content
stringlengths
7
1.05M
# Calculate factorial of a number def factorial(n): ''' Returns the factorial of n. e.g. factorial(7) = 7x76x5x4x3x2x1 = 5040. ''' answer = 1 for i in range(1,n+1): answer = answer * i return answer if __name__ == "__main__": assert factorial(7) == 5040
line = input().split() n = int(line[0]) m = int(line[1]) print(str(abs(n-m)))
# AUTOGENERATED BY NBDEV! DO NOT EDIT! __all__ = ["index", "modules", "custom_doc_links", "git_url"] index = {"c_imshow": "01_nn_utils.ipynb", "Flatten": "01_nn_utils.ipynb", "conv3x3": "01_nn_utils.ipynb", "get_proto_accuracy": "01_nn_utils.ipynb", "get_accuracy": "02_maml_pl.ipynb", "collate_task": "01b_data_loaders_pl.ipynb", "collate_task_batch": "01b_data_loaders_pl.ipynb", "get_episode_loader": "01b_data_loaders_pl.ipynb", "UnlabelledDataset": "01b_data_loaders_pl.ipynb", "get_cub_default_transform": "01b_data_loaders_pl.ipynb", "get_simCLR_transform": "01b_data_loaders_pl.ipynb", "get_omniglot_transform": "01b_data_loaders_pl.ipynb", "get_custom_transform": "01b_data_loaders_pl.ipynb", "identity_transform": "01b_data_loaders_pl.ipynb", "UnlabelledDataModule": "01b_data_loaders_pl.ipynb", "OmniglotDataModule": "01b_data_loaders_pl.ipynb", "MiniImagenetDataModule": "01b_data_loaders_pl.ipynb", "cg": "01c_grad_utils.ipynb", "cat_list_to_tensor": "01c_grad_utils.ipynb", "reverse_unroll": "01c_grad_utils.ipynb", "reverse": "01c_grad_utils.ipynb", "fixed_point": "01c_grad_utils.ipynb", "CG": "01c_grad_utils.ipynb", "CG_normaleq": "01c_grad_utils.ipynb", "neumann": "01c_grad_utils.ipynb", "exact": "01c_grad_utils.ipynb", "grd": "01c_grad_utils.ipynb", "list_dot": "01c_grad_utils.ipynb", "jvp": "01c_grad_utils.ipynb", "get_outer_gradients": "01c_grad_utils.ipynb", "update_tensor_grads": "01c_grad_utils.ipynb", "grad_unused_zero": "01c_grad_utils.ipynb", "DifferentiableOptimizer": "01c_grad_utils.ipynb", "HeavyBall": "01c_grad_utils.ipynb", "Momentum": "01c_grad_utils.ipynb", "GradientDescent": "01c_grad_utils.ipynb", "gd_step": "01c_grad_utils.ipynb", "heavy_ball_step": "01c_grad_utils.ipynb", "torch_momentum_step": "01c_grad_utils.ipynb", "euclidean_distance": "01d_proto_utils.ipynb", "cosine_similarity": "01d_proto_utils.ipynb", "get_num_samples": "01d_proto_utils.ipynb", "get_prototypes": "01d_proto_utils.ipynb", "prototypical_loss": "01d_proto_utils.ipynb", "clusterer": "01d_proto_utils.ipynb", "cluster_diff_loss": "01d_proto_utils.ipynb", "CNN_4Layer": "01d_proto_utils.ipynb", "Encoder": "01d_proto_utils.ipynb", "Decoder": "01d_proto_utils.ipynb", "CAE": "01d_proto_utils.ipynb", "Encoder4L": "01d_proto_utils.ipynb", "Decoder4L": "01d_proto_utils.ipynb", "Decoder4L4Mini": "01d_proto_utils.ipynb", "CAE4L": "01d_proto_utils.ipynb", "get_images_labels_from_dl": "01d_proto_utils.ipynb", "logger": "02_maml_pl.ipynb", "ConvolutionalNeuralNetwork": "02_maml_pl.ipynb", "MAML": "02_maml_pl.ipynb", "UMTRA": "02_maml_pl.ipynb", "cg_solve": "02b_iMAML.ipynb", "iMAML": "02b_iMAML.ipynb", "PrototypicalNetwork": "03_protonet_pl.ipynb", "CactusPrototypicalModel": "03_protonet_pl.ipynb", "ProtoModule": "03_protonet_pl.ipynb", "Classifier": "03b_ProtoCLR.ipynb", "get_train_images": "03b_ProtoCLR.ipynb", "WandbImageCallback": "03b_ProtoCLR.ipynb", "TensorBoardImageCallback": "03b_ProtoCLR.ipynb", "ConfidenceIntervalCallback": "03b_ProtoCLR.ipynb", "UMAPCallback": "03b_ProtoCLR.ipynb", "UMAPClusteringCallback": "03b_ProtoCLR.ipynb", "PCACallback": "03b_ProtoCLR.ipynb", "ProtoCLR": "03b_ProtoCLR.ipynb", "Partition": "04_cactus.ipynb", "CactusTaskDataset": "04_cactus.ipynb", "get_partitions_kmeans": "04_cactus.ipynb", "DataOpt": "04_cactus.ipynb", "LoaderOpt": "04_cactus.ipynb", "load": "04_cactus.ipynb", "CactusDataModule": "04_cactus.ipynb"} modules = ["nn_utils.py", "pl_dataloaders.py", "hypergrad.py", "proto_utils.py", "maml.py", "imaml.py", "protonets.py", "protoclr.py", "cactus.py"] doc_url = "https://ojss.github.io/unsupervised_meta_learning/" git_url = "https://github.com/ojss/unsupervised_meta_learning/tree/main/" def custom_doc_links(name): return None
''' The MIT License (MIT) Copyright (c) 2016 WavyCloud Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ''' def add_permission(QueueUrl=None, Label=None, AWSAccountIds=None, Actions=None): """ Adds a permission to a queue for a specific principal . This allows sharing access to the queue. When you create a queue, you have full control access rights for the queue. Only you, the owner of the queue, can grant or deny permissions to the queue. For more information about these permissions, see Shared Queues in the Amazon SQS Developer Guide . See also: AWS API Documentation :example: response = client.add_permission( QueueUrl='string', Label='string', AWSAccountIds=[ 'string', ], Actions=[ 'string', ] ) :type QueueUrl: string :param QueueUrl: [REQUIRED] The URL of the Amazon SQS queue to which permissions are added. Queue URLs are case-sensitive. :type Label: string :param Label: [REQUIRED] The unique identification of the permission you're setting (for example, AliceSendMessage ). Maximum 80 characters. Allowed characters include alphanumeric characters, hyphens (- ), and underscores (_ ). :type AWSAccountIds: list :param AWSAccountIds: [REQUIRED] The AWS account number of the principal who is given permission. The principal must have an AWS account, but does not need to be signed up for Amazon SQS. For information about locating the AWS account identification, see Your AWS Identifiers in the Amazon SQS Developer Guide . (string) -- :type Actions: list :param Actions: [REQUIRED] The action the client wants to allow for the specified principal. The following values are valid: * ChangeMessageVisibility DeleteMessage GetQueueAttributes GetQueueUrl ReceiveMessage SendMessage For more information about these actions, see Understanding Permissions in the Amazon SQS Developer Guide . Specifying SendMessage , DeleteMessage , or ChangeMessageVisibility for ActionName.n also grants permissions for the corresponding batch versions of those actions: SendMessageBatch , DeleteMessageBatch , and ChangeMessageVisibilityBatch . (string) -- """ pass def can_paginate(operation_name=None): """ Check if an operation can be paginated. :type operation_name: string :param operation_name: The operation name. This is the same name as the method name on the client. For example, if the method name is create_foo, and you'd normally invoke the operation as client.create_foo(**kwargs), if the create_foo operation can be paginated, you can use the call client.get_paginator('create_foo'). """ pass def change_message_visibility(QueueUrl=None, ReceiptHandle=None, VisibilityTimeout=None): """ Changes the visibility timeout of a specified message in a queue to a new value. The maximum allowed timeout value is 12 hours. Thus, you can't extend the timeout of a message in an existing queue to more than a total visibility timeout of 12 hours. For more information, see Visibility Timeout in the Amazon SQS Developer Guide . For example, you have a message and with the default visibility timeout of 5 minutes. After 3 minutes, you call ChangeMessageVisiblity with a timeout of 10 minutes. At that time, the timeout for the message is extended by 10 minutes beyond the time of the ChangeMessageVisibility action. This results in a total visibility timeout of 13 minutes. You can continue to call the ChangeMessageVisibility to extend the visibility timeout to a maximum of 12 hours. If you try to extend the visibility timeout beyond 12 hours, your request is rejected. A message is considered to be in flight after it's received from a queue by a consumer, but not yet deleted from the queue. For standard queues, there can be a maximum of 120,000 inflight messages per queue. If you reach this limit, Amazon SQS returns the OverLimit error message. To avoid reaching the limit, you should delete messages from the queue after they're processed. You can also increase the number of queues you use to process your messages. For FIFO queues, there can be a maximum of 20,000 inflight messages per queue. If you reach this limit, Amazon SQS returns no error messages. See also: AWS API Documentation :example: response = client.change_message_visibility( QueueUrl='string', ReceiptHandle='string', VisibilityTimeout=123 ) :type QueueUrl: string :param QueueUrl: [REQUIRED] The URL of the Amazon SQS queue whose message's visibility is changed. Queue URLs are case-sensitive. :type ReceiptHandle: string :param ReceiptHandle: [REQUIRED] The receipt handle associated with the message whose visibility timeout is changed. This parameter is returned by the `` ReceiveMessage `` action. :type VisibilityTimeout: integer :param VisibilityTimeout: [REQUIRED] The new value for the message's visibility timeout (in seconds). Values values: 0 to 43200 . Maximum: 12 hours. """ pass def change_message_visibility_batch(QueueUrl=None, Entries=None): """ Changes the visibility timeout of multiple messages. This is a batch version of `` ChangeMessageVisibility .`` The result of the action on each message is reported individually in the response. You can send up to 10 `` ChangeMessageVisibility `` requests with each ChangeMessageVisibilityBatch action. See also: AWS API Documentation :example: response = client.change_message_visibility_batch( QueueUrl='string', Entries=[ { 'Id': 'string', 'ReceiptHandle': 'string', 'VisibilityTimeout': 123 }, ] ) :type QueueUrl: string :param QueueUrl: [REQUIRED] The URL of the Amazon SQS queue whose messages' visibility is changed. Queue URLs are case-sensitive. :type Entries: list :param Entries: [REQUIRED] A list of receipt handles of the messages for which the visibility timeout must be changed. (dict) --Encloses a receipt handle and an entry id for each message in `` ChangeMessageVisibilityBatch .`` Warning All of the following list parameters must be prefixed with ChangeMessageVisibilityBatchRequestEntry.n , where n is an integer value starting with 1 . For example, a parameter list for this action might look like this: amp;ChangeMessageVisibilityBatchRequestEntry.1.Id=change_visibility_msg_2 amp;ChangeMessageVisibilityBatchRequestEntry.1.ReceiptHandle=replaceableYour_Receipt_Handle/replaceable amp;ChangeMessageVisibilityBatchRequestEntry.1.VisibilityTimeout=45 Id (string) -- [REQUIRED]An identifier for this particular receipt handle used to communicate the result. Note The Id s of a batch request need to be unique within a request ReceiptHandle (string) -- [REQUIRED]A receipt handle. VisibilityTimeout (integer) --The new value (in seconds) for the message's visibility timeout. :rtype: dict :return: { 'Successful': [ { 'Id': 'string' }, ], 'Failed': [ { 'Id': 'string', 'SenderFault': True|False, 'Code': 'string', 'Message': 'string' }, ] } """ pass def create_queue(QueueName=None, Attributes=None): """ Creates a new standard or FIFO queue. You can pass one or more attributes in the request. Keep the following caveats in mind: To successfully create a new queue, you must provide a queue name that adheres to the limits related to queues and is unique within the scope of your queues. To get the queue URL, use the `` GetQueueUrl `` action. `` GetQueueUrl `` requires only the QueueName parameter. be aware of existing queue names: See also: AWS API Documentation Examples The following operation creates an SQS queue named MyQueue. Expected Output: :example: response = client.create_queue( QueueName='string', Attributes={ 'string': 'string' } ) :type QueueName: string :param QueueName: [REQUIRED] The name of the new queue. The following limits apply to this name: A queue name can have up to 80 characters. Valid values: alphanumeric characters, hyphens (- ), and underscores (_ ). A FIFO queue name must end with the .fifo suffix. Queue names are case-sensitive. :type Attributes: dict :param Attributes: A map of attributes with their corresponding values. The following lists the names, descriptions, and values of the special request parameters that the CreateQueue action uses: DelaySeconds - The length of time, in seconds, for which the delivery of all messages in the queue is delayed. Valid values: An integer from 0 to 900 seconds (15 minutes). The default is 0 (zero). MaximumMessageSize - The limit of how many bytes a message can contain before Amazon SQS rejects it. Valid values: An integer from 1,024 bytes (1 KiB) to 262,144 bytes (256 KiB). The default is 262,144 (256 KiB). MessageRetentionPeriod - The length of time, in seconds, for which Amazon SQS retains a message. Valid values: An integer from 60 seconds (1 minute) to 1,209,600 seconds (14 days). The default is 345,600 (4 days). Policy - The queue's policy. A valid AWS policy. For more information about policy structure, see Overview of AWS IAM Policies in the Amazon IAM User Guide . ReceiveMessageWaitTimeSeconds - The length of time, in seconds, for which a `` ReceiveMessage `` action waits for a message to arrive. Valid values: An integer from 0 to 20 (seconds). The default is 0 (zero). RedrivePolicy - The parameters for the dead letter queue functionality of the source queue. For more information about the redrive policy and dead letter queues, see Using Amazon SQS Dead Letter Queues in the Amazon SQS Developer Guide . Note The dead letter queue of a FIFO queue must also be a FIFO queue. Similarly, the dead letter queue of a standard queue must also be a standard queue. VisibilityTimeout - The visibility timeout for the queue. Valid values: An integer from 0 to 43,200 (12 hours). The default is 30. For more information about the visibility timeout, see Visibility Timeout in the Amazon SQS Developer Guide . The following attributes apply only to server-side-encryption : KmsMasterKeyId - The ID of an AWS-managed customer master key (CMK) for Amazon SQS or a custom CMK. For more information, see Key Terms . While the alias of the AWS-managed CMK for Amazon SQS is always alias/aws/sqs , the alias of a custom CMK can, for example, be alias/aws/sqs . For more examples, see KeyId in the AWS Key Management Service API Reference . KmsDataKeyReusePeriodSeconds - The length of time, in seconds, for which Amazon SQS can reuse a data key to encrypt or decrypt messages before calling AWS KMS again. An integer representing seconds, between 60 seconds (1 minute) and 86,400 seconds (24 hours). The default is 300 (5 minutes). A shorter time period provides better security but results in more calls to KMS which incur charges after Free Tier. For more information, see How Does the Data Key Reuse Period Work? . The following attributes apply only to FIFO (first-in-first-out) queues : FifoQueue - Designates a queue as FIFO. Valid values: true , false . You can provide this attribute only during queue creation. You can't change it for an existing queue. When you set this attribute, you must also provide the MessageGroupId for your messages explicitly. For more information, see FIFO Queue Logic in the Amazon SQS Developer Guide . ContentBasedDeduplication - Enables content-based deduplication. Valid values: true , false . For more information, see Exactly-Once Processing in the Amazon SQS Developer Guide . Every message must have a unique MessageDeduplicationId , You may provide a MessageDeduplicationId explicitly. If you aren't able to provide a MessageDeduplicationId and you enable ContentBasedDeduplication for your queue, Amazon SQS uses a SHA-256 hash to generate the MessageDeduplicationId using the body of the message (but not the attributes of the message). If you don't provide a MessageDeduplicationId and the queue doesn't have ContentBasedDeduplication set, the action fails with an error. If the queue has ContentBasedDeduplication set, your MessageDeduplicationId overrides the generated one. When ContentBasedDeduplication is in effect, messages with identical content sent within the deduplication interval are treated as duplicates and only one copy of the message is delivered. If you send one message with ContentBasedDeduplication enabled and then another message with a MessageDeduplicationId that is the same as the one generated for the first MessageDeduplicationId , the two messages are treated as duplicates and only one copy of the message is delivered. Any other valid special request parameters (such as the following) are ignored: ApproximateNumberOfMessages ApproximateNumberOfMessagesDelayed ApproximateNumberOfMessagesNotVisible CreatedTimestamp LastModifiedTimestamp QueueArn (string) -- (string) -- :rtype: dict :return: { 'QueueUrl': 'string' } :returns: If you don't provide a value for an attribute, the queue is created with the default value for the attribute. If you delete a queue, you must wait at least 60 seconds before creating a queue with the same name. """ pass def delete_message(QueueUrl=None, ReceiptHandle=None): """ Deletes the specified message from the specified queue. You specify the message by using the message's receipt handle and not the MessageId you receive when you send the message. Even if the message is locked by another reader due to the visibility timeout setting, it is still deleted from the queue. If you leave a message in the queue for longer than the queue's configured retention period, Amazon SQS automatically deletes the message. See also: AWS API Documentation :example: response = client.delete_message( QueueUrl='string', ReceiptHandle='string' ) :type QueueUrl: string :param QueueUrl: [REQUIRED] The URL of the Amazon SQS queue from which messages are deleted. Queue URLs are case-sensitive. :type ReceiptHandle: string :param ReceiptHandle: [REQUIRED] The receipt handle associated with the message to delete. """ pass def delete_message_batch(QueueUrl=None, Entries=None): """ Deletes up to ten messages from the specified queue. This is a batch version of `` DeleteMessage .`` The result of the action on each message is reported individually in the response. See also: AWS API Documentation :example: response = client.delete_message_batch( QueueUrl='string', Entries=[ { 'Id': 'string', 'ReceiptHandle': 'string' }, ] ) :type QueueUrl: string :param QueueUrl: [REQUIRED] The URL of the Amazon SQS queue from which messages are deleted. Queue URLs are case-sensitive. :type Entries: list :param Entries: [REQUIRED] A list of receipt handles for the messages to be deleted. (dict) --Encloses a receipt handle and an identifier for it. Id (string) -- [REQUIRED]An identifier for this particular receipt handle. This is used to communicate the result. Note The Id s of a batch request need to be unique within a request ReceiptHandle (string) -- [REQUIRED]A receipt handle. :rtype: dict :return: { 'Successful': [ { 'Id': 'string' }, ], 'Failed': [ { 'Id': 'string', 'SenderFault': True|False, 'Code': 'string', 'Message': 'string' }, ] } """ pass def delete_queue(QueueUrl=None): """ Deletes the queue specified by the QueueUrl , even if the queue is empty. If the specified queue doesn't exist, Amazon SQS returns a successful response. When you delete a queue, the deletion process takes up to 60 seconds. Requests you send involving that queue during the 60 seconds might succeed. For example, a `` SendMessage `` request might succeed, but after 60 seconds the queue and the message you sent no longer exist. When you delete a queue, you must wait at least 60 seconds before creating a queue with the same name. See also: AWS API Documentation :example: response = client.delete_queue( QueueUrl='string' ) :type QueueUrl: string :param QueueUrl: [REQUIRED] The URL of the Amazon SQS queue to delete. Queue URLs are case-sensitive. """ pass def generate_presigned_url(ClientMethod=None, Params=None, ExpiresIn=None, HttpMethod=None): """ Generate a presigned url given a client, its method, and arguments :type ClientMethod: string :param ClientMethod: The client method to presign for :type Params: dict :param Params: The parameters normally passed to ClientMethod. :type ExpiresIn: int :param ExpiresIn: The number of seconds the presigned url is valid for. By default it expires in an hour (3600 seconds) :type HttpMethod: string :param HttpMethod: The http method to use on the generated url. By default, the http method is whatever is used in the method's model. """ pass def get_paginator(operation_name=None): """ Create a paginator for an operation. :type operation_name: string :param operation_name: The operation name. This is the same name as the method name on the client. For example, if the method name is create_foo, and you'd normally invoke the operation as client.create_foo(**kwargs), if the create_foo operation can be paginated, you can use the call client.get_paginator('create_foo'). :rtype: L{botocore.paginate.Paginator} """ pass def get_queue_attributes(QueueUrl=None, AttributeNames=None): """ Gets attributes for the specified queue. See also: AWS API Documentation :example: response = client.get_queue_attributes( QueueUrl='string', AttributeNames=[ 'All'|'Policy'|'VisibilityTimeout'|'MaximumMessageSize'|'MessageRetentionPeriod'|'ApproximateNumberOfMessages'|'ApproximateNumberOfMessagesNotVisible'|'CreatedTimestamp'|'LastModifiedTimestamp'|'QueueArn'|'ApproximateNumberOfMessagesDelayed'|'DelaySeconds'|'ReceiveMessageWaitTimeSeconds'|'RedrivePolicy'|'FifoQueue'|'ContentBasedDeduplication'|'KmsMasterKeyId'|'KmsDataKeyReusePeriodSeconds', ] ) :type QueueUrl: string :param QueueUrl: [REQUIRED] The URL of the Amazon SQS queue whose attribute information is retrieved. Queue URLs are case-sensitive. :type AttributeNames: list :param AttributeNames: A list of attributes for which to retrieve information. Note In the future, new attributes might be added. If you write code that calls this action, we recommend that you structure your code so that it can handle new attributes gracefully. The following attributes are supported: All - Returns all values. ApproximateNumberOfMessages - Returns the approximate number of visible messages in a queue. For more information, see Resources Required to Process Messages in the Amazon SQS Developer Guide . ApproximateNumberOfMessagesDelayed - Returns the approximate number of messages that are waiting to be added to the queue. ApproximateNumberOfMessagesNotVisible - Returns the approximate number of messages that have not timed-out and aren't deleted. For more information, see Resources Required to Process Messages in the Amazon SQS Developer Guide . CreatedTimestamp - Returns the time when the queue was created in seconds (epoch time ). DelaySeconds - Returns the default delay on the queue in seconds. LastModifiedTimestamp - Returns the time when the queue was last changed in seconds (epoch time ). MaximumMessageSize - Returns the limit of how many bytes a message can contain before Amazon SQS rejects it. MessageRetentionPeriod - Returns the length of time, in seconds, for which Amazon SQS retains a message. Policy - Returns the policy of the queue. QueueArn - Returns the Amazon resource name (ARN) of the queue. ReceiveMessageWaitTimeSeconds - Returns the length of time, in seconds, for which the ReceiveMessage action waits for a message to arrive. RedrivePolicy - Returns the parameters for dead letter queue functionality of the source queue. For more information about the redrive policy and dead letter queues, see Using Amazon SQS Dead Letter Queues in the Amazon SQS Developer Guide . VisibilityTimeout - Returns the visibility timeout for the queue. For more information about the visibility timeout, see Visibility Timeout in the Amazon SQS Developer Guide . The following attributes apply only to server-side-encryption : KmsMasterKeyId - Returns the ID of an AWS-managed customer master key (CMK) for Amazon SQS or a custom CMK. For more information, see Key Terms . KmsDataKeyReusePeriodSeconds - Returns the length of time, in seconds, for which Amazon SQS can reuse a data key to encrypt or decrypt messages before calling AWS KMS again. The following attributes apply only to FIFO (first-in-first-out) queues : FifoQueue - Returns whether the queue is FIFO. For more information, see FIFO Queue Logic in the Amazon SQS Developer Guide . Note To determine whether a queue is FIFO , you can check whether QueueName ends with the .fifo suffix. ContentBasedDeduplication - Returns whether content-based deduplication is enabled for the queue. For more information, see Exactly-Once Processing in the Amazon SQS Developer Guide . (string) -- :rtype: dict :return: { 'Attributes': { 'string': 'string' } } :returns: (string) -- (string) -- """ pass def get_queue_url(QueueName=None, QueueOwnerAWSAccountId=None): """ Returns the URL of an existing queue. This action provides a simple way to retrieve the URL of an Amazon SQS queue. To access a queue that belongs to another AWS account, use the QueueOwnerAWSAccountId parameter to specify the account ID of the queue's owner. The queue's owner must grant you permission to access the queue. For more information about shared queue access, see `` AddPermission `` or see Shared Queues in the Amazon SQS Developer Guide . See also: AWS API Documentation Examples The following example retrieves the queue ARN. Expected Output: :example: response = client.get_queue_url( QueueName='string', QueueOwnerAWSAccountId='string' ) :type QueueName: string :param QueueName: [REQUIRED] The name of the queue whose URL must be fetched. Maximum 80 characters. Valid values: alphanumeric characters, hyphens (- ), and underscores (_ ). Queue names are case-sensitive. :type QueueOwnerAWSAccountId: string :param QueueOwnerAWSAccountId: The AWS account ID of the account that created the queue. :rtype: dict :return: { 'QueueUrl': 'string' } """ pass def get_waiter(): """ """ pass def list_dead_letter_source_queues(QueueUrl=None): """ Returns a list of your queues that have the RedrivePolicy queue attribute configured with a dead letter queue. For more information about using dead letter queues, see Using Amazon SQS Dead Letter Queues in the Amazon SQS Developer Guide . See also: AWS API Documentation :example: response = client.list_dead_letter_source_queues( QueueUrl='string' ) :type QueueUrl: string :param QueueUrl: [REQUIRED] The URL of a dead letter queue. Queue URLs are case-sensitive. :rtype: dict :return: { 'queueUrls': [ 'string', ] } """ pass def list_queues(QueueNamePrefix=None): """ Returns a list of your queues. The maximum number of queues that can be returned is 1,000. If you specify a value for the optional QueueNamePrefix parameter, only queues with a name that begins with the specified value are returned. See also: AWS API Documentation :example: response = client.list_queues( QueueNamePrefix='string' ) :type QueueNamePrefix: string :param QueueNamePrefix: A string to use for filtering the list results. Only those queues whose name begins with the specified string are returned. Queue names are case-sensitive. :rtype: dict :return: { 'QueueUrls': [ 'string', ] } """ pass def purge_queue(QueueUrl=None): """ Deletes the messages in a queue specified by the QueueURL parameter. When you purge a queue, the message deletion process takes up to 60 seconds. All messages sent to the queue before calling the PurgeQueue action are deleted. Messages sent to the queue while it is being purged might be deleted. While the queue is being purged, messages sent to the queue before PurgeQueue is called might be received, but are deleted within the next minute. See also: AWS API Documentation :example: response = client.purge_queue( QueueUrl='string' ) :type QueueUrl: string :param QueueUrl: [REQUIRED] The URL of the queue from which the PurgeQueue action deletes messages. Queue URLs are case-sensitive. """ pass def receive_message(QueueUrl=None, AttributeNames=None, MessageAttributeNames=None, MaxNumberOfMessages=None, VisibilityTimeout=None, WaitTimeSeconds=None, ReceiveRequestAttemptId=None): """ Retrieves one or more messages (up to 10), from the specified queue. Using the WaitTimeSeconds parameter enables long-poll support. For more information, see Amazon SQS Long Polling in the Amazon SQS Developer Guide . Short poll is the default behavior where a weighted random set of machines is sampled on a ReceiveMessage call. Thus, only the messages on the sampled machines are returned. If the number of messages in the queue is small (fewer than 1,000), you most likely get fewer messages than you requested per ReceiveMessage call. If the number of messages in the queue is extremely small, you might not receive any messages in a particular ReceiveMessage response. If this happens, repeat the request. For each message returned, the response includes the following: The receipt handle is the identifier you must provide when deleting the message. For more information, see Queue and Message Identifiers in the Amazon SQS Developer Guide . You can provide the VisibilityTimeout parameter in your request. The parameter is applied to the messages that Amazon SQS returns in the response. If you don't include the parameter, the overall visibility timeout for the queue is used for the returned messages. For more information, see Visibility Timeout in the Amazon SQS Developer Guide . A message that isn't deleted or a message whose visibility isn't extended before the visibility timeout expires counts as a failed receive. Depending on the configuration of the queue, the message might be sent to the dead letter queue. See also: AWS API Documentation :example: response = client.receive_message( QueueUrl='string', AttributeNames=[ 'All'|'Policy'|'VisibilityTimeout'|'MaximumMessageSize'|'MessageRetentionPeriod'|'ApproximateNumberOfMessages'|'ApproximateNumberOfMessagesNotVisible'|'CreatedTimestamp'|'LastModifiedTimestamp'|'QueueArn'|'ApproximateNumberOfMessagesDelayed'|'DelaySeconds'|'ReceiveMessageWaitTimeSeconds'|'RedrivePolicy'|'FifoQueue'|'ContentBasedDeduplication'|'KmsMasterKeyId'|'KmsDataKeyReusePeriodSeconds', ], MessageAttributeNames=[ 'string', ], MaxNumberOfMessages=123, VisibilityTimeout=123, WaitTimeSeconds=123, ReceiveRequestAttemptId='string' ) :type QueueUrl: string :param QueueUrl: [REQUIRED] The URL of the Amazon SQS queue from which messages are received. Queue URLs are case-sensitive. :type AttributeNames: list :param AttributeNames: A list of attributes that need to be returned along with each message. These attributes include: All - Returns all values. ApproximateFirstReceiveTimestamp - Returns the time the message was first received from the queue (epoch time in milliseconds). ApproximateReceiveCount - Returns the number of times a message has been received from the queue but not deleted. SenderId For an IAM user, returns the IAM user ID, for example ABCDEFGHI1JKLMNOPQ23R . For an IAM role, returns the IAM role ID, for example ABCDE1F2GH3I4JK5LMNOP:i-a123b456 . SentTimestamp - Returns the time the message was sent to the queue (epoch time in milliseconds). MessageDeduplicationId - Returns the value provided by the sender that calls the `` SendMessage `` action. MessageGroupId - Returns the value provided by the sender that calls the `` SendMessage `` action. Messages with the same MessageGroupId are returned in sequence. SequenceNumber - Returns the value provided by Amazon SQS. Any other valid special request parameters (such as the following) are ignored: ApproximateNumberOfMessages ApproximateNumberOfMessagesDelayed ApproximateNumberOfMessagesNotVisible CreatedTimestamp ContentBasedDeduplication DelaySeconds FifoQueue LastModifiedTimestamp MaximumMessageSize MessageRetentionPeriod Policy QueueArn , ReceiveMessageWaitTimeSeconds RedrivePolicy VisibilityTimeout (string) -- :type MessageAttributeNames: list :param MessageAttributeNames: The name of the message attribute, where N is the index. The name can contain alphanumeric characters and the underscore (_ ), hyphen (- ), and period (. ). The name is case-sensitive and must be unique among all attribute names for the message. The name must not start with AWS-reserved prefixes such as AWS. or Amazon. (or any casing variants). The name must not start or end with a period (. ), and it should not have periods in succession (.. ). The name can be up to 256 characters long. When using ReceiveMessage , you can send a list of attribute names to receive, or you can return all of the attributes by specifying All or .* in your request. You can also use all message attributes starting with a prefix, for example bar.* . (string) -- :type MaxNumberOfMessages: integer :param MaxNumberOfMessages: The maximum number of messages to return. Amazon SQS never returns more messages than this value (however, fewer messages might be returned). Valid values are 1 to 10. Default is 1. :type VisibilityTimeout: integer :param VisibilityTimeout: The duration (in seconds) that the received messages are hidden from subsequent retrieve requests after being retrieved by a ReceiveMessage request. :type WaitTimeSeconds: integer :param WaitTimeSeconds: The duration (in seconds) for which the call waits for a message to arrive in the queue before returning. If a message is available, the call returns sooner than WaitTimeSeconds . :type ReceiveRequestAttemptId: string :param ReceiveRequestAttemptId: This parameter applies only to FIFO (first-in-first-out) queues. The token used for deduplication of ReceiveMessage calls. If a networking issue occurs after a ReceiveMessage action, and instead of a response you receive a generic error, you can retry the same action with an identical ReceiveRequestAttemptId to retrieve the same set of messages, even if their visibility timeout has not yet expired. You can use ReceiveRequestAttemptId only for 5 minutes after a ReceiveMessage action. When you set FifoQueue , a caller of the ReceiveMessage action can provide a ReceiveRequestAttemptId explicitly. If a caller of the ReceiveMessage action doesn't provide a ReceiveRequestAttemptId , Amazon SQS generates a ReceiveRequestAttemptId . You can retry the ReceiveMessage action with the same ReceiveRequestAttemptId if none of the messages have been modified (deleted or had their visibility changes). During a visibility timeout, subsequent calls with the same ReceiveRequestAttemptId return the same messages and receipt handles. If a retry occurs within the deduplication interval, it resets the visibility timeout. For more information, see Visibility Timeout in the Amazon Simple Queue Service Developer Guide . Warning If a caller of the ReceiveMessage action is still processing messages when the visibility timeout expires and messages become visible, another worker reading from the same queue can receive the same messages and therefore process duplicates. Also, if a reader whose message processing time is longer than the visibility timeout tries to delete the processed messages, the action fails with an error. To mitigate this effect, ensure that your application observes a safe threshold before the visibility timeout expires and extend the visibility timeout as necessary. While messages with a particular MessageGroupId are invisible, no more messages belonging to the same MessageGroupId are returned until the visibility timeout expires. You can still receive messages with another MessageGroupId as long as it is also visible. If a caller of ReceiveMessage can't track the ReceiveRequestAttemptId , no retries work until the original visibility timeout expires. As a result, delays might occur but the messages in the queue remain in a strict order. The length of ReceiveRequestAttemptId is 128 characters. ReceiveRequestAttemptId can contain alphanumeric characters (a-z , A-Z , 0-9 ) and punctuation (!'#$%'()*+,-./:;=?@[\]^_`{|}~ ). For best practices of using ReceiveRequestAttemptId , see Using the ReceiveRequestAttemptId Request Parameter in the Amazon Simple Queue Service Developer Guide . :rtype: dict :return: { 'Messages': [ { 'MessageId': 'string', 'ReceiptHandle': 'string', 'MD5OfBody': 'string', 'Body': 'string', 'Attributes': { 'string': 'string' }, 'MD5OfMessageAttributes': 'string', 'MessageAttributes': { 'string': { 'StringValue': 'string', 'BinaryValue': b'bytes', 'StringListValues': [ 'string', ], 'BinaryListValues': [ b'bytes', ], 'DataType': 'string' } } }, ] } :returns: QueueUrl (string) -- [REQUIRED] The URL of the Amazon SQS queue from which messages are received. Queue URLs are case-sensitive. AttributeNames (list) -- A list of attributes that need to be returned along with each message. These attributes include: All - Returns all values. ApproximateFirstReceiveTimestamp - Returns the time the message was first received from the queue (epoch time in milliseconds). ApproximateReceiveCount - Returns the number of times a message has been received from the queue but not deleted. SenderId For an IAM user, returns the IAM user ID, for example ABCDEFGHI1JKLMNOPQ23R . For an IAM role, returns the IAM role ID, for example ABCDE1F2GH3I4JK5LMNOP:i-a123b456 . SentTimestamp - Returns the time the message was sent to the queue (epoch time in milliseconds). MessageDeduplicationId - Returns the value provided by the sender that calls the `` SendMessage `` action. MessageGroupId - Returns the value provided by the sender that calls the `` SendMessage `` action. Messages with the same MessageGroupId are returned in sequence. SequenceNumber - Returns the value provided by Amazon SQS. Any other valid special request parameters (such as the following) are ignored: ApproximateNumberOfMessages ApproximateNumberOfMessagesDelayed ApproximateNumberOfMessagesNotVisible CreatedTimestamp ContentBasedDeduplication DelaySeconds FifoQueue LastModifiedTimestamp MaximumMessageSize MessageRetentionPeriod Policy QueueArn , ReceiveMessageWaitTimeSeconds RedrivePolicy VisibilityTimeout (string) -- MessageAttributeNames (list) -- The name of the message attribute, where N is the index. The name can contain alphanumeric characters and the underscore (_ ), hyphen (- ), and period (. ). The name is case-sensitive and must be unique among all attribute names for the message. The name must not start with AWS-reserved prefixes such as AWS. or Amazon. (or any casing variants). The name must not start or end with a period (. ), and it should not have periods in succession (.. ). The name can be up to 256 characters long. When using ReceiveMessage , you can send a list of attribute names to receive, or you can return all of the attributes by specifying All or .* in your request. You can also use all message attributes starting with a prefix, for example bar.* . (string) -- MaxNumberOfMessages (integer) -- The maximum number of messages to return. Amazon SQS never returns more messages than this value (however, fewer messages might be returned). Valid values are 1 to 10. Default is 1. VisibilityTimeout (integer) -- The duration (in seconds) that the received messages are hidden from subsequent retrieve requests after being retrieved by a ReceiveMessage request. WaitTimeSeconds (integer) -- The duration (in seconds) for which the call waits for a message to arrive in the queue before returning. If a message is available, the call returns sooner than WaitTimeSeconds . ReceiveRequestAttemptId (string) -- This parameter applies only to FIFO (first-in-first-out) queues. The token used for deduplication of ReceiveMessage calls. If a networking issue occurs after a ReceiveMessage action, and instead of a response you receive a generic error, you can retry the same action with an identical ReceiveRequestAttemptId to retrieve the same set of messages, even if their visibility timeout has not yet expired. You can use ReceiveRequestAttemptId only for 5 minutes after a ReceiveMessage action. When you set FifoQueue , a caller of the ReceiveMessage action can provide a ReceiveRequestAttemptId explicitly. If a caller of the ReceiveMessage action doesn't provide a ReceiveRequestAttemptId , Amazon SQS generates a ReceiveRequestAttemptId . You can retry the ReceiveMessage action with the same ReceiveRequestAttemptId if none of the messages have been modified (deleted or had their visibility changes). During a visibility timeout, subsequent calls with the same ReceiveRequestAttemptId return the same messages and receipt handles. If a retry occurs within the deduplication interval, it resets the visibility timeout. For more information, see Visibility Timeout in the Amazon Simple Queue Service Developer Guide . Warning If a caller of the ReceiveMessage action is still processing messages when the visibility timeout expires and messages become visible, another worker reading from the same queue can receive the same messages and therefore process duplicates. Also, if a reader whose message processing time is longer than the visibility timeout tries to delete the processed messages, the action fails with an error. To mitigate this effect, ensure that your application observes a safe threshold before the visibility timeout expires and extend the visibility timeout as necessary. While messages with a particular MessageGroupId are invisible, no more messages belonging to the same MessageGroupId are returned until the visibility timeout expires. You can still receive messages with another MessageGroupId as long as it is also visible. If a caller of ReceiveMessage can't track the ReceiveRequestAttemptId , no retries work until the original visibility timeout expires. As a result, delays might occur but the messages in the queue remain in a strict order. The length of ReceiveRequestAttemptId is 128 characters. ReceiveRequestAttemptId can contain alphanumeric characters (a-z , A-Z , 0-9 ) and punctuation (!"#$%'()*+,-./:;=?@[\]^_`{|}~ ). For best practices of using ReceiveRequestAttemptId , see Using the ReceiveRequestAttemptId Request Parameter in the Amazon Simple Queue Service Developer Guide . """ pass def remove_permission(QueueUrl=None, Label=None): """ Revokes any permissions in the queue policy that matches the specified Label parameter. Only the owner of the queue can remove permissions. See also: AWS API Documentation :example: response = client.remove_permission( QueueUrl='string', Label='string' ) :type QueueUrl: string :param QueueUrl: [REQUIRED] The URL of the Amazon SQS queue from which permissions are removed. Queue URLs are case-sensitive. :type Label: string :param Label: [REQUIRED] The identification of the permission to remove. This is the label added using the `` AddPermission `` action. """ pass def send_message(QueueUrl=None, MessageBody=None, DelaySeconds=None, MessageAttributes=None, MessageDeduplicationId=None, MessageGroupId=None): """ Delivers a message to the specified queue. See also: AWS API Documentation :example: response = client.send_message( QueueUrl='string', MessageBody='string', DelaySeconds=123, MessageAttributes={ 'string': { 'StringValue': 'string', 'BinaryValue': b'bytes', 'StringListValues': [ 'string', ], 'BinaryListValues': [ b'bytes', ], 'DataType': 'string' } }, MessageDeduplicationId='string', MessageGroupId='string' ) :type QueueUrl: string :param QueueUrl: [REQUIRED] The URL of the Amazon SQS queue to which a message is sent. Queue URLs are case-sensitive. :type MessageBody: string :param MessageBody: [REQUIRED] The message to send. The maximum string size is 256 KB. Warning A message can include only XML, JSON, and unformatted text. The following Unicode characters are allowed: #x9 | #xA | #xD | #x20 to #xD7FF | #xE000 to #xFFFD | #x10000 to #x10FFFF Any characters not included in this list will be rejected. For more information, see the W3C specification for characters . :type DelaySeconds: integer :param DelaySeconds: The length of time, in seconds, for which to delay a specific message. Valid values: 0 to 900. Maximum: 15 minutes. Messages with a positive DelaySeconds value become available for processing after the delay period is finished. If you don't specify a value, the default value for the queue applies. Note When you set FifoQueue , you can't set DelaySeconds per message. You can set this parameter only on a queue level. :type MessageAttributes: dict :param MessageAttributes: Each message attribute consists of a Name , Type , and Value . For more information, see Message Attribute Items and Validation in the Amazon SQS Developer Guide . (string) -- (dict) --The user-specified message attribute value. For string data types, the Value attribute has the same restrictions on the content as the message body. For more information, see `` SendMessage .`` Name , type , value and the message body must not be empty or null. All parts of the message attribute, including Name , Type , and Value , are part of the message size restriction (256 KB or 262,144 bytes). StringValue (string) --Strings are Unicode with UTF-8 binary encoding. For a list of code values, see ASCII Printable Characters . BinaryValue (bytes) --Binary type attributes can store any binary data, such as compressed data, encrypted data, or images. StringListValues (list) --Not implemented. Reserved for future use. (string) -- BinaryListValues (list) --Not implemented. Reserved for future use. (bytes) -- DataType (string) -- [REQUIRED]Amazon SQS supports the following logical data types: String , Number , and Binary . For the Number data type, you must use StringValue . You can also append custom labels. For more information, see Message Attribute Data Types and Validation in the Amazon SQS Developer Guide . :type MessageDeduplicationId: string :param MessageDeduplicationId: This parameter applies only to FIFO (first-in-first-out) queues. The token used for deduplication of sent messages. If a message with a particular MessageDeduplicationId is sent successfully, any messages sent with the same MessageDeduplicationId are accepted successfully but aren't delivered during the 5-minute deduplication interval. For more information, see Exactly-Once Processing in the Amazon SQS Developer Guide . Every message must have a unique MessageDeduplicationId , You may provide a MessageDeduplicationId explicitly. If you aren't able to provide a MessageDeduplicationId and you enable ContentBasedDeduplication for your queue, Amazon SQS uses a SHA-256 hash to generate the MessageDeduplicationId using the body of the message (but not the attributes of the message). If you don't provide a MessageDeduplicationId and the queue doesn't have ContentBasedDeduplication set, the action fails with an error. If the queue has ContentBasedDeduplication set, your MessageDeduplicationId overrides the generated one. When ContentBasedDeduplication is in effect, messages with identical content sent within the deduplication interval are treated as duplicates and only one copy of the message is delivered. If you send one message with ContentBasedDeduplication enabled and then another message with a MessageDeduplicationId that is the same as the one generated for the first MessageDeduplicationId , the two messages are treated as duplicates and only one copy of the message is delivered. Note The MessageDeduplicationId is available to the recipient of the message (this can be useful for troubleshooting delivery issues). If a message is sent successfully but the acknowledgement is lost and the message is resent with the same MessageDeduplicationId after the deduplication interval, Amazon SQS can't detect duplicate messages. The length of MessageDeduplicationId is 128 characters. MessageDeduplicationId can contain alphanumeric characters (a-z , A-Z , 0-9 ) and punctuation (!'#$%'()*+,-./:;=?@[\]^_`{|}~ ). For best practices of using MessageDeduplicationId , see Using the MessageDeduplicationId Property in the Amazon Simple Queue Service Developer Guide . :type MessageGroupId: string :param MessageGroupId: This parameter applies only to FIFO (first-in-first-out) queues. The tag that specifies that a message belongs to a specific message group. Messages that belong to the same message group are processed in a FIFO manner (however, messages in different message groups might be processed out of order). To interleave multiple ordered streams within a single queue, use MessageGroupId values (for example, session data for multiple users). In this scenario, multiple readers can process the queue, but the session data of each user is processed in a FIFO fashion. You must associate a non-empty MessageGroupId with a message. If you don't provide a MessageGroupId , the action fails. ReceiveMessage might return messages with multiple MessageGroupId values. For each MessageGroupId , the messages are sorted by time sent. The caller can't specify a MessageGroupId . The length of MessageGroupId is 128 characters. Valid values are alphanumeric characters and punctuation (!'#$%'()*+,-./:;=?@[\]^_`{|}~) . For best practices of using MessageGroupId , see Using the MessageGroupId Property in the Amazon Simple Queue Service Developer Guide . Warning MessageGroupId is required for FIFO queues. You can't use it for Standard queues. :rtype: dict :return: { 'MD5OfMessageBody': 'string', 'MD5OfMessageAttributes': 'string', 'MessageId': 'string', 'SequenceNumber': 'string' } """ pass def send_message_batch(QueueUrl=None, Entries=None): """ Delivers up to ten messages to the specified queue. This is a batch version of `` SendMessage .`` For a FIFO queue, multiple messages within a single batch are enqueued in the order they are sent. The result of sending each message is reported individually in the response. Because the batch request can result in a combination of successful and unsuccessful actions, you should check for batch errors even when the call returns an HTTP status code of 200 . The maximum allowed individual message size and the maximum total payload size (the sum of the individual lengths of all of the batched messages) are both 256 KB (262,144 bytes). If you don't specify the DelaySeconds parameter for an entry, Amazon SQS uses the default value for the queue. See also: AWS API Documentation :example: response = client.send_message_batch( QueueUrl='string', Entries=[ { 'Id': 'string', 'MessageBody': 'string', 'DelaySeconds': 123, 'MessageAttributes': { 'string': { 'StringValue': 'string', 'BinaryValue': b'bytes', 'StringListValues': [ 'string', ], 'BinaryListValues': [ b'bytes', ], 'DataType': 'string' } }, 'MessageDeduplicationId': 'string', 'MessageGroupId': 'string' }, ] ) :type QueueUrl: string :param QueueUrl: [REQUIRED] The URL of the Amazon SQS queue to which batched messages are sent. Queue URLs are case-sensitive. :type Entries: list :param Entries: [REQUIRED] A list of `` SendMessageBatchRequestEntry `` items. (dict) --Contains the details of a single Amazon SQS message along with an Id . Id (string) -- [REQUIRED]An identifier for a message in this batch used to communicate the result. Note The Id s of a batch request need to be unique within a request MessageBody (string) -- [REQUIRED]The body of the message. DelaySeconds (integer) --The length of time, in seconds, for which a specific message is delayed. Valid values: 0 to 900. Maximum: 15 minutes. Messages with a positive DelaySeconds value become available for processing after the delay period is finished. If you don't specify a value, the default value for the queue is applied. Note When you set FifoQueue , you can't set DelaySeconds per message. You can set this parameter only on a queue level. MessageAttributes (dict) --Each message attribute consists of a Name , Type , and Value . For more information, see Message Attribute Items and Validation in the Amazon SQS Developer Guide . (string) -- (dict) --The user-specified message attribute value. For string data types, the Value attribute has the same restrictions on the content as the message body. For more information, see `` SendMessage .`` Name , type , value and the message body must not be empty or null. All parts of the message attribute, including Name , Type , and Value , are part of the message size restriction (256 KB or 262,144 bytes). StringValue (string) --Strings are Unicode with UTF-8 binary encoding. For a list of code values, see ASCII Printable Characters . BinaryValue (bytes) --Binary type attributes can store any binary data, such as compressed data, encrypted data, or images. StringListValues (list) --Not implemented. Reserved for future use. (string) -- BinaryListValues (list) --Not implemented. Reserved for future use. (bytes) -- DataType (string) -- [REQUIRED]Amazon SQS supports the following logical data types: String , Number , and Binary . For the Number data type, you must use StringValue . You can also append custom labels. For more information, see Message Attribute Data Types and Validation in the Amazon SQS Developer Guide . MessageDeduplicationId (string) --This parameter applies only to FIFO (first-in-first-out) queues. The token used for deduplication of messages within a 5-minute minimum deduplication interval. If a message with a particular MessageDeduplicationId is sent successfully, subsequent messages with the same MessageDeduplicationId are accepted successfully but aren't delivered. For more information, see Exactly-Once Processing in the Amazon SQS Developer Guide . Every message must have a unique MessageDeduplicationId , You may provide a MessageDeduplicationId explicitly. If you aren't able to provide a MessageDeduplicationId and you enable ContentBasedDeduplication for your queue, Amazon SQS uses a SHA-256 hash to generate the MessageDeduplicationId using the body of the message (but not the attributes of the message). If you don't provide a MessageDeduplicationId and the queue doesn't have ContentBasedDeduplication set, the action fails with an error. If the queue has ContentBasedDeduplication set, your MessageDeduplicationId overrides the generated one. When ContentBasedDeduplication is in effect, messages with identical content sent within the deduplication interval are treated as duplicates and only one copy of the message is delivered. If you send one message with ContentBasedDeduplication enabled and then another message with a MessageDeduplicationId that is the same as the one generated for the first MessageDeduplicationId , the two messages are treated as duplicates and only one copy of the message is delivered. Note The MessageDeduplicationId is available to the recipient of the message (this can be useful for troubleshooting delivery issues). If a message is sent successfully but the acknowledgement is lost and the message is resent with the same MessageDeduplicationId after the deduplication interval, Amazon SQS can't detect duplicate messages. The length of MessageDeduplicationId is 128 characters. MessageDeduplicationId can contain alphanumeric characters (a-z , A-Z , 0-9 ) and punctuation (!'#$%'()*+,-./:;=?@[\]^_`{|}~ ). For best practices of using MessageDeduplicationId , see Using the MessageDeduplicationId Property in the Amazon Simple Queue Service Developer Guide . MessageGroupId (string) --This parameter applies only to FIFO (first-in-first-out) queues. The tag that specifies that a message belongs to a specific message group. Messages that belong to the same message group are processed in a FIFO manner (however, messages in different message groups might be processed out of order). To interleave multiple ordered streams within a single queue, use MessageGroupId values (for example, session data for multiple users). In this scenario, multiple readers can process the queue, but the session data of each user is processed in a FIFO fashion. You must associate a non-empty MessageGroupId with a message. If you don't provide a MessageGroupId , the action fails. ReceiveMessage might return messages with multiple MessageGroupId values. For each MessageGroupId , the messages are sorted by time sent. The caller can't specify a MessageGroupId . The length of MessageGroupId is 128 characters. Valid values are alphanumeric characters and punctuation (!'#$%'()*+,-./:;=?@[\]^_`{|}~) . For best practices of using MessageGroupId , see Using the MessageGroupId Property in the Amazon Simple Queue Service Developer Guide . Warning MessageGroupId is required for FIFO queues. You can't use it for Standard queues. :rtype: dict :return: { 'Successful': [ { 'Id': 'string', 'MessageId': 'string', 'MD5OfMessageBody': 'string', 'MD5OfMessageAttributes': 'string', 'SequenceNumber': 'string' }, ], 'Failed': [ { 'Id': 'string', 'SenderFault': True|False, 'Code': 'string', 'Message': 'string' }, ] } """ pass def set_queue_attributes(QueueUrl=None, Attributes=None): """ Sets the value of one or more queue attributes. When you change a queue's attributes, the change can take up to 60 seconds for most of the attributes to propagate throughout the Amazon SQS system. Changes made to the MessageRetentionPeriod attribute can take up to 15 minutes. See also: AWS API Documentation :example: response = client.set_queue_attributes( QueueUrl='string', Attributes={ 'string': 'string' } ) :type QueueUrl: string :param QueueUrl: [REQUIRED] The URL of the Amazon SQS queue whose attributes are set. Queue URLs are case-sensitive. :type Attributes: dict :param Attributes: [REQUIRED] A map of attributes to set. The following lists the names, descriptions, and values of the special request parameters that the SetQueueAttributes action uses: DelaySeconds - The length of time, in seconds, for which the delivery of all messages in the queue is delayed. Valid values: An integer from 0 to 900 (15 minutes). The default is 0 (zero). MaximumMessageSize - The limit of how many bytes a message can contain before Amazon SQS rejects it. Valid values: An integer from 1,024 bytes (1 KiB) up to 262,144 bytes (256 KiB). The default is 262,144 (256 KiB). MessageRetentionPeriod - The length of time, in seconds, for which Amazon SQS retains a message. Valid values: An integer representing seconds, from 60 (1 minute) to 1,209,600 (14 days). The default is 345,600 (4 days). Policy - The queue's policy. A valid AWS policy. For more information about policy structure, see Overview of AWS IAM Policies in the Amazon IAM User Guide . ReceiveMessageWaitTimeSeconds - The length of time, in seconds, for which a `` ReceiveMessage `` action waits for a message to arrive. Valid values: an integer from 0 to 20 (seconds). The default is 0. RedrivePolicy - The parameters for the dead letter queue functionality of the source queue. For more information about the redrive policy and dead letter queues, see Using Amazon SQS Dead Letter Queues in the Amazon SQS Developer Guide . Note The dead letter queue of a FIFO queue must also be a FIFO queue. Similarly, the dead letter queue of a standard queue must also be a standard queue. VisibilityTimeout - The visibility timeout for the queue. Valid values: an integer from 0 to 43,200 (12 hours). The default is 30. For more information about the visibility timeout, see Visibility Timeout in the Amazon SQS Developer Guide . The following attributes apply only to server-side-encryption : KmsMasterKeyId - The ID of an AWS-managed customer master key (CMK) for Amazon SQS or a custom CMK. For more information, see Key Terms . While the alias of the AWS-managed CMK for Amazon SQS is always alias/aws/sqs , the alias of a custom CMK can, for example, be alias/aws/sqs . For more examples, see KeyId in the AWS Key Management Service API Reference . KmsDataKeyReusePeriodSeconds - The length of time, in seconds, for which Amazon SQS can reuse a data key to encrypt or decrypt messages before calling AWS KMS again. An integer representing seconds, between 60 seconds (1 minute) and 86,400 seconds (24 hours). The default is 300 (5 minutes). A shorter time period provides better security but results in more calls to KMS which incur charges after Free Tier. For more information, see How Does the Data Key Reuse Period Work? . The following attribute applies only to FIFO (first-in-first-out) queues : ContentBasedDeduplication - Enables content-based deduplication. For more information, see Exactly-Once Processing in the Amazon SQS Developer Guide . Every message must have a unique MessageDeduplicationId , You may provide a MessageDeduplicationId explicitly. If you aren't able to provide a MessageDeduplicationId and you enable ContentBasedDeduplication for your queue, Amazon SQS uses a SHA-256 hash to generate the MessageDeduplicationId using the body of the message (but not the attributes of the message). If you don't provide a MessageDeduplicationId and the queue doesn't have ContentBasedDeduplication set, the action fails with an error. If the queue has ContentBasedDeduplication set, your MessageDeduplicationId overrides the generated one. When ContentBasedDeduplication is in effect, messages with identical content sent within the deduplication interval are treated as duplicates and only one copy of the message is delivered. If you send one message with ContentBasedDeduplication enabled and then another message with a MessageDeduplicationId that is the same as the one generated for the first MessageDeduplicationId , the two messages are treated as duplicates and only one copy of the message is delivered. Any other valid special request parameters (such as the following) are ignored: ApproximateNumberOfMessages ApproximateNumberOfMessagesDelayed ApproximateNumberOfMessagesNotVisible CreatedTimestamp LastModifiedTimestamp QueueArn (string) -- (string) -- """ pass
entrada = input() def fibonacci(n): fib = [0, 1, 1] if n > 0 and n <= 2: return fib[1] elif n == 0: return fib[0] else: for x in range(3, n+1): fib.append(0) fib[x] = fib[x-1] + fib[x-2] return fib[n] numeros = entrada.split(' ') numeros = list(map(int, numeros)) print(str(fibonacci(numeros[0])) + " " + str(fibonacci(numeros[1])) + " " + str(fibonacci(numeros[2])) + " " + str(fibonacci(numeros[3])))
#! /usr/bin/env python3 ################################################################################ # File Name : l6e4.py # Created By : Félix Chiasson (7138723) # Creation Date : [2015-10-20 11:40] # Last Modified : [2015-10-20 13:46] # Description : Count with the count method ################################################################################ def compte(word, string): compteur = 0 index = 0 while index < (len(word)-len(string)+1): if string in word[index:index+len(string)]: compteur += 1 index = index + 1 return compteur def compteB(c, s): return c.count(s) word = input("Veuillez entrer le mot: ") print(compte(word,'a')) print(compte(word,'de la')) print("Avec count()") print(compteB(word,'a')) print(compteB(word,'de la'))
class AXFundAddress(object): def __init__(self, address, alias): self.address = address self.alias = alias
class Usuario(object): def __init__(self, email='', senha=''): self.email = email self.senha = senha def __str__(self): return f'{self.email}' class Equipe(object): def __init__(self, nome='', sigla='', local=''): self.nome = nome self.sigla = sigla self.local = local def __str__(self): return f'{self.nome} ({self.sigla})' class Partida(object): def __init__(self, equipe_casa, equipe_visita, pontos_casa, pontos_visita): self.equipe_casa = equipe_casa self.equipe_visita = equipe_visita self.pontos_casa = pontos_casa self.pontos_visita = pontos_visita def __str__(self): return f'{self.equipe_casa} ({self.pontos_casa}) - {self.equipe_visita} ({self.pontos_visita})' def vencedor(self): if self.pontos_casa > self.pontos_visita: return self.equipe_casa elif self.pontos_visita > self.pontos_casa: return self.equipe_visita return False def id(self): return (self.equipe_casa.sigla+self.equipe_visita.sigla) def trocar_equipe(self, sigla_anterior, equipe): if self.equipe_casa.sigla == sigla_anterior: self.equipe_casa = equipe elif self.equipe_visita.sigla == sigla_anterior: self.equipe_visita = equipe
''' | Write a program that should prompt the user to type some sentences. It should then print number of words, number of characters, number of digits and number of special characters in it. | |------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | We use the input() function to receive input from the user and print() function to print it | ''' string = input("Enter a sentence...\n") numbers = '1234567890' chars = '!@#$%^&*()<>?:-\"\'}+=_{|\][;//.,`~' num_words = len(string.split()) res = [0,0,0] for i in string: if i.isalpha(): res[0] += 1 elif i in numbers: res[1] += 1 elif i in chars: res[2] += 1 else: pass print(f'There are {num_words} word(s), {res[0]} alphabets, {res[1]} digits and {res[2]} special characters in the given string.')
def problem1_1(): print("Problem Set 1") pass # replace this pass (a do-nothing) statement with your code
"""Calculation Class""" class Calculation: """ calculation abstract base class""" # pylint: disable=too-few-public-methods def __init__(self,values: tuple): """ constructor method""" self.values = Calculation.convert_args_to_tuple_of_float(values) @classmethod def create(cls,values: tuple): """ factory method""" return cls(values) @staticmethod def convert_args_to_tuple_of_float(values: tuple): """ standardize values to list of floats""" #lists can be modified and tuple cannot, tuple are faster. #We need to convert the tuple of potentially random data types (its raw data) #into a standard data format to keep things consistent so we convert it to float #then i make it a tuple again because i actually won't need to change the calculation values #I can also use it as a list and then i would be able to edit the calculation list_values_float = [] for item in values: list_values_float.append(float(item)) return tuple(list_values_float)
# # PySNMP MIB module CTRON-SSR-CONFIG-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CTRON-SSR-CONFIG-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 18:15:46 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") ConstraintsUnion, ValueSizeConstraint, ConstraintsIntersection, SingleValueConstraint, ValueRangeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsUnion", "ValueSizeConstraint", "ConstraintsIntersection", "SingleValueConstraint", "ValueRangeConstraint") ssrMibs, = mibBuilder.importSymbols("CTRON-SSR-SMI-MIB", "ssrMibs") ModuleCompliance, ObjectGroup, NotificationGroup = mibBuilder.importSymbols("SNMPv2-CONF", "ModuleCompliance", "ObjectGroup", "NotificationGroup") MibScalar, MibTable, MibTableRow, MibTableColumn, ObjectIdentity, Counter32, MibIdentifier, IpAddress, Gauge32, Counter64, ModuleIdentity, iso, Bits, NotificationType, TimeTicks, Unsigned32, Integer32 = mibBuilder.importSymbols("SNMPv2-SMI", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "ObjectIdentity", "Counter32", "MibIdentifier", "IpAddress", "Gauge32", "Counter64", "ModuleIdentity", "iso", "Bits", "NotificationType", "TimeTicks", "Unsigned32", "Integer32") TextualConvention, TruthValue, DisplayString = mibBuilder.importSymbols("SNMPv2-TC", "TextualConvention", "TruthValue", "DisplayString") ssrConfigMIB = ModuleIdentity((1, 3, 6, 1, 4, 1, 52, 2501, 1, 230)) ssrConfigMIB.setRevisions(('2000-07-15 00:00', '2000-02-20 00:00', '1998-08-17 00:00',)) if mibBuilder.loadTexts: ssrConfigMIB.setLastUpdated('200007150000Z') if mibBuilder.loadTexts: ssrConfigMIB.setOrganization('Cabletron Systems, Inc') class SSRErrorCode(TextualConvention, Integer32): status = 'current' subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6, 7, 8)) namedValues = NamedValues(("noStatus", 1), ("timeout", 2), ("networkError", 3), ("noSpace", 4), ("invalidConfig", 5), ("commandCompleted", 6), ("internalError", 7), ("tftpServerError", 8)) cfgGroup = MibIdentifier((1, 3, 6, 1, 4, 1, 52, 2501, 1, 231)) cfgTransferOp = MibScalar((1, 3, 6, 1, 4, 1, 52, 2501, 1, 231, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("noop", 1), ("sendConfigToAgent", 2), ("receiveConfigFromAgent", 3), ("receiveBootlogFromAgent", 4)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: cfgTransferOp.setStatus('current') cfgManagerAddress = MibScalar((1, 3, 6, 1, 4, 1, 52, 2501, 1, 231, 2), IpAddress()).setMaxAccess("readwrite") if mibBuilder.loadTexts: cfgManagerAddress.setStatus('current') cfgFileName = MibScalar((1, 3, 6, 1, 4, 1, 52, 2501, 1, 231, 3), DisplayString()).setMaxAccess("readwrite") if mibBuilder.loadTexts: cfgFileName.setStatus('current') cfgActivateTransfer = MibScalar((1, 3, 6, 1, 4, 1, 52, 2501, 1, 231, 4), TruthValue()).setMaxAccess("readwrite") if mibBuilder.loadTexts: cfgActivateTransfer.setStatus('current') cfgTransferStatus = MibScalar((1, 3, 6, 1, 4, 1, 52, 2501, 1, 231, 5), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5))).clone(namedValues=NamedValues(("idle", 1), ("sending", 2), ("receiving", 3), ("transferComplete", 4), ("error", 5)))).setMaxAccess("readonly") if mibBuilder.loadTexts: cfgTransferStatus.setStatus('current') cfgActivateFile = MibScalar((1, 3, 6, 1, 4, 1, 52, 2501, 1, 231, 6), TruthValue()).setMaxAccess("readwrite") if mibBuilder.loadTexts: cfgActivateFile.setStatus('current') cfgLastError = MibScalar((1, 3, 6, 1, 4, 1, 52, 2501, 1, 231, 7), SSRErrorCode()).setMaxAccess("readonly") if mibBuilder.loadTexts: cfgLastError.setStatus('current') cfgLastErrorReason = MibScalar((1, 3, 6, 1, 4, 1, 52, 2501, 1, 231, 8), DisplayString()).setMaxAccess("readonly") if mibBuilder.loadTexts: cfgLastErrorReason.setStatus('current') cfgActiveImageVersion = MibScalar((1, 3, 6, 1, 4, 1, 52, 2501, 1, 231, 9), DisplayString()).setMaxAccess("readonly") if mibBuilder.loadTexts: cfgActiveImageVersion.setStatus('current') cfgActiveImageBootLocation = MibScalar((1, 3, 6, 1, 4, 1, 52, 2501, 1, 231, 10), DisplayString()).setMaxAccess("readonly") if mibBuilder.loadTexts: cfgActiveImageBootLocation.setStatus('current') configConformance = MibIdentifier((1, 3, 6, 1, 4, 1, 52, 2501, 1, 230, 3)) configCompliances = MibIdentifier((1, 3, 6, 1, 4, 1, 52, 2501, 1, 230, 3, 1)) configGroups = MibIdentifier((1, 3, 6, 1, 4, 1, 52, 2501, 1, 230, 3, 2)) configCompliance = ModuleCompliance((1, 3, 6, 1, 4, 1, 52, 2501, 1, 230, 3, 1, 1)).setObjects(("CTRON-SSR-CONFIG-MIB", "configGroup10")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): configCompliance = configCompliance.setStatus('obsolete') configCompliance2 = ModuleCompliance((1, 3, 6, 1, 4, 1, 52, 2501, 1, 230, 3, 1, 2)).setObjects(("CTRON-SSR-CONFIG-MIB", "configGroup20")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): configCompliance2 = configCompliance2.setStatus('current') configGroup10 = ObjectGroup((1, 3, 6, 1, 4, 1, 52, 2501, 1, 230, 3, 2, 1)).setObjects(("CTRON-SSR-CONFIG-MIB", "cfgTransferOp"), ("CTRON-SSR-CONFIG-MIB", "cfgManagerAddress"), ("CTRON-SSR-CONFIG-MIB", "cfgFileName"), ("CTRON-SSR-CONFIG-MIB", "cfgActivateTransfer"), ("CTRON-SSR-CONFIG-MIB", "cfgTransferStatus"), ("CTRON-SSR-CONFIG-MIB", "cfgActivateFile"), ("CTRON-SSR-CONFIG-MIB", "cfgLastError"), ("CTRON-SSR-CONFIG-MIB", "cfgLastErrorReason")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): configGroup10 = configGroup10.setStatus('deprecated') configGroup20 = ObjectGroup((1, 3, 6, 1, 4, 1, 52, 2501, 1, 230, 3, 2, 2)).setObjects(("CTRON-SSR-CONFIG-MIB", "cfgTransferOp"), ("CTRON-SSR-CONFIG-MIB", "cfgManagerAddress"), ("CTRON-SSR-CONFIG-MIB", "cfgFileName"), ("CTRON-SSR-CONFIG-MIB", "cfgActivateTransfer"), ("CTRON-SSR-CONFIG-MIB", "cfgTransferStatus"), ("CTRON-SSR-CONFIG-MIB", "cfgActivateFile"), ("CTRON-SSR-CONFIG-MIB", "cfgLastError"), ("CTRON-SSR-CONFIG-MIB", "cfgLastErrorReason"), ("CTRON-SSR-CONFIG-MIB", "cfgActiveImageVersion"), ("CTRON-SSR-CONFIG-MIB", "cfgActiveImageBootLocation")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): configGroup20 = configGroup20.setStatus('current') mibBuilder.exportSymbols("CTRON-SSR-CONFIG-MIB", cfgManagerAddress=cfgManagerAddress, cfgActiveImageVersion=cfgActiveImageVersion, cfgActivateFile=cfgActivateFile, configGroups=configGroups, cfgLastErrorReason=cfgLastErrorReason, ssrConfigMIB=ssrConfigMIB, SSRErrorCode=SSRErrorCode, configCompliance=configCompliance, configGroup20=configGroup20, cfgGroup=cfgGroup, cfgActiveImageBootLocation=cfgActiveImageBootLocation, configConformance=configConformance, configCompliance2=configCompliance2, cfgFileName=cfgFileName, cfgLastError=cfgLastError, configGroup10=configGroup10, cfgTransferOp=cfgTransferOp, PYSNMP_MODULE_ID=ssrConfigMIB, cfgActivateTransfer=cfgActivateTransfer, cfgTransferStatus=cfgTransferStatus, configCompliances=configCompliances)
seats = [] with open("input.txt") as f: for line in f: line = line.replace("\n", "") seat = {} seat["raw"] = line seat["row"] = int(seat["raw"][:7].replace("F", "0").replace("B", "1"), 2) seat["column"] = int(seat["raw"][-3:].replace("L", "0").replace("R", "1"), 2) seat["id"] = seat["row"] * 8 + seat["column"] seats.append(seat) seats = sorted(seats, key=lambda k: k["id"], reverse=True) for i, seat in enumerate(seats): if seat["id"]-1 != seats[i+1]["id"]: print(seat["id"]-1) break
#!/usr/bin/env python3 # Copyright © 2012-13 Qtrac Ltd. All rights reserved. # This program or module is free software: you can redistribute it # and/or modify it under the terms of the GNU General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. It is provided for # educational purposes and is distributed in the hope that it will be # useful, but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. ABOUT = "About" APPNAME = "ImageScale" GENERAL = "General" PAD = "0.75m" POSITION = "position" RESTORE = "Restore" SOURCE, TARGET = ("SOURCE", "TARGET") VERSION = "1.0.0" WORKING, CANCELED, TERMINATING, IDLE = ("WORKING", "CANCELED", "TERMINATING", "IDLE") class Canceled(Exception): pass
class MLModelInterface: def fit(self, features, labels): raise NotImplementedError def predict(self, data): raise NotImplementedError class KNeighborsClassifier(MLModelInterface): def fit(self, features, labels): pass def predict(self, data): pass class LinearRegression(MLModelInterface): def fit(self, features, labels): pass def predict(self, data): pass class LogisticsRegression(MLModelInterface): pass # Imput to the classifier features = [ (5.1, 3.5, 1.4, 0.2), (4.9, 3.0, 1.4, 0.2), (4.7, 3.2, 1.3, 0.2), (7.0, 3.2, 4.7, 1.4), (6.4, 3.2, 4.5, 1.5), (6.9, 3.1, 4.9, 1.5), (6.3, 3.3, 6.0, 2.5), (5.8, 2.7, 5.1, 1.9), (7.1, 3.0, 5.9, 2.1), ] # 0: I. setosa # 1: I. versicolor # 2: I. virginica labels = [0, 0, 0, 1, 1, 1, 2, 2, 2] to_predict = [ (5.7, 2.8, 4.1, 1.3), (4.9, 2.5, 4.5, 1.7), (4.6, 3.4, 1.4, 0.3), ] model = LinearRegression() model.fit(features, labels) model.predict(to_predict) # [1, 2, 0]
{ "targets": [ { "target_name": "gpio", "sources": ["gpio.cc", "tizen-gpio.cc"] } ] }
songs = { ('Nickelback', 'How You Remind Me'), ('Will.i.am', 'That Power'), ('Miles Davis', 'Stella by Starlight'), ('Nickelback', 'Animals') } # Using a set comprehension, create a new set that contains all songs that were not performed by Nickelback. nonNickelback = {}
def assign_variable(robot_instance, variable_name, args): """Assign a robotframework variable.""" variable_value = robot_instance.run_keyword(*args) robot_instance._variables.__setitem__(variable_name, variable_value) return variable_value
file1 = open("./logs/pythonlog.txt", 'r+') avg1 = 0.0 lines1 = 0.0 for line in file1: lines1 = lines1 + 1.0 avg1 = (avg1 + float(line)) avg1 = avg1/lines1 print(avg1, "for Python with", lines1, "lines") file2 = open("./logs/clog.txt", 'r+') avg2 = 0.0 lines2 = 0.0 for line in file2: lines2 = lines2 + 1.0 avg2 = (avg2 + float(line)) avg2 = avg2/lines2 print(avg2, "for C with", lines2, "lines") file3 = open("./logs/cpplog.txt", 'r+') avg3 = 0.0 lines3 = 0.0 for line in file3: lines3 = lines3 + 1.0 avg3 = (avg3 + float(line)) avg3 = avg3/lines3 print(avg3, "for C++ with", lines3, "lines") file4 = open("./logs/javalog.txt", 'r+') avg4 = 0.0 lines4 = 0.0 for line in file4: lines4 = lines4 + 1.0 avg4 = (avg4 + float(line)) avg4 = avg4/lines4 print(avg4, "for Java with", lines4, "lines") word = "" while(word.lower() != "y" and word.lower() != "n"): word = input("Do you want to wipe the previous log? [Y/N]") if(word.lower() == "y"): file1.truncate(0) file3.truncate(0) file2.truncate(0) file4.truncate(0) print("Done.") file4.close() file3.close() file2.close() file1.close()
# Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: def detectCycle(self, head: ListNode) -> ListNode: if head is None: return None # 1 - check cycle p1 = head p2 = head.next has_cycle = False while p2 is not None and p2.next is not None: if p1 == p2: has_cycle = True break p1 = p1.next p2 = p2.next.next if not has_cycle: return None # 2 - cycle length cycle_length = 1 p2 = p1.next while p1 != p2: p2 = p2.next cycle_length += 1 # 3 - problem 19, the nth node from the end # L = cycle + non # p1 moves cycle # p1 and p2 moves non, meeting at the start dummy = ListNode(None) dummy.next = head p1 = dummy for _ in range(cycle_length): p1 = p1.next p2 = dummy while p2 != p1: p1 = p1.next p2 = p2.next return p1 if __name__ == "__main__": head = ListNode(1) p = head node = ListNode(2) p.next = node p = p.next node = ListNode(3) p.next = node p = p.next node = ListNode(4) p.next = node p = p.next start = node node = ListNode(5) p.next = node p = p.next node = ListNode(6) p.next = node p = p.next node = ListNode(7) p.next = node p = p.next p.next = start sol = Solution() print(sol.detectCycle(head).val)
#!/usr/bin/python def add(a,b): return a+b def sub(a,b): return a-b def mul(a,b): return a*b def div(a,b): return a/b a = int(input("Enter first number: ")) b = int(input("Enter second number: ")) print("Please select operation : \n" \ "1. Addition \n" \ "2. Subtraction \n" \ "3. Multiplication \n" \ "4. Division \n") select = int(input("Select operations form 1, 2, 3, 4 :")) if select == 1: print(a, "+", b, "=", add(a,b)) elif select == 2: print(a, "-", b, "=", sub(a,b)) elif select == 3: print(a, "*", b, "=", mul(a,b)) elif select == 4: if b == 0: exit elif b != 0: print(a, "/", b, "=", div(a,b)) else: print("Invalid input")
# The classroom scheduling problem # Suppose you have a classroom and you want to hold as many classes as possible # __________________________ #| class | start | end | #|_______|_________|________| #| Art | 9:00 am | 10:30am| #|_______|_________|________| #| Eng | 9:30am | 10:30am| #|_______|_________|________| #| Math | 10 am | 11 am | #|_______|_________|________| #| CS | 10:30am | 11.30am| #|_______|_________|________| #| Music | 11 am | 12 pm | #|_______|_________|________| #| def schedule(classes): possible_classes = [] possible_classes.append(classes[0]) print(possible_classes) # return for i in range(2,len(classes)): if possible_classes[-1][1]<=classes[i][0]: possible_classes.append(classes[i]) return possible_classes
class restaurantvalidator(): def valideaza(self, restaurant): erori = [] if len(restaurant.nume) == 0: erori.append('numele nu trb sa fie null') if erori: raise ValueError(erori)
OVERALL_CATEGORY_ID = '0x02E00000FFFFFFFF' HERO_CATEGORY_IDS = { 'reaper': '0x02E0000000000002', 'tracer': '0x02E0000000000003', 'mercy': '0x02E0000000000004', 'hanzo': '0x02E0000000000005', 'torbjorn': '0x02E0000000000006', 'reinhardt': '0x02E0000000000007', 'pharah': '0x02E0000000000008', 'winston': '0x02E0000000000009', 'widowmaker': '0x02E000000000000A', 'bastion': '0x02E0000000000015', 'symmetra': '0x02E0000000000016', 'zenyatta': '0x02E0000000000020', 'genji': '0x02E0000000000029', 'roadhog': '0x02E0000000000040', 'mccree': '0x02E0000000000042', 'junkrat': '0x02E0000000000065', 'zarya': '0x02E0000000000068', 'soldier76': '0x02E000000000006E', 'lucio': '0x02E0000000000079', 'dva': '0x02E000000000007A', 'mei': '0x02E00000000000DD', 'sombra': '0x02E000000000012E', 'ana': '0x02E000000000013B', 'orisa': '0x02E000000000013E', 'doomfist': '0x02E000000000012F', 'moira': '0x02E00000000001A2', 'brigitte': '0x02E0000000000195', 'wrecking_ball': '0x02E00000000001CA', } INVERTED_HERO_CATEGORY_IDS = {category_id: hero for hero, category_id in HERO_CATEGORY_IDS.items()} # Taken from https://github.com/SunDwarf/OWAPI/blob/master/owapi/prestige.py LEVEL_IDS = { # Bronze '0x0250000000000918': 0, '0x0250000000000919': 0, '0x025000000000091A': 0, '0x025000000000091B': 0, '0x025000000000091C': 0, '0x025000000000091D': 0, '0x025000000000091E': 0, '0x025000000000091F': 0, '0x0250000000000920': 0, '0x0250000000000921': 0, '0x0250000000000922': 100, '0x0250000000000924': 100, '0x0250000000000925': 100, '0x0250000000000926': 100, '0x025000000000094C': 100, '0x0250000000000927': 100, '0x0250000000000928': 100, '0x0250000000000929': 100, '0x025000000000092B': 100, '0x0250000000000950': 100, '0x025000000000092A': 200, '0x025000000000092C': 200, '0x0250000000000937': 200, '0x025000000000093B': 200, '0x0250000000000933': 200, '0x0250000000000923': 200, '0x0250000000000944': 200, '0x0250000000000948': 200, '0x025000000000093F': 200, '0x0250000000000951': 200, '0x025000000000092D': 300, '0x0250000000000930': 300, '0x0250000000000934': 300, '0x0250000000000938': 300, '0x0250000000000940': 300, '0x0250000000000949': 300, '0x0250000000000952': 300, '0x025000000000094D': 300, '0x0250000000000945': 300, '0x025000000000093C': 300, '0x025000000000092E': 400, '0x0250000000000931': 400, '0x0250000000000935': 400, '0x025000000000093D': 400, '0x0250000000000946': 400, '0x025000000000094A': 400, '0x0250000000000953': 400, '0x025000000000094E': 400, '0x0250000000000939': 400, '0x0250000000000941': 400, '0x025000000000092F': 500, '0x0250000000000932': 500, '0x025000000000093E': 500, '0x0250000000000936': 500, '0x025000000000093A': 500, '0x0250000000000942': 500, '0x0250000000000947': 500, '0x025000000000094F': 500, '0x025000000000094B': 500, '0x0250000000000954': 500, # Silver '0x0250000000000956': 600, '0x025000000000095C': 600, '0x025000000000095D': 600, '0x025000000000095E': 600, '0x025000000000095F': 600, '0x0250000000000960': 600, '0x0250000000000961': 600, '0x0250000000000962': 600, '0x0250000000000963': 600, '0x0250000000000964': 600, '0x0250000000000957': 700, '0x0250000000000965': 700, '0x0250000000000966': 700, '0x0250000000000967': 700, '0x0250000000000968': 700, '0x0250000000000969': 700, '0x025000000000096A': 700, '0x025000000000096B': 700, '0x025000000000096C': 700, '0x025000000000096D': 700, '0x0250000000000958': 800, '0x025000000000096E': 800, '0x025000000000096F': 800, '0x0250000000000970': 800, '0x0250000000000971': 800, '0x0250000000000972': 800, '0x0250000000000973': 800, '0x0250000000000974': 800, '0x0250000000000975': 800, '0x0250000000000976': 800, '0x0250000000000959': 900, '0x0250000000000977': 900, '0x0250000000000978': 900, '0x0250000000000979': 900, '0x025000000000097A': 900, '0x025000000000097B': 900, '0x025000000000097C': 900, '0x025000000000097D': 900, '0x025000000000097E': 900, '0x025000000000097F': 900, '0x025000000000095A': 1000, '0x0250000000000980': 1000, '0x0250000000000981': 1000, '0x0250000000000982': 1000, '0x0250000000000983': 1000, '0x0250000000000984': 1000, '0x0250000000000985': 1000, '0x0250000000000986': 1000, '0x0250000000000987': 1000, '0x0250000000000988': 1000, '0x025000000000095B': 1100, '0x0250000000000989': 1100, '0x025000000000098A': 1100, '0x025000000000098B': 1100, '0x025000000000098C': 1100, '0x025000000000098D': 1100, '0x025000000000098E': 1100, '0x025000000000098F': 1100, '0x0250000000000991': 1100, '0x0250000000000990': 1100, # Gold '0x0250000000000992': 1200, '0x0250000000000993': 1200, '0x0250000000000994': 1200, '0x0250000000000995': 1200, '0x0250000000000996': 1200, '0x0250000000000997': 1200, '0x0250000000000998': 1200, '0x0250000000000999': 1200, '0x025000000000099A': 1200, '0x025000000000099B': 1200, '0x025000000000099C': 1300, '0x025000000000099D': 1300, '0x025000000000099E': 1300, '0x025000000000099F': 1300, '0x02500000000009A0': 1300, '0x02500000000009A1': 1300, '0x02500000000009A2': 1300, '0x02500000000009A3': 1300, '0x02500000000009A4': 1300, '0x02500000000009A5': 1300, '0x02500000000009A6': 1400, '0x02500000000009A7': 1400, '0x02500000000009A8': 1400, '0x02500000000009A9': 1400, '0x02500000000009AA': 1400, '0x02500000000009AB': 1400, '0x02500000000009AC': 1400, '0x02500000000009AD': 1400, '0x02500000000009AE': 1400, '0x02500000000009AF': 1400, '0x02500000000009B0': 1500, '0x02500000000009B1': 1500, '0x02500000000009B2': 1500, '0x02500000000009B3': 1500, '0x02500000000009B4': 1500, '0x02500000000009B5': 1500, '0x02500000000009B6': 1500, '0x02500000000009B7': 1500, '0x02500000000009B8': 1500, '0x02500000000009B9': 1500, '0x02500000000009BA': 1600, '0x02500000000009BB': 1600, '0x02500000000009BC': 1600, '0x02500000000009BD': 1600, '0x02500000000009BE': 1600, '0x02500000000009BF': 1600, '0x02500000000009C0': 1600, '0x02500000000009C1': 1600, '0x02500000000009C2': 1600, '0x02500000000009C3': 1600, '0x02500000000009C4': 1700, '0x02500000000009C5': 1700, '0x02500000000009C6': 1700, '0x02500000000009C7': 1700, '0x02500000000009C8': 1700, '0x02500000000009C9': 1700, '0x02500000000009CA': 1700, '0x02500000000009CB': 1700, '0x02500000000009CC': 1700, '0x02500000000009CD': 1700, }
class Section: def get_display_text(self): pass def get_children(self): pass
def solution(prices): if len(prices) == 0: return 0 # We are always paying the first price. total = prices[0] min_price = prices[0] for i in range(1, len(prices)): if prices[i] > min_price: total += prices[i] - min_price if prices[i] < min_price: min_price = prices[i] return total def num_divisors(number, keys): count = 0 for key in keys: if number % key == 0: count += 1 return count def encryptionValidity(instructionCount, validityPeriod, keys): max_num_divisors = float('-inf') for key in keys: num = num_divisors(key, keys) if num > max_num_divisors: max_num_divisors = num encryption_strength = max_num_divisors * pow(10, 5) is_crackable = 1 if encryption_strength / instructionCount > validityPeriod: is_crackable = 0 return is_crackable, encryption_strength # Write a function that accepts as an argument a string of addition/subtraction operations. # The function should return the result of the operations as an integer # ex: calculate("1 - 2 + 3") => 2 def apply_op(op, a, b): if op == 'plus': return a + b if op == 'minus': return a - b def calculate(expression): tokens = expression.split(" ") result = 0 last_op = 'plus' for token in tokens: if token == "": continue if str.isdigit(token): new_val = int(token) result = apply_op(last_op, result, new_val) if token == '+': last_op = 'plus' if token == '-': last_op = 'minus' return result # Next, write a function that accepts as an argument a string of addition/subtraction # operations and also includes parentheses to indicate order of operations. The function # should return the result of the operations as an integer # ex: calculate("1 - (2 + 3)") => -4 def parse_number(expression): if len(expression) == 0: return '', expression hd, tl = expression[0], expression[1:] if str.isdigit(hd) == False: return '', expression more, rest = parse_number(tl) return hd + more, rest def tokenize(expression): if len(expression) == 0: return [] hd, tl = expression[0], expression[1:] if hd == ' ': return tokenize(tl) if str.isdigit(hd): num, rest = parse_number(expression) return [int(num)] + tokenize(rest) if hd in ['(', ')', '+', '-']: return [hd] + tokenize(tl) def calculate_two_rec(tokens, result_so_far, last_op): if len(tokens) == 0: return result_so_far, [] token, rest = tokens[0], tokens[1:] if isinstance(token, int): return calculate_two_rec(rest, apply_op(last_op, result_so_far, token), last_op) if token == '+': return calculate_two_rec(rest, result_so_far, 'plus') if token == '-': return calculate_two_rec(rest, result_so_far, 'minus') if token == '(': value_in_paran, rest_after_paran = calculate_two_rec(rest, 0, 'plus') return calculate_two_rec(rest_after_paran, apply_op(last_op, result_so_far, value_in_paran), 'plus') if token == ')': return result_so_far, rest def calculate_two(expression): tokens = tokenize(expression) final_result, _ = calculate_two_rec(tokens, 0, 'plus') return final_result
# /////////////////////////////////////////////////////////////////////////// # # # # /////////////////////////////////////////////////////////////////////////// class GLLight: def __init__(self, pos=(0.0,0.0,0.0), color=(1.0,1.0,1.0)): self.pos = pos self.color = color self.ambient = (1.0, 1.0, 1.0) self.diffuse = (1.0, 1.0, 1.0) # attenuation self.constant = 1.0 self.linear = 0.09 self.quadratic = 0.032
def splitbylength(wordlist): initlen = len(wordlist[0]) lastlen = len(wordlist[-1]) splitlist = [] for i in range(initlen, lastlen+1): curlist = [] for x in wordlist: if len(x) == i: curlist.append(x.capitalize()) splitlist.append(sorted(curlist)) return splitlist
if __name__ == '__main__': checksum = 0 while True: try: numbers = input() except EOFError: break numbers = map(int, numbers.split('\t')) numbers = sorted(numbers) checksum += numbers[-1] - numbers[0] print(checksum)
# # PySNMP MIB module ITOUCH-RADIUS-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ITOUCH-RADIUS-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 19:47:05 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, OctetString, ObjectIdentifier = mibBuilder.importSymbols("ASN1", "Integer", "OctetString", "ObjectIdentifier") NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") ConstraintsUnion, ValueSizeConstraint, SingleValueConstraint, ConstraintsIntersection, ValueRangeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsUnion", "ValueSizeConstraint", "SingleValueConstraint", "ConstraintsIntersection", "ValueRangeConstraint") iTouch, = mibBuilder.importSymbols("ITOUCH-MIB", "iTouch") NotificationGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance") Counter64, Integer32, Gauge32, ModuleIdentity, Unsigned32, Counter32, TimeTicks, NotificationType, iso, ObjectIdentity, MibScalar, MibTable, MibTableRow, MibTableColumn, Bits, IpAddress, MibIdentifier = mibBuilder.importSymbols("SNMPv2-SMI", "Counter64", "Integer32", "Gauge32", "ModuleIdentity", "Unsigned32", "Counter32", "TimeTicks", "NotificationType", "iso", "ObjectIdentity", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Bits", "IpAddress", "MibIdentifier") DisplayString, TextualConvention = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TextualConvention") xRadius = MibIdentifier((1, 3, 6, 1, 4, 1, 33, 35)) xRadiusPort = MibIdentifier((1, 3, 6, 1, 4, 1, 33, 35, 1)) xRadiusCircuit = MibIdentifier((1, 3, 6, 1, 4, 1, 33, 35, 2)) xRadiusConfig = MibIdentifier((1, 3, 6, 1, 4, 1, 33, 35, 3)) xRadiusServers = MibIdentifier((1, 3, 6, 1, 4, 1, 33, 35, 4)) xRadiusCounters = MibIdentifier((1, 3, 6, 1, 4, 1, 33, 35, 5)) xRadiusPortTable = MibTable((1, 3, 6, 1, 4, 1, 33, 35, 1, 1), ) if mibBuilder.loadTexts: xRadiusPortTable.setStatus('mandatory') xRadiusPortEntry = MibTableRow((1, 3, 6, 1, 4, 1, 33, 35, 1, 1, 1), ).setIndexNames((0, "ITOUCH-RADIUS-MIB", "xRadiusPortIndex")) if mibBuilder.loadTexts: xRadiusPortEntry.setStatus('mandatory') xRadiusPortIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 33, 35, 1, 1, 1, 1), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: xRadiusPortIndex.setStatus('mandatory') xRadiusPortStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 33, 35, 1, 1, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("disabled", 1), ("enabled", 2))).clone('disabled')).setMaxAccess("readonly") if mibBuilder.loadTexts: xRadiusPortStatus.setStatus('mandatory') xRadiusPortSolicitStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 33, 35, 1, 1, 1, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("disabled", 1), ("enabled", 2))).clone('disabled')).setMaxAccess("readwrite") if mibBuilder.loadTexts: xRadiusPortSolicitStatus.setStatus('mandatory') xRadiusAcctPortStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 33, 35, 1, 1, 1, 4), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("disabled", 1), ("enabled", 2), ("limited", 3))).clone('disabled')).setMaxAccess("readonly") if mibBuilder.loadTexts: xRadiusAcctPortStatus.setStatus('mandatory') xRadiusCircuitTable = MibTable((1, 3, 6, 1, 4, 1, 33, 35, 2, 1), ) if mibBuilder.loadTexts: xRadiusCircuitTable.setStatus('mandatory') xRadiusCircuitEntry = MibTableRow((1, 3, 6, 1, 4, 1, 33, 35, 2, 1, 1), ).setIndexNames((0, "ITOUCH-RADIUS-MIB", "xRadiusCircuitIndex")) if mibBuilder.loadTexts: xRadiusCircuitEntry.setStatus('mandatory') xRadiusCircuitIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 33, 35, 2, 1, 1, 1), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: xRadiusCircuitIndex.setStatus('mandatory') xRadiusCircAcctOnOff = MibTableColumn((1, 3, 6, 1, 4, 1, 33, 35, 2, 1, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("disabled", 1), ("enabled", 2), ("limited", 3))).clone('disabled')).setMaxAccess("readonly") if mibBuilder.loadTexts: xRadiusCircAcctOnOff.setStatus('mandatory') xRadiusAuthServerPort = MibScalar((1, 3, 6, 1, 4, 1, 33, 35, 3, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 65535)).clone(1645)).setMaxAccess("readwrite") if mibBuilder.loadTexts: xRadiusAuthServerPort.setStatus('mandatory') xRadiusAcctServerPort = MibScalar((1, 3, 6, 1, 4, 1, 33, 35, 3, 2), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 65535)).clone(1646)).setMaxAccess("readwrite") if mibBuilder.loadTexts: xRadiusAcctServerPort.setStatus('mandatory') xRadiusTimeout = MibScalar((1, 3, 6, 1, 4, 1, 33, 35, 3, 3), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 255)).clone(5)).setMaxAccess("readwrite") if mibBuilder.loadTexts: xRadiusTimeout.setStatus('mandatory') xRadiusServerRetries = MibScalar((1, 3, 6, 1, 4, 1, 33, 35, 3, 4), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 10)).clone(3)).setMaxAccess("readwrite") if mibBuilder.loadTexts: xRadiusServerRetries.setStatus('mandatory') xRadiusAcctLogAttempts = MibScalar((1, 3, 6, 1, 4, 1, 33, 35, 3, 5), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 50000)).clone(5)).setMaxAccess("readwrite") if mibBuilder.loadTexts: xRadiusAcctLogAttempts.setStatus('mandatory') xRadiusChapChallengeSize = MibScalar((1, 3, 6, 1, 4, 1, 33, 35, 3, 6), Integer32().subtype(subtypeSpec=ValueRangeConstraint(4, 128)).clone(16)).setMaxAccess("readwrite") if mibBuilder.loadTexts: xRadiusChapChallengeSize.setStatus('mandatory') xRadiusLogging = MibScalar((1, 3, 6, 1, 4, 1, 33, 35, 3, 7), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("disabled", 1), ("enabled", 2))).clone('disabled')).setMaxAccess("readwrite") if mibBuilder.loadTexts: xRadiusLogging.setStatus('mandatory') xRadiusMessage = MibScalar((1, 3, 6, 1, 4, 1, 33, 35, 3, 8), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(40, 40)).setFixedLength(40)).setMaxAccess("readwrite") if mibBuilder.loadTexts: xRadiusMessage.setStatus('mandatory') xRadServer1SubGrp = MibIdentifier((1, 3, 6, 1, 4, 1, 33, 35, 4, 1)) xRadServer2SubGrp = MibIdentifier((1, 3, 6, 1, 4, 1, 33, 35, 4, 2)) xRadiusServerName1 = MibScalar((1, 3, 6, 1, 4, 1, 33, 35, 4, 1, 1), OctetString().subtype(subtypeSpec=ValueSizeConstraint(51, 51)).setFixedLength(51)).setMaxAccess("readwrite") if mibBuilder.loadTexts: xRadiusServerName1.setStatus('mandatory') xRadiusSecret1 = MibScalar((1, 3, 6, 1, 4, 1, 33, 35, 4, 1, 2), OctetString().subtype(subtypeSpec=ValueSizeConstraint(32, 32)).setFixedLength(32).clone('Default_Secret')).setMaxAccess("readonly") if mibBuilder.loadTexts: xRadiusSecret1.setStatus('obsolete') xRadiusServerAccess1 = MibScalar((1, 3, 6, 1, 4, 1, 33, 35, 4, 1, 3), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: xRadiusServerAccess1.setStatus('mandatory') xRadiusServerAccessFailed1 = MibScalar((1, 3, 6, 1, 4, 1, 33, 35, 4, 1, 4), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: xRadiusServerAccessFailed1.setStatus('mandatory') xRadiusServerName2 = MibScalar((1, 3, 6, 1, 4, 1, 33, 35, 4, 2, 1), OctetString().subtype(subtypeSpec=ValueSizeConstraint(51, 51)).setFixedLength(51)).setMaxAccess("readwrite") if mibBuilder.loadTexts: xRadiusServerName2.setStatus('mandatory') xRadiusSecret2 = MibScalar((1, 3, 6, 1, 4, 1, 33, 35, 4, 2, 2), OctetString().subtype(subtypeSpec=ValueSizeConstraint(32, 32)).setFixedLength(32).clone('Default_Secret')).setMaxAccess("readonly") if mibBuilder.loadTexts: xRadiusSecret2.setStatus('obsolete') xRadiusServerAccess2 = MibScalar((1, 3, 6, 1, 4, 1, 33, 35, 4, 2, 3), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: xRadiusServerAccess2.setStatus('mandatory') xRadiusServerAccessFailed2 = MibScalar((1, 3, 6, 1, 4, 1, 33, 35, 4, 2, 4), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: xRadiusServerAccessFailed2.setStatus('mandatory') xRadAuthCtsSubGrp = MibIdentifier((1, 3, 6, 1, 4, 1, 33, 35, 5, 1)) xRadAcctCtsSubGrp = MibIdentifier((1, 3, 6, 1, 4, 1, 33, 35, 5, 2)) xRadiusLogins = MibScalar((1, 3, 6, 1, 4, 1, 33, 35, 5, 1, 1), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: xRadiusLogins.setStatus('mandatory') xRadiusLoginsFailed = MibScalar((1, 3, 6, 1, 4, 1, 33, 35, 5, 1, 2), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: xRadiusLoginsFailed.setStatus('mandatory') xRadiusConfigFailed = MibScalar((1, 3, 6, 1, 4, 1, 33, 35, 5, 1, 3), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: xRadiusConfigFailed.setStatus('mandatory') xRadiusPolicyFailed = MibScalar((1, 3, 6, 1, 4, 1, 33, 35, 5, 1, 4), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: xRadiusPolicyFailed.setStatus('mandatory') xRadiusAcctSuccess = MibScalar((1, 3, 6, 1, 4, 1, 33, 35, 5, 2, 1), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: xRadiusAcctSuccess.setStatus('mandatory') xRadiusAcctFailed = MibScalar((1, 3, 6, 1, 4, 1, 33, 35, 5, 2, 2), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: xRadiusAcctFailed.setStatus('mandatory') xRadiusAcctReqWait = MibScalar((1, 3, 6, 1, 4, 1, 33, 35, 5, 2, 3), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: xRadiusAcctReqWait.setStatus('mandatory') mibBuilder.exportSymbols("ITOUCH-RADIUS-MIB", xRadiusConfigFailed=xRadiusConfigFailed, xRadiusLogging=xRadiusLogging, xRadiusCounters=xRadiusCounters, xRadiusAcctPortStatus=xRadiusAcctPortStatus, xRadiusPortIndex=xRadiusPortIndex, xRadiusChapChallengeSize=xRadiusChapChallengeSize, xRadiusCircuitTable=xRadiusCircuitTable, xRadiusCircuitEntry=xRadiusCircuitEntry, xRadiusAcctServerPort=xRadiusAcctServerPort, xRadiusMessage=xRadiusMessage, xRadiusAcctLogAttempts=xRadiusAcctLogAttempts, xRadServer2SubGrp=xRadServer2SubGrp, xRadius=xRadius, xRadiusServerAccess1=xRadiusServerAccess1, xRadiusServerAccessFailed2=xRadiusServerAccessFailed2, xRadiusCircuitIndex=xRadiusCircuitIndex, xRadiusServerAccess2=xRadiusServerAccess2, xRadAcctCtsSubGrp=xRadAcctCtsSubGrp, xRadiusLoginsFailed=xRadiusLoginsFailed, xRadiusAcctSuccess=xRadiusAcctSuccess, xRadiusServerName2=xRadiusServerName2, xRadiusTimeout=xRadiusTimeout, xRadiusAcctReqWait=xRadiusAcctReqWait, xRadServer1SubGrp=xRadServer1SubGrp, xRadiusPort=xRadiusPort, xRadiusPortTable=xRadiusPortTable, xRadiusPortSolicitStatus=xRadiusPortSolicitStatus, xRadiusServerAccessFailed1=xRadiusServerAccessFailed1, xRadiusCircAcctOnOff=xRadiusCircAcctOnOff, xRadiusLogins=xRadiusLogins, xRadiusAcctFailed=xRadiusAcctFailed, xRadiusPolicyFailed=xRadiusPolicyFailed, xRadiusConfig=xRadiusConfig, xRadiusCircuit=xRadiusCircuit, xRadiusServers=xRadiusServers, xRadAuthCtsSubGrp=xRadAuthCtsSubGrp, xRadiusSecret2=xRadiusSecret2, xRadiusServerRetries=xRadiusServerRetries, xRadiusServerName1=xRadiusServerName1, xRadiusPortStatus=xRadiusPortStatus, xRadiusAuthServerPort=xRadiusAuthServerPort, xRadiusPortEntry=xRadiusPortEntry, xRadiusSecret1=xRadiusSecret1)
# -*- coding: utf-8 -*- """ Created on Tue May 31 17:02:24 2016 @author: rmondoncancel """ # Deprecated priorityList = [ { 'name': 'fistOfFire', 'group': 'monk', 'prepull': True, 'condition': { 'type': 'buffPresent', 'name': 'fistOfFire', 'comparison': 'is', 'value': False, } }, { 'name': 'perfectBalance', 'group': 'pugilist', 'prepull': True, }, { 'name': 'bloodForBlood', 'group': 'lancer', 'condition': { 'logic': 'and', 'list': [ { 'type': 'buffAtMaxStacks', 'name': 'greasedLightning', 'comparison': 'is', 'value': True, }, ] } }, { 'name': 'perfectBalance', 'group': 'pugilist', 'condition': { 'type': 'cooldownPresent', 'name': 'tornadoKick', 'comparison': 'is', 'value': False, } }, { 'name': 'tornadoKick', 'group': 'monk', 'condition': { 'logic': 'and', 'list': [ { 'type': 'buffTimeLeft', 'name': 'perfectBalance', 'comparison': '>=', 'value': 7, }, { 'type': 'buffAtMaxStacks', 'name': 'greasedLightning', 'comparison': 'is', 'value': True, } ], } }, { 'name': 'internalRelease', 'group': 'pugilist', 'condition': { 'logic': 'and', 'list': [ { 'type': 'buffAtMaxStacks', 'name': 'greasedLightning', 'comparison': 'is', 'value': True, }, { 'type': 'cooldownTimeLeft', 'name': 'elixirField', 'comparison': '<=', 'value': 6, }, ] } }, { 'name': 'potionOfStrengthHQ', 'group': 'item', 'condition': { 'logic': 'and', 'list': [ { 'type': 'buffAtMaxStacks', 'name': 'greasedLightning', 'comparison': 'is', 'value': True, }, ] } }, { 'name': 'howlingFist', 'group': 'pugilist', 'condition': { 'type': 'buffPresent', 'name': 'internalRelease', 'comparison': 'is', 'value': True, } }, { 'name': 'elixirField', 'group': 'monk', 'condition': { 'logic': 'or', 'list': [ { 'type': 'buffPresent', 'name': 'internalRelease', 'comparison': 'is', 'value': True, }, { 'type': 'cooldownTimeLeft', 'name': 'internalRelease', 'comparison': '>=', 'value': 20, }, ], } }, { 'name': 'steelPeak', 'group': 'pugilist', 'condition': { 'logic': 'and', 'list': [ { 'type': 'buffAtMaxStacks', 'name': 'greasedLightning', 'comparison': 'is', 'value': True, }, ] } }, { 'name': 'touchOfDeath', 'group': 'pugilist', 'condition': { 'logic': 'and', 'list': [ { 'type': 'debuffTimeLeft', 'name': 'touchOfDeath', 'comparison': '<=', 'value': 1.5, }, { 'type': 'debuffPresent', 'name': 'dragonKick', 'comparison': 'is', 'value': True, }, { 'type': 'buffPresent', 'name': 'twinSnakes', 'comparison': 'is', 'value': True, }, ] } }, { 'name': 'fracture', 'group': 'marauder', 'condition': { 'logic': 'and', 'list': [ { 'type': 'debuffTimeLeft', 'name': 'fracture', 'comparison': '<=', 'value': 1.5, }, { 'type': 'debuffPresent', 'name': 'dragonKick', 'comparison': 'is', 'value': True, }, { 'type': 'buffPresent', 'name': 'twinSnakes', 'comparison': 'is', 'value': True, }, ] } }, { 'name': 'demolish', 'group': 'pugilist', 'condition': { 'type': 'debuffTimeLeft', 'name': 'demolish', 'comparison': '<=', 'value': 4, }, }, { 'name': 'twinSnakes', 'group': 'pugilist', 'condition': { 'type': 'buffTimeLeft', 'name': 'twinSnakes', 'comparison': '<=', 'value': 5, }, }, { 'name': 'snapPunch', 'group': 'pugilist', }, { 'name': 'dragonKick', 'group': 'monk', 'condition': { 'type': 'debuffTimeLeft', 'name': 'dragonKick', 'comparison': '<=', 'value': 5, }, }, { 'name': 'trueStrike', 'group': 'pugilist', }, { 'name': 'bootshine', 'group': 'pugilist', }, ]
hyper_params = { 'weight_decay': float(1e-6), 'epochs': 30, 'batch_size': 256, 'validate_every': 3, 'early_stop': 3, 'max_seq_len': 10, }
print("valores dos numeros pares e impares:") lista = [[],[]] numero =0 for c in range(0,7): numero = int(input(f"informe o {c+1}° numero:")) if numero %2 ==0: lista[0].append(numero) else: lista[1].append(numero) print("Dados os numeros informados:") print("lista dos numeros pares em ordem crescente:") lista[0].sort() for c in lista[0]: print(f"[{c}]",end="") print() print("lista dos numeros impares em ordem crescente:") lista[1].sort() for c in lista[1]: print(f"[{c}]",end="")
def topla(a, b): toplam = a + b if a < b: kucuk = a else: kucuk = b return (toplam, kucuk) toplam, kucuk = topla(1, 2) print(toplam, kucuk) tuple1 = (1, 2, 3) tuple2 = 1, 2, 3 tuple3 = tuple([1, 2, 3, 4, 5]) ilkSayi = tuple2[0] ikinciSayi = tuple2[1] ucuncuSayi = tuple2[2] ilkSayi, ikinciSayi, ucuncuSayi = tuple2 a = [1, 2, 3, 4, 5] print(a) print(a[1]) a.append(6) print(a) del a[2] print(a) b = (1, 2, 3) print(b) print(b[0]) # b.append(6) # Demetler (Tuple) değiştirilemezdir. a[0] = 123 # b[0] = 123
# 1073 n = int(input()) if 5 < n < 2000: for i in range(2, n + 1, 2): print("{}^{} = {}".format(i, 2, i ** 2))
class BinaryIndexedTree(object): def __init__(self): self.BITTree = [0] # Returns sum of arr[0..index]. This function assumes # that the array is preprocessed and partial sums of # array elements are stored in BITree[]. def getsum(self, i): s = 0 # initialize result # index in BITree[] is 1 more than the index in arr[] i = i + 1 # Traverse ancestors of BITree[index] while i > 0: # Add current element of BITree to sum s += self.BITTree[i] # Move index to parent node in getSum View i -= i & (-i) return s def get_sum(self, a, b): return self.getsum(b) - self.getsum(a-1) if a > 0 else 0 # Updates a node in Binary Index Tree (BITree) at given index # in BITree. The given value 'val' is added to BITree[i] and # all of its ancestors in tree. def updatebit(self, n, i, v): # index in BITree[] is 1 more than the index in arr[] i += 1 # Traverse all ancestors and add 'val' while i <= n: # Add 'val' to current node of BI Tree self.BITTree[i] += v # Update index to that of parent in update View i += i & (-i) # Constructs and returns a Binary Indexed Tree for given # array of size n. def construct(self, arr, n): # Create and initialize BITree[] as 0 self.BITTree = [0] * (n + 1) # Store the actual values in BITree[] using update() for i in range(n): self.updatebit(n, i, arr[i]) freq = [2, 1, 1, 3, 2, 3, 4, 5, 6, 7, 8, 9] BITTree = BinaryIndexedTree() BITTree.construct(freq,len(freq)) print("Sum of elements in arr[0..5] is " + str(BITTree.getsum(5))) freq[3] += 6 BITTree.updatebit(len(freq), 3, 6) print("Sum of elements in arr[0..5]"+ " after update is " + str(BITTree.getsum(5))) print("Sum of elements in arr[1..5]"+ " after update is " + str(BITTree.get_sum(2, 5)))
s = input() t = int(input()) xy = [0, 0] cnt = 0 for i in range(len(s)): if s[i] == 'U': xy[1] += 1 elif s[i] == 'D': xy[1] -= 1 elif s[i] == 'R': xy[0] += 1 elif s[i] == 'L': xy[0] -= 1 else: cnt += 1 ans = abs(xy[0]) + abs(xy[1]) if t == 1: ans += cnt else: if ans >= cnt: ans -= cnt else: ans = (ans - cnt) % 2 print(ans)
def is_valid_session(session: dict) -> bool: """ checks if passed dict has enough info to display event :param session: dict representing a session :return: True if it has enough info (title, start time, end time), False otherwise """ try: session_keys = session.keys() except AttributeError: print("probable error in ajax request...") return False # not a dict for expected in 'title', 'start', 'end': # minimal requirements if expected not in session_keys: return False return True # at this level, all required keys were found
class Solution: def intToRoman(self, num: int) -> str: convertor = [ ["","M", "MM", "MMM"], ["","C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM"], ["","X", "XX", "XXX", "XL", "L", "LX","LXX","LXXX", "XC"], ["","I","II","III","IV","V","VI","VII","VIII","IX"] ] return convertor[0][num//1000] + convertor[1][(num//100)%10] + convertor[2][(num//10)%10] + convertor[3][num%10] if __name__ == "__main__": sol = Solution() num = 58 print(sol.intToRoman(num))
yoo = { "af": "Afrikaans", "sq": "Albanian - shqip", "am": "Amharic - አማርኛ", "ar": "Arabic - العربية", "hy": "Armenian - հայերեն", "az": "Azerbaijani - azərbaycan dili", "bn": "Bengali - বাংলা", "bs": "Bosnian - bosanski", "bg": "Bulgarian - български", "ca": "Catalan - català", "zh": "Chinese - 中文", "zh-Hans": "Chinese (Simplified) - 中文(简体)", "zh-Hant": "Chinese (Traditional) - 中文(繁體)", "hr": "Croatian - hrvatski", "cs": "Czech - čeština", "da": "Danish - dansk", "nl": "Dutch - Nederlands", "en": "English", "et": "Estonian - eesti", "fj": "Fijian - føroyskt", "fil": "Filipino", "fi": "Finnish - suomi", "fr": "French - français", "de": "German - Deutsch", "el": "Greek - Ελληνικά", "gu": "Gujarati - ગુજરાતી", "ht": "Haitian Creole", "he": "Hebrew - עברית", "hi": "Hindi - हिन्दी", "mww": "Hmong Daw", "hu": "Hungarian - magyar", "is": "Icelandic - íslenska", "id": "Indonesian - Indonesia", "iu": "Inuktitut", "ga": "Irish - Gaeilge", "it": "Italian - italiano", "ja": "Japanese - 日本語", "kn": "Kannada - ಕನ್ನಡ", "kk": "Kazakh - қазақ тілі", "km": "Khmer - ខ្មែរ", "ko": "Korean - 한국어", "ku": "Kurdish - Kurdî", "lo": "Lao - ລາວ", "la": "Latin", "lv": "Latvian - latviešu", "lt": "Lithuanian - lietuvių", "mg": "Malagasy - मराठी", "ms": "Malay - Bahasa Melayu", "ml": "Malayalam - മലയാളം", "mt": "Maltese - Malti", "mn": "Mongolian - монгол", "ne": "Nepali - नेपाली", "no": "Norwegian - norsk", "or": "Oriya - ଓଡ଼ିଆ", "ps": "Pashto - پښتو", "fa": "Persian - فارسی", "pl": "Polish - polski", "pt": "Portuguese - português", "pt-pt": "Portuguese (Portugal)", "pa": "Punjabi - ਪੰਜਾਬੀ", "ro": "Romanian - română", "ru": "Russian - русский", "sr-Cyrl": "Serbian - српски", "sr-Latn": "Serbian - српски", "sd": "Sindhi", "si": "Sinhala - සිංහල", "sk": "Slovak - slovenčina", "sl": "Slovenian - slovenščina", "es": "Spanish - español", "sw": "Swahili - Kiswahili", "sv": "Swedish - svenska", "tg": "Tajik - тоҷикӣ", "ta": "Tamil - தமிழ்", "tt": "Tatar", "te": "Telugu - తెలుగు", "th": "Thai - ไทย", "ti": "Tigrinya - ትግርኛ", "to": "Tongan - lea fakatonga", "tr": "Turkish - Türkçe", "uk": "Ukrainian - українська", "ur": "Urdu - اردو", "vi": "Vietnamese - Tiếng Việt", "cy": "Welsh - Cymraeg", } def language_name(lang): return yoo[lang] if __name__ == "__main__": language_name(lang)
# 2. Multiples List # Write a program that receives two numbers (factor and count) and creates a list with length of the given count # and contains only elements that are multiples of the given factor. factor = int(input()) count = int(input()) list = [] for counter in range(1, count+1): list.append(factor * counter) print(list)
# # PySNMP MIB module H3C-IPSEC-MONITOR-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/H3C-IPSEC-MONITOR-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 19:09:33 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15) # OctetString, ObjectIdentifier, Integer = mibBuilder.importSymbols("ASN1", "OctetString", "ObjectIdentifier", "Integer") NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") SingleValueConstraint, ValueRangeConstraint, ValueSizeConstraint, ConstraintsUnion, ConstraintsIntersection = mibBuilder.importSymbols("ASN1-REFINEMENT", "SingleValueConstraint", "ValueRangeConstraint", "ValueSizeConstraint", "ConstraintsUnion", "ConstraintsIntersection") h3cCommon, = mibBuilder.importSymbols("HUAWEI-3COM-OID-MIB", "h3cCommon") ifIndex, = mibBuilder.importSymbols("IF-MIB", "ifIndex") ObjectGroup, NotificationGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "ObjectGroup", "NotificationGroup", "ModuleCompliance") IpAddress, Counter64, TimeTicks, Unsigned32, ModuleIdentity, ObjectIdentity, iso, NotificationType, MibIdentifier, Counter32, Gauge32, Bits, Integer32, MibScalar, MibTable, MibTableRow, MibTableColumn = mibBuilder.importSymbols("SNMPv2-SMI", "IpAddress", "Counter64", "TimeTicks", "Unsigned32", "ModuleIdentity", "ObjectIdentity", "iso", "NotificationType", "MibIdentifier", "Counter32", "Gauge32", "Bits", "Integer32", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn") TextualConvention, DisplayString = mibBuilder.importSymbols("SNMPv2-TC", "TextualConvention", "DisplayString") h3cIPSecMonitor = ModuleIdentity((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7)) if mibBuilder.loadTexts: h3cIPSecMonitor.setLastUpdated('200410260000Z') if mibBuilder.loadTexts: h3cIPSecMonitor.setOrganization('Huawei-3COM Technologies Co., Ltd.') class H3cDiffHellmanGrp(TextualConvention, Integer32): status = 'current' subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(0, 1, 2, 5, 14, 2147483647)) namedValues = NamedValues(("none", 0), ("modp768", 1), ("modp1024", 2), ("modp1536", 5), ("modp2048", 14), ("invalidGroup", 2147483647)) class H3cEncapMode(TextualConvention, Integer32): status = 'current' subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(1, 2, 2147483647)) namedValues = NamedValues(("tunnel", 1), ("transport", 2), ("invalidMode", 2147483647)) class H3cEncryptAlgo(TextualConvention, Integer32): status = 'current' subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 2147483647)) namedValues = NamedValues(("none", 0), ("desCbc", 1), ("ideaCbc", 2), ("blowfishCbc", 3), ("rc5R16B64Cbc", 4), ("tripledesCbc", 5), ("castCbc", 6), ("aesCbc", 7), ("nsaCbc", 8), ("aesCbc128", 9), ("aesCbc192", 10), ("aesCbc256", 11), ("invalidAlg", 2147483647)) class H3cAuthAlgo(TextualConvention, Integer32): status = 'current' subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(0, 1, 2, 2147483647)) namedValues = NamedValues(("none", 0), ("md5", 1), ("sha", 2), ("invalidAlg", 2147483647)) class H3cSaProtocol(TextualConvention, Integer32): status = 'current' subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(0, 1, 2, 3, 4)) namedValues = NamedValues(("reserved", 0), ("isakmp", 1), ("ah", 2), ("esp", 3), ("ipcomp", 4)) class H3cTrapStatus(TextualConvention, Integer32): status = 'current' subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(1, 2)) namedValues = NamedValues(("enabled", 1), ("disabled", 2)) class H3cIPSecIDType(TextualConvention, Integer32): status = 'current' subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)) namedValues = NamedValues(("reserved", 0), ("ipv4Addr", 1), ("fqdn", 2), ("userFqdn", 3), ("ipv4AddrSubnet", 4), ("ipv6Addr", 5), ("ipv6AddrSubnet", 6), ("ipv4AddrRange", 7), ("ipv6AddrRange", 8), ("derAsn1Dn", 9), ("derAsn1Gn", 10), ("keyId", 11)) class H3cTrafficType(TextualConvention, Integer32): status = 'current' subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(1, 4, 5, 6, 7, 8)) namedValues = NamedValues(("ipv4Addr", 1), ("ipv4AddrSubnet", 4), ("ipv6Addr", 5), ("ipv6AddrSubnet", 6), ("ipv4AddrRange", 7), ("ipv6AddrRange", 8)) class H3cIPSecNegoType(TextualConvention, Integer32): status = 'current' subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(1, 2, 2147483647)) namedValues = NamedValues(("ike", 1), ("manual", 2), ("invalidType", 2147483647)) class H3cIPSecTunnelState(TextualConvention, Integer32): status = 'current' subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(1, 2)) namedValues = NamedValues(("active", 1), ("timeout", 2)) h3cIPSecObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1)) h3cIPSecTunnelTable = MibTable((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 1), ) if mibBuilder.loadTexts: h3cIPSecTunnelTable.setStatus('current') h3cIPSecTunnelEntry = MibTableRow((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 1, 1), ).setIndexNames((0, "H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunIfIndex"), (0, "H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunEntryIndex"), (0, "H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunIndex")) if mibBuilder.loadTexts: h3cIPSecTunnelEntry.setStatus('current') h3cIPSecTunIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 1, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 2147483647))) if mibBuilder.loadTexts: h3cIPSecTunIfIndex.setStatus('current') h3cIPSecTunEntryIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 1, 1, 2), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 2147483647))) if mibBuilder.loadTexts: h3cIPSecTunEntryIndex.setStatus('current') h3cIPSecTunIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 1, 1, 3), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 2147483647))) if mibBuilder.loadTexts: h3cIPSecTunIndex.setStatus('current') h3cIPSecTunIKETunnelIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 1, 1, 4), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 2147483647))).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecTunIKETunnelIndex.setStatus('current') h3cIPSecTunLocalAddr = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 1, 1, 5), IpAddress()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecTunLocalAddr.setStatus('current') h3cIPSecTunRemoteAddr = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 1, 1, 6), IpAddress()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecTunRemoteAddr.setStatus('current') h3cIPSecTunKeyType = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 1, 1, 7), H3cIPSecNegoType()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecTunKeyType.setStatus('current') h3cIPSecTunEncapMode = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 1, 1, 8), H3cEncapMode()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecTunEncapMode.setStatus('current') h3cIPSecTunInitiator = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 1, 1, 9), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 2147483647))).clone(namedValues=NamedValues(("local", 1), ("remote", 2), ("none", 2147483647)))).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecTunInitiator.setStatus('current') h3cIPSecTunLifeSize = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 1, 1, 10), Gauge32()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecTunLifeSize.setStatus('current') h3cIPSecTunLifeTime = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 1, 1, 11), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 2147483647))).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecTunLifeTime.setStatus('current') h3cIPSecTunRemainTime = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 1, 1, 12), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 2147483647))).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecTunRemainTime.setStatus('current') h3cIPSecTunActiveTime = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 1, 1, 13), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 2147483647))).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecTunActiveTime.setStatus('current') h3cIPSecTunRemainSize = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 1, 1, 14), Gauge32()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecTunRemainSize.setStatus('current') h3cIPSecTunTotalRefreshes = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 1, 1, 15), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecTunTotalRefreshes.setStatus('current') h3cIPSecTunCurrentSaInstances = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 1, 1, 16), Gauge32()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecTunCurrentSaInstances.setStatus('current') h3cIPSecTunInSaEncryptAlgo = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 1, 1, 17), H3cEncryptAlgo()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecTunInSaEncryptAlgo.setStatus('current') h3cIPSecTunInSaAhAuthAlgo = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 1, 1, 18), H3cAuthAlgo()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecTunInSaAhAuthAlgo.setStatus('current') h3cIPSecTunInSaEspAuthAlgo = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 1, 1, 19), H3cAuthAlgo()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecTunInSaEspAuthAlgo.setStatus('current') h3cIPSecTunDiffHellmanGrp = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 1, 1, 20), H3cDiffHellmanGrp()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecTunDiffHellmanGrp.setStatus('current') h3cIPSecTunOutSaEncryptAlgo = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 1, 1, 21), H3cEncryptAlgo()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecTunOutSaEncryptAlgo.setStatus('current') h3cIPSecTunOutSaAhAuthAlgo = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 1, 1, 22), H3cAuthAlgo()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecTunOutSaAhAuthAlgo.setStatus('current') h3cIPSecTunOutSaEspAuthAlgo = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 1, 1, 23), H3cAuthAlgo()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecTunOutSaEspAuthAlgo.setStatus('current') h3cIPSecTunPolicyName = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 1, 1, 24), DisplayString()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecTunPolicyName.setStatus('current') h3cIPSecTunPolicyNum = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 1, 1, 25), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 2147483647))).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecTunPolicyNum.setStatus('current') h3cIPSecTunStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 1, 1, 26), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("initial", 1), ("ready", 2), ("rekeyed", 3), ("closed", 4)))).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecTunStatus.setStatus('current') h3cIPSecTunnelStatTable = MibTable((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 2), ) if mibBuilder.loadTexts: h3cIPSecTunnelStatTable.setStatus('current') h3cIPSecTunnelStatEntry = MibTableRow((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 2, 1), ).setIndexNames((0, "H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunIfIndex"), (0, "H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunEntryIndex"), (0, "H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunIndex")) if mibBuilder.loadTexts: h3cIPSecTunnelStatEntry.setStatus('current') h3cIPSecTunInOctets = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 2, 1, 1), Counter64()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecTunInOctets.setStatus('current') h3cIPSecTunInDecompOctets = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 2, 1, 2), Counter64()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecTunInDecompOctets.setStatus('current') h3cIPSecTunInPkts = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 2, 1, 3), Counter64()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecTunInPkts.setStatus('current') h3cIPSecTunInDropPkts = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 2, 1, 4), Counter64()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecTunInDropPkts.setStatus('current') h3cIPSecTunInReplayDropPkts = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 2, 1, 5), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecTunInReplayDropPkts.setStatus('current') h3cIPSecTunInAuthFails = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 2, 1, 6), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecTunInAuthFails.setStatus('current') h3cIPSecTunInDecryptFails = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 2, 1, 7), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecTunInDecryptFails.setStatus('current') h3cIPSecTunOutOctets = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 2, 1, 8), Counter64()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecTunOutOctets.setStatus('current') h3cIPSecTunOutUncompOctets = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 2, 1, 9), Counter64()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecTunOutUncompOctets.setStatus('current') h3cIPSecTunOutPkts = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 2, 1, 10), Counter64()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecTunOutPkts.setStatus('current') h3cIPSecTunOutDropPkts = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 2, 1, 11), Counter64()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecTunOutDropPkts.setStatus('current') h3cIPSecTunOutEncryptFails = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 2, 1, 12), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecTunOutEncryptFails.setStatus('current') h3cIPSecTunNoMemoryDropPkts = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 2, 1, 13), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecTunNoMemoryDropPkts.setStatus('current') h3cIPSecTunQueueFullDropPkts = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 2, 1, 14), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecTunQueueFullDropPkts.setStatus('current') h3cIPSecTunInvalidLenDropPkts = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 2, 1, 15), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecTunInvalidLenDropPkts.setStatus('current') h3cIPSecTunTooLongDropPkts = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 2, 1, 16), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecTunTooLongDropPkts.setStatus('current') h3cIPSecTunInvalidSaDropPkts = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 2, 1, 17), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecTunInvalidSaDropPkts.setStatus('current') h3cIPSecSaTable = MibTable((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 3), ) if mibBuilder.loadTexts: h3cIPSecSaTable.setStatus('current') h3cIPSecSaEntry = MibTableRow((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 3, 1), ).setIndexNames((0, "H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunIfIndex"), (0, "H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunEntryIndex"), (0, "H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunIndex"), (0, "H3C-IPSEC-MONITOR-MIB", "h3cIPSecSaIndex")) if mibBuilder.loadTexts: h3cIPSecSaEntry.setStatus('current') h3cIPSecSaIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 3, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 2147483647))) if mibBuilder.loadTexts: h3cIPSecSaIndex.setStatus('current') h3cIPSecSaDirection = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 3, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("in", 1), ("out", 2)))).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecSaDirection.setStatus('current') h3cIPSecSaValue = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 3, 1, 3), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(1, 4294967295))).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecSaValue.setStatus('current') h3cIPSecSaProtocol = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 3, 1, 4), H3cSaProtocol()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecSaProtocol.setStatus('current') h3cIPSecSaEncryptAlgo = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 3, 1, 5), H3cEncryptAlgo()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecSaEncryptAlgo.setStatus('current') h3cIPSecSaAuthAlgo = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 3, 1, 6), H3cAuthAlgo()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecSaAuthAlgo.setStatus('current') h3cIPSecSaStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 3, 1, 7), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("active", 1), ("expiring", 2)))).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecSaStatus.setStatus('current') h3cIPSecTrafficTable = MibTable((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 4), ) if mibBuilder.loadTexts: h3cIPSecTrafficTable.setStatus('current') h3cIPSecTrafficEntry = MibTableRow((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 4, 1), ).setIndexNames((0, "H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunIfIndex"), (0, "H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunEntryIndex"), (0, "H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunIndex")) if mibBuilder.loadTexts: h3cIPSecTrafficEntry.setStatus('current') h3cIPSecTrafficLocalType = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 4, 1, 1), H3cTrafficType()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecTrafficLocalType.setStatus('current') h3cIPSecTrafficLocalAddr1 = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 4, 1, 2), IpAddress()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecTrafficLocalAddr1.setStatus('current') h3cIPSecTrafficLocalAddr2 = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 4, 1, 3), IpAddress()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecTrafficLocalAddr2.setStatus('current') h3cIPSecTrafficLocalProtocol = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 4, 1, 4), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 255))).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecTrafficLocalProtocol.setStatus('current') h3cIPSecTrafficLocalPort = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 4, 1, 5), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 65535))).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecTrafficLocalPort.setStatus('current') h3cIPSecTrafficRemoteType = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 4, 1, 6), H3cTrafficType()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecTrafficRemoteType.setStatus('current') h3cIPSecTrafficRemoteAddr1 = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 4, 1, 7), IpAddress()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecTrafficRemoteAddr1.setStatus('current') h3cIPSecTrafficRemoteAddr2 = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 4, 1, 8), IpAddress()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecTrafficRemoteAddr2.setStatus('current') h3cIPSecTrafficRemoteProtocol = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 4, 1, 9), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 255))).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecTrafficRemoteProtocol.setStatus('current') h3cIPSecTrafficRemotePort = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 4, 1, 10), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 65535))).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecTrafficRemotePort.setStatus('current') h3cIPSecGlobalStats = MibIdentifier((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 5)) h3cIPSecGlobalActiveTunnels = MibScalar((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 5, 1), Gauge32()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecGlobalActiveTunnels.setStatus('current') h3cIPSecGlobalActiveSas = MibScalar((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 5, 2), Gauge32()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecGlobalActiveSas.setStatus('current') h3cIPSecGlobalInOctets = MibScalar((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 5, 3), Counter64()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecGlobalInOctets.setStatus('current') h3cIPSecGlobalInDecompOctets = MibScalar((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 5, 4), Counter64()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecGlobalInDecompOctets.setStatus('current') h3cIPSecGlobalInPkts = MibScalar((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 5, 5), Counter64()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecGlobalInPkts.setStatus('current') h3cIPSecGlobalInDrops = MibScalar((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 5, 6), Counter64()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecGlobalInDrops.setStatus('current') h3cIPSecGlobalInReplayDrops = MibScalar((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 5, 7), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecGlobalInReplayDrops.setStatus('current') h3cIPSecGlobalInAuthFails = MibScalar((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 5, 8), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecGlobalInAuthFails.setStatus('current') h3cIPSecGlobalInDecryptFails = MibScalar((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 5, 9), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecGlobalInDecryptFails.setStatus('current') h3cIPSecGlobalOutOctets = MibScalar((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 5, 10), Counter64()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecGlobalOutOctets.setStatus('current') h3cIPSecGlobalOutUncompOctets = MibScalar((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 5, 11), Counter64()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecGlobalOutUncompOctets.setStatus('current') h3cIPSecGlobalOutPkts = MibScalar((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 5, 12), Counter64()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecGlobalOutPkts.setStatus('current') h3cIPSecGlobalOutDrops = MibScalar((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 5, 13), Counter64()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecGlobalOutDrops.setStatus('current') h3cIPSecGlobalOutEncryptFails = MibScalar((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 5, 14), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecGlobalOutEncryptFails.setStatus('current') h3cIPSecGlobalNoMemoryDropPkts = MibScalar((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 5, 15), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecGlobalNoMemoryDropPkts.setStatus('current') h3cIPSecGlobalNoFindSaDropPkts = MibScalar((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 5, 16), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecGlobalNoFindSaDropPkts.setStatus('current') h3cIPSecGlobalQueueFullDropPkts = MibScalar((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 5, 17), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecGlobalQueueFullDropPkts.setStatus('current') h3cIPSecGlobalInvalidLenDropPkts = MibScalar((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 5, 18), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecGlobalInvalidLenDropPkts.setStatus('current') h3cIPSecGlobalTooLongDropPkts = MibScalar((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 5, 19), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecGlobalTooLongDropPkts.setStatus('current') h3cIPSecGlobalInvalidSaDropPkts = MibScalar((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 5, 20), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cIPSecGlobalInvalidSaDropPkts.setStatus('current') h3cIPSecTrapObject = MibIdentifier((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 6)) h3cIPSecPolicyName = MibScalar((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 6, 1), DisplayString()).setMaxAccess("accessiblefornotify") if mibBuilder.loadTexts: h3cIPSecPolicyName.setStatus('current') h3cIPSecPolicySeqNum = MibScalar((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 6, 2), Integer32()).setMaxAccess("accessiblefornotify") if mibBuilder.loadTexts: h3cIPSecPolicySeqNum.setStatus('current') h3cIPSecPolicySize = MibScalar((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 6, 3), Integer32()).setMaxAccess("accessiblefornotify") if mibBuilder.loadTexts: h3cIPSecPolicySize.setStatus('current') h3cIPSecSpiValue = MibScalar((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 6, 4), Integer32()).setMaxAccess("accessiblefornotify") if mibBuilder.loadTexts: h3cIPSecSpiValue.setStatus('current') h3cIPSecTrapCntl = MibIdentifier((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 7)) h3cIPSecTrapGlobalCntl = MibScalar((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 7, 1), H3cTrapStatus()).setMaxAccess("readwrite") if mibBuilder.loadTexts: h3cIPSecTrapGlobalCntl.setStatus('current') h3cIPSecTunnelStartTrapCntl = MibScalar((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 7, 2), H3cTrapStatus()).setMaxAccess("readwrite") if mibBuilder.loadTexts: h3cIPSecTunnelStartTrapCntl.setStatus('current') h3cIPSecTunnelStopTrapCntl = MibScalar((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 7, 3), H3cTrapStatus()).setMaxAccess("readwrite") if mibBuilder.loadTexts: h3cIPSecTunnelStopTrapCntl.setStatus('current') h3cIPSecNoSaTrapCntl = MibScalar((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 7, 4), H3cTrapStatus()).setMaxAccess("readwrite") if mibBuilder.loadTexts: h3cIPSecNoSaTrapCntl.setStatus('current') h3cIPSecAuthFailureTrapCntl = MibScalar((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 7, 5), H3cTrapStatus()).setMaxAccess("readwrite") if mibBuilder.loadTexts: h3cIPSecAuthFailureTrapCntl.setStatus('current') h3cIPSecEncryFailureTrapCntl = MibScalar((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 7, 6), H3cTrapStatus()).setMaxAccess("readwrite") if mibBuilder.loadTexts: h3cIPSecEncryFailureTrapCntl.setStatus('current') h3cIPSecDecryFailureTrapCntl = MibScalar((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 7, 7), H3cTrapStatus()).setMaxAccess("readwrite") if mibBuilder.loadTexts: h3cIPSecDecryFailureTrapCntl.setStatus('current') h3cIPSecInvalidSaTrapCntl = MibScalar((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 7, 8), H3cTrapStatus()).setMaxAccess("readwrite") if mibBuilder.loadTexts: h3cIPSecInvalidSaTrapCntl.setStatus('current') h3cIPSecPolicyAddTrapCntl = MibScalar((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 7, 9), H3cTrapStatus()).setMaxAccess("readwrite") if mibBuilder.loadTexts: h3cIPSecPolicyAddTrapCntl.setStatus('current') h3cIPSecPolicyDelTrapCntl = MibScalar((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 7, 10), H3cTrapStatus()).setMaxAccess("readwrite") if mibBuilder.loadTexts: h3cIPSecPolicyDelTrapCntl.setStatus('current') h3cIPSecPolicyAttachTrapCntl = MibScalar((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 7, 11), H3cTrapStatus()).setMaxAccess("readwrite") if mibBuilder.loadTexts: h3cIPSecPolicyAttachTrapCntl.setStatus('current') h3cIPSecPolicyDetachTrapCntl = MibScalar((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 7, 12), H3cTrapStatus()).setMaxAccess("readwrite") if mibBuilder.loadTexts: h3cIPSecPolicyDetachTrapCntl.setStatus('current') h3cIPSecTrap = MibIdentifier((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 8)) h3cIPSecNotifications = MibIdentifier((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 8, 1)) h3cIPSecTunnelStart = NotificationType((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 8, 1, 1)).setObjects(("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunLocalAddr"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunRemoteAddr"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunLifeTime"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunLifeSize")) if mibBuilder.loadTexts: h3cIPSecTunnelStart.setStatus('current') h3cIPSecTunnelStop = NotificationType((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 8, 1, 2)).setObjects(("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunLocalAddr"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunRemoteAddr"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunActiveTime")) if mibBuilder.loadTexts: h3cIPSecTunnelStop.setStatus('current') h3cIPSecNoSaFailure = NotificationType((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 8, 1, 3)).setObjects(("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunLocalAddr"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunRemoteAddr")) if mibBuilder.loadTexts: h3cIPSecNoSaFailure.setStatus('current') h3cIPSecAuthFailFailure = NotificationType((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 8, 1, 4)).setObjects(("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunLocalAddr"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunRemoteAddr")) if mibBuilder.loadTexts: h3cIPSecAuthFailFailure.setStatus('current') h3cIPSecEncryFailFailure = NotificationType((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 8, 1, 5)).setObjects(("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunLocalAddr"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunRemoteAddr")) if mibBuilder.loadTexts: h3cIPSecEncryFailFailure.setStatus('current') h3cIPSecDecryFailFailure = NotificationType((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 8, 1, 6)).setObjects(("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunLocalAddr"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunRemoteAddr")) if mibBuilder.loadTexts: h3cIPSecDecryFailFailure.setStatus('current') h3cIPSecInvalidSaFailure = NotificationType((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 8, 1, 7)).setObjects(("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunLocalAddr"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunRemoteAddr"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecSpiValue")) if mibBuilder.loadTexts: h3cIPSecInvalidSaFailure.setStatus('current') h3cIPSecPolicyAdd = NotificationType((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 8, 1, 8)).setObjects(("H3C-IPSEC-MONITOR-MIB", "h3cIPSecPolicyName"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecPolicySeqNum"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecPolicySize")) if mibBuilder.loadTexts: h3cIPSecPolicyAdd.setStatus('current') h3cIPSecPolicyDel = NotificationType((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 8, 1, 9)).setObjects(("H3C-IPSEC-MONITOR-MIB", "h3cIPSecPolicyName"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecPolicySeqNum"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecPolicySize")) if mibBuilder.loadTexts: h3cIPSecPolicyDel.setStatus('current') h3cIPSecPolicyAttach = NotificationType((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 8, 1, 10)).setObjects(("H3C-IPSEC-MONITOR-MIB", "h3cIPSecPolicyName"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecPolicySize"), ("IF-MIB", "ifIndex")) if mibBuilder.loadTexts: h3cIPSecPolicyAttach.setStatus('current') h3cIPSecPolicyDetach = NotificationType((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 1, 8, 1, 11)).setObjects(("H3C-IPSEC-MONITOR-MIB", "h3cIPSecPolicyName"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecPolicySize"), ("IF-MIB", "ifIndex")) if mibBuilder.loadTexts: h3cIPSecPolicyDetach.setStatus('current') h3cIPSecConformance = MibIdentifier((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 2)) h3cIPSecCompliances = MibIdentifier((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 2, 1)) h3cIPSecGroups = MibIdentifier((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 2, 2)) h3cIPSecCompliance = ModuleCompliance((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 2, 1, 1)).setObjects(("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunnelTableGroup"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunnelStatGroup"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecSaGroup"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTrafficTableGroup"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecGlobalStatsGroup"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTrapObjectGroup"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTrapCntlGroup"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTrapGroup")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): h3cIPSecCompliance = h3cIPSecCompliance.setStatus('current') h3cIPSecTunnelTableGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 2, 2, 1)).setObjects(("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunIKETunnelIndex"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunLocalAddr"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunRemoteAddr"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunKeyType"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunEncapMode"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunInitiator"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunLifeSize"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunLifeTime"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunRemainTime"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunActiveTime"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunRemainSize"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunTotalRefreshes"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunCurrentSaInstances"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunInSaEncryptAlgo"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunInSaAhAuthAlgo"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunInSaEspAuthAlgo"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunDiffHellmanGrp"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunOutSaEncryptAlgo"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunOutSaAhAuthAlgo"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunOutSaEspAuthAlgo"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunPolicyName"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunPolicyNum"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunStatus")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): h3cIPSecTunnelTableGroup = h3cIPSecTunnelTableGroup.setStatus('current') h3cIPSecTunnelStatGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 2, 2, 2)).setObjects(("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunInOctets"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunInDecompOctets"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunInPkts"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunInDropPkts"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunInReplayDropPkts"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunInAuthFails"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunInDecryptFails"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunOutOctets"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunOutUncompOctets"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunOutPkts"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunOutDropPkts"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunOutEncryptFails"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunNoMemoryDropPkts"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunQueueFullDropPkts"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunInvalidLenDropPkts"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunTooLongDropPkts"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunInvalidSaDropPkts")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): h3cIPSecTunnelStatGroup = h3cIPSecTunnelStatGroup.setStatus('current') h3cIPSecSaGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 2, 2, 3)).setObjects(("H3C-IPSEC-MONITOR-MIB", "h3cIPSecSaDirection"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecSaValue"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecSaProtocol"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecSaEncryptAlgo"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecSaAuthAlgo"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecSaStatus")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): h3cIPSecSaGroup = h3cIPSecSaGroup.setStatus('current') h3cIPSecTrafficTableGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 2, 2, 4)).setObjects(("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTrafficLocalType"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTrafficLocalAddr1"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTrafficLocalAddr2"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTrafficLocalProtocol"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTrafficLocalPort"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTrafficRemoteType"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTrafficRemoteAddr1"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTrafficRemoteAddr2"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTrafficRemoteProtocol"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTrafficRemotePort")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): h3cIPSecTrafficTableGroup = h3cIPSecTrafficTableGroup.setStatus('current') h3cIPSecGlobalStatsGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 2, 2, 5)).setObjects(("H3C-IPSEC-MONITOR-MIB", "h3cIPSecGlobalActiveTunnels"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecGlobalActiveSas"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecGlobalInOctets"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecGlobalInDecompOctets"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecGlobalInPkts"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecGlobalInDrops"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecGlobalInReplayDrops"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecGlobalInAuthFails"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecGlobalInDecryptFails"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecGlobalOutOctets"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecGlobalOutUncompOctets"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecGlobalOutPkts"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecGlobalOutDrops"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecGlobalOutEncryptFails"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecGlobalNoMemoryDropPkts"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecGlobalNoFindSaDropPkts"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecGlobalQueueFullDropPkts"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecGlobalInvalidLenDropPkts"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecGlobalTooLongDropPkts"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecGlobalInvalidSaDropPkts")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): h3cIPSecGlobalStatsGroup = h3cIPSecGlobalStatsGroup.setStatus('current') h3cIPSecTrapObjectGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 2, 2, 6)).setObjects(("H3C-IPSEC-MONITOR-MIB", "h3cIPSecPolicyName"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecPolicySeqNum"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecPolicySize"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecSpiValue")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): h3cIPSecTrapObjectGroup = h3cIPSecTrapObjectGroup.setStatus('current') h3cIPSecTrapCntlGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 2, 2, 7)).setObjects(("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTrapGlobalCntl"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunnelStartTrapCntl"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunnelStopTrapCntl"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecNoSaTrapCntl"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecAuthFailureTrapCntl"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecEncryFailureTrapCntl"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecDecryFailureTrapCntl"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecInvalidSaTrapCntl"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecPolicyAddTrapCntl"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecPolicyDelTrapCntl"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecPolicyAttachTrapCntl"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecPolicyDetachTrapCntl")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): h3cIPSecTrapCntlGroup = h3cIPSecTrapCntlGroup.setStatus('current') h3cIPSecTrapGroup = NotificationGroup((1, 3, 6, 1, 4, 1, 2011, 10, 2, 7, 2, 2, 8)).setObjects(("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunnelStart"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecTunnelStop"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecNoSaFailure"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecAuthFailFailure"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecEncryFailFailure"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecDecryFailFailure"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecInvalidSaFailure"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecPolicyAdd"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecPolicyDel"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecPolicyAttach"), ("H3C-IPSEC-MONITOR-MIB", "h3cIPSecPolicyDetach")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): h3cIPSecTrapGroup = h3cIPSecTrapGroup.setStatus('current') mibBuilder.exportSymbols("H3C-IPSEC-MONITOR-MIB", h3cIPSecTrafficRemoteAddr2=h3cIPSecTrafficRemoteAddr2, h3cIPSecTrafficLocalAddr1=h3cIPSecTrafficLocalAddr1, h3cIPSecTunInOctets=h3cIPSecTunInOctets, h3cIPSecTunStatus=h3cIPSecTunStatus, h3cIPSecGlobalStats=h3cIPSecGlobalStats, h3cIPSecTrafficRemoteType=h3cIPSecTrafficRemoteType, h3cIPSecGlobalQueueFullDropPkts=h3cIPSecGlobalQueueFullDropPkts, h3cIPSecTunInvalidSaDropPkts=h3cIPSecTunInvalidSaDropPkts, h3cIPSecTunLocalAddr=h3cIPSecTunLocalAddr, h3cIPSecTunKeyType=h3cIPSecTunKeyType, h3cIPSecGlobalTooLongDropPkts=h3cIPSecGlobalTooLongDropPkts, h3cIPSecTunEntryIndex=h3cIPSecTunEntryIndex, PYSNMP_MODULE_ID=h3cIPSecMonitor, h3cIPSecTrapGlobalCntl=h3cIPSecTrapGlobalCntl, h3cIPSecTunOutEncryptFails=h3cIPSecTunOutEncryptFails, h3cIPSecTunNoMemoryDropPkts=h3cIPSecTunNoMemoryDropPkts, h3cIPSecAuthFailFailure=h3cIPSecAuthFailFailure, h3cIPSecSpiValue=h3cIPSecSpiValue, h3cIPSecGlobalOutEncryptFails=h3cIPSecGlobalOutEncryptFails, h3cIPSecSaEncryptAlgo=h3cIPSecSaEncryptAlgo, h3cIPSecSaStatus=h3cIPSecSaStatus, h3cIPSecTunRemainTime=h3cIPSecTunRemainTime, h3cIPSecTunnelStartTrapCntl=h3cIPSecTunnelStartTrapCntl, H3cAuthAlgo=H3cAuthAlgo, h3cIPSecTrafficTableGroup=h3cIPSecTrafficTableGroup, h3cIPSecPolicyAttach=h3cIPSecPolicyAttach, h3cIPSecGlobalInDecryptFails=h3cIPSecGlobalInDecryptFails, h3cIPSecTunRemainSize=h3cIPSecTunRemainSize, h3cIPSecSaDirection=h3cIPSecSaDirection, h3cIPSecDecryFailureTrapCntl=h3cIPSecDecryFailureTrapCntl, h3cIPSecTunIndex=h3cIPSecTunIndex, h3cIPSecPolicyDetachTrapCntl=h3cIPSecPolicyDetachTrapCntl, h3cIPSecNoSaFailure=h3cIPSecNoSaFailure, h3cIPSecPolicyAttachTrapCntl=h3cIPSecPolicyAttachTrapCntl, h3cIPSecTunInSaAhAuthAlgo=h3cIPSecTunInSaAhAuthAlgo, h3cIPSecTunnelStatEntry=h3cIPSecTunnelStatEntry, h3cIPSecTunInDecryptFails=h3cIPSecTunInDecryptFails, h3cIPSecNotifications=h3cIPSecNotifications, h3cIPSecGlobalInPkts=h3cIPSecGlobalInPkts, h3cIPSecTunInvalidLenDropPkts=h3cIPSecTunInvalidLenDropPkts, h3cIPSecGlobalActiveSas=h3cIPSecGlobalActiveSas, h3cIPSecGlobalActiveTunnels=h3cIPSecGlobalActiveTunnels, h3cIPSecGlobalOutUncompOctets=h3cIPSecGlobalOutUncompOctets, H3cSaProtocol=H3cSaProtocol, h3cIPSecTunInSaEncryptAlgo=h3cIPSecTunInSaEncryptAlgo, h3cIPSecTunOutOctets=h3cIPSecTunOutOctets, h3cIPSecInvalidSaFailure=h3cIPSecInvalidSaFailure, h3cIPSecTunQueueFullDropPkts=h3cIPSecTunQueueFullDropPkts, h3cIPSecPolicyName=h3cIPSecPolicyName, h3cIPSecSaIndex=h3cIPSecSaIndex, h3cIPSecTunTotalRefreshes=h3cIPSecTunTotalRefreshes, h3cIPSecSaProtocol=h3cIPSecSaProtocol, H3cEncapMode=H3cEncapMode, h3cIPSecTrafficLocalProtocol=h3cIPSecTrafficLocalProtocol, h3cIPSecPolicySeqNum=h3cIPSecPolicySeqNum, h3cIPSecTunActiveTime=h3cIPSecTunActiveTime, h3cIPSecTunOutSaEspAuthAlgo=h3cIPSecTunOutSaEspAuthAlgo, h3cIPSecTunPolicyNum=h3cIPSecTunPolicyNum, h3cIPSecGlobalInAuthFails=h3cIPSecGlobalInAuthFails, h3cIPSecGlobalOutDrops=h3cIPSecGlobalOutDrops, h3cIPSecConformance=h3cIPSecConformance, h3cIPSecTunInAuthFails=h3cIPSecTunInAuthFails, h3cIPSecTunnelStop=h3cIPSecTunnelStop, h3cIPSecTunOutSaAhAuthAlgo=h3cIPSecTunOutSaAhAuthAlgo, h3cIPSecSaValue=h3cIPSecSaValue, h3cIPSecGlobalOutOctets=h3cIPSecGlobalOutOctets, h3cIPSecPolicyDelTrapCntl=h3cIPSecPolicyDelTrapCntl, h3cIPSecTunTooLongDropPkts=h3cIPSecTunTooLongDropPkts, h3cIPSecTunInSaEspAuthAlgo=h3cIPSecTunInSaEspAuthAlgo, h3cIPSecTunDiffHellmanGrp=h3cIPSecTunDiffHellmanGrp, h3cIPSecTunOutUncompOctets=h3cIPSecTunOutUncompOctets, h3cIPSecTunnelStatGroup=h3cIPSecTunnelStatGroup, h3cIPSecTunPolicyName=h3cIPSecTunPolicyName, h3cIPSecObjects=h3cIPSecObjects, h3cIPSecMonitor=h3cIPSecMonitor, h3cIPSecEncryFailFailure=h3cIPSecEncryFailFailure, h3cIPSecTunInReplayDropPkts=h3cIPSecTunInReplayDropPkts, h3cIPSecGlobalNoMemoryDropPkts=h3cIPSecGlobalNoMemoryDropPkts, h3cIPSecPolicyAdd=h3cIPSecPolicyAdd, h3cIPSecGlobalInDrops=h3cIPSecGlobalInDrops, h3cIPSecPolicyDetach=h3cIPSecPolicyDetach, h3cIPSecDecryFailFailure=h3cIPSecDecryFailFailure, h3cIPSecTrapCntlGroup=h3cIPSecTrapCntlGroup, h3cIPSecTunOutPkts=h3cIPSecTunOutPkts, h3cIPSecTrafficRemoteAddr1=h3cIPSecTrafficRemoteAddr1, h3cIPSecSaGroup=h3cIPSecSaGroup, H3cIPSecTunnelState=H3cIPSecTunnelState, h3cIPSecTunLifeSize=h3cIPSecTunLifeSize, h3cIPSecTunOutDropPkts=h3cIPSecTunOutDropPkts, H3cTrapStatus=H3cTrapStatus, h3cIPSecGroups=h3cIPSecGroups, h3cIPSecTrafficLocalPort=h3cIPSecTrafficLocalPort, h3cIPSecGlobalInOctets=h3cIPSecGlobalInOctets, h3cIPSecGlobalStatsGroup=h3cIPSecGlobalStatsGroup, h3cIPSecTunInDropPkts=h3cIPSecTunInDropPkts, h3cIPSecGlobalOutPkts=h3cIPSecGlobalOutPkts, h3cIPSecTunOutSaEncryptAlgo=h3cIPSecTunOutSaEncryptAlgo, H3cIPSecNegoType=H3cIPSecNegoType, h3cIPSecTrafficLocalAddr2=h3cIPSecTrafficLocalAddr2, h3cIPSecTrafficRemoteProtocol=h3cIPSecTrafficRemoteProtocol, h3cIPSecTrapObject=h3cIPSecTrapObject, h3cIPSecTunCurrentSaInstances=h3cIPSecTunCurrentSaInstances, h3cIPSecGlobalInvalidLenDropPkts=h3cIPSecGlobalInvalidLenDropPkts, h3cIPSecGlobalInReplayDrops=h3cIPSecGlobalInReplayDrops, h3cIPSecPolicyDel=h3cIPSecPolicyDel, h3cIPSecTunnelTableGroup=h3cIPSecTunnelTableGroup, h3cIPSecAuthFailureTrapCntl=h3cIPSecAuthFailureTrapCntl, H3cTrafficType=H3cTrafficType, h3cIPSecTunIfIndex=h3cIPSecTunIfIndex, h3cIPSecNoSaTrapCntl=h3cIPSecNoSaTrapCntl, h3cIPSecTunInDecompOctets=h3cIPSecTunInDecompOctets, h3cIPSecPolicyAddTrapCntl=h3cIPSecPolicyAddTrapCntl, h3cIPSecCompliance=h3cIPSecCompliance, h3cIPSecTunnelStopTrapCntl=h3cIPSecTunnelStopTrapCntl, h3cIPSecTunInPkts=h3cIPSecTunInPkts, h3cIPSecInvalidSaTrapCntl=h3cIPSecInvalidSaTrapCntl, h3cIPSecSaAuthAlgo=h3cIPSecSaAuthAlgo, h3cIPSecTrafficTable=h3cIPSecTrafficTable, h3cIPSecPolicySize=h3cIPSecPolicySize, h3cIPSecTrap=h3cIPSecTrap, h3cIPSecTunnelEntry=h3cIPSecTunnelEntry, h3cIPSecTunEncapMode=h3cIPSecTunEncapMode, h3cIPSecTrafficLocalType=h3cIPSecTrafficLocalType, h3cIPSecTunnelStatTable=h3cIPSecTunnelStatTable, h3cIPSecSaEntry=h3cIPSecSaEntry, h3cIPSecTrafficRemotePort=h3cIPSecTrafficRemotePort, h3cIPSecTrapCntl=h3cIPSecTrapCntl, h3cIPSecEncryFailureTrapCntl=h3cIPSecEncryFailureTrapCntl, h3cIPSecGlobalInDecompOctets=h3cIPSecGlobalInDecompOctets, h3cIPSecCompliances=h3cIPSecCompliances, h3cIPSecTunIKETunnelIndex=h3cIPSecTunIKETunnelIndex, h3cIPSecTunnelTable=h3cIPSecTunnelTable, h3cIPSecTrafficEntry=h3cIPSecTrafficEntry, h3cIPSecTunRemoteAddr=h3cIPSecTunRemoteAddr, H3cIPSecIDType=H3cIPSecIDType, h3cIPSecTrapObjectGroup=h3cIPSecTrapObjectGroup, h3cIPSecTunInitiator=h3cIPSecTunInitiator, h3cIPSecTunLifeTime=h3cIPSecTunLifeTime, h3cIPSecTrapGroup=h3cIPSecTrapGroup, H3cDiffHellmanGrp=H3cDiffHellmanGrp, H3cEncryptAlgo=H3cEncryptAlgo, h3cIPSecGlobalNoFindSaDropPkts=h3cIPSecGlobalNoFindSaDropPkts, h3cIPSecTunnelStart=h3cIPSecTunnelStart, h3cIPSecGlobalInvalidSaDropPkts=h3cIPSecGlobalInvalidSaDropPkts, h3cIPSecSaTable=h3cIPSecSaTable)
# # PySNMP MIB module CISCO-CAS-IF-CAPABILITY (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-CAS-IF-CAPABILITY # Produced by pysmi-0.3.4 at Mon Apr 29 17:35:01 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, OctetString, ObjectIdentifier = mibBuilder.importSymbols("ASN1", "Integer", "OctetString", "ObjectIdentifier") NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") ValueRangeConstraint, SingleValueConstraint, ConstraintsIntersection, ValueSizeConstraint, ConstraintsUnion = mibBuilder.importSymbols("ASN1-REFINEMENT", "ValueRangeConstraint", "SingleValueConstraint", "ConstraintsIntersection", "ValueSizeConstraint", "ConstraintsUnion") ciscoAgentCapability, = mibBuilder.importSymbols("CISCO-SMI", "ciscoAgentCapability") AgentCapabilities, ModuleCompliance, NotificationGroup = mibBuilder.importSymbols("SNMPv2-CONF", "AgentCapabilities", "ModuleCompliance", "NotificationGroup") TimeTicks, Integer32, iso, ObjectIdentity, Unsigned32, IpAddress, Bits, MibIdentifier, Counter64, Counter32, ModuleIdentity, MibScalar, MibTable, MibTableRow, MibTableColumn, Gauge32, NotificationType = mibBuilder.importSymbols("SNMPv2-SMI", "TimeTicks", "Integer32", "iso", "ObjectIdentity", "Unsigned32", "IpAddress", "Bits", "MibIdentifier", "Counter64", "Counter32", "ModuleIdentity", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Gauge32", "NotificationType") DisplayString, TextualConvention = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TextualConvention") ciscoCasIfCapability = ModuleIdentity((1, 3, 6, 1, 4, 1, 9, 7, 122)) ciscoCasIfCapability.setRevisions(('2009-12-04 00:00', '2004-08-10 00:00', '2003-12-03 00:00',)) if mibBuilder.loadTexts: ciscoCasIfCapability.setLastUpdated('200912040000Z') if mibBuilder.loadTexts: ciscoCasIfCapability.setOrganization('Cisco Systems, Inc.') ciscoCasIfCapabilityV5R000 = AgentCapabilities((1, 3, 6, 1, 4, 1, 9, 7, 122, 1)) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): ciscoCasIfCapabilityV5R000 = ciscoCasIfCapabilityV5R000.setProductRelease('MGX8850 Release 5.0') if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): ciscoCasIfCapabilityV5R000 = ciscoCasIfCapabilityV5R000.setStatus('current') ciscoCasIfCapabilityV5R015 = AgentCapabilities((1, 3, 6, 1, 4, 1, 9, 7, 122, 2)) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): ciscoCasIfCapabilityV5R015 = ciscoCasIfCapabilityV5R015.setProductRelease('MGX8850 Release 5.0.15') if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): ciscoCasIfCapabilityV5R015 = ciscoCasIfCapabilityV5R015.setStatus('current') ciscoCasIfCapabilityV12R04TPC3xxx = AgentCapabilities((1, 3, 6, 1, 4, 1, 9, 7, 122, 3)) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): ciscoCasIfCapabilityV12R04TPC3xxx = ciscoCasIfCapabilityV12R04TPC3xxx.setProductRelease('CISCO IOS 12.4T for Integrate Service\n Router (ISR) c2xxx and c3xxx platforms.') if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): ciscoCasIfCapabilityV12R04TPC3xxx = ciscoCasIfCapabilityV12R04TPC3xxx.setStatus('current') mibBuilder.exportSymbols("CISCO-CAS-IF-CAPABILITY", ciscoCasIfCapabilityV5R015=ciscoCasIfCapabilityV5R015, ciscoCasIfCapability=ciscoCasIfCapability, ciscoCasIfCapabilityV5R000=ciscoCasIfCapabilityV5R000, PYSNMP_MODULE_ID=ciscoCasIfCapability, ciscoCasIfCapabilityV12R04TPC3xxx=ciscoCasIfCapabilityV12R04TPC3xxx)
""" Copyright 2018 Arm Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. SPDX-License-Identifier: Apache-2.0 """ class NaiveCommentParser: """Naive comment parser.""" def __init__(self): self.in_comment = False """Are we in a multi-line comment?""" def parse_line(self, line): """Parse comments in a source line. Args: line (str): The line to parse. Returns: bool: Is this line a comment? """ if line.lstrip().startswith('//'): return True if self.in_comment: if '*/' in line: self.in_comment = False return True else: if line.lstrip().startswith('/*'): if not '*/' in line: self.in_comment = True return True elif line.rstrip().endswith('*/'): return True return False
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ CS231n Convolutional Neural Networks for Visual Recognition http://cs231n.github.io/ Python Numpy Tutorial http://cs231n.github.io/python-numpy-tutorial/  ̄ python_numpy_tutorial-python-containers_dictionary.py 2019-07-03 (Wed) """ # Python Numpy Tutorial > Python > Containers # Python's built-in container types: # lists, dictionaries, sets, and tuples. # # (Python) Lists # a mutable ordered list of values. # A list is the Python equivalent of an array with useful functions. # A Python list is resizeable and # can contain elements of different types. # # Dictionaries # stores key-value pairs # # Sets # an unordered collection of distinct elements. # # Tuples # an immutable ordered list of values. # A tuple is similar to a list, but different in that # tuples can be used as keys in dictionaries and # as elements of sets. # # =[,,] (Python) list ~= Dynamic array (with useful functions) # ={:,:,:} Dictionary ~= Map # ={,,} Set = Set # =(,) Tuples ~= (Python) list # # This example covers: # Lists # Slicing # A concise syntax to access sublists. # Loops # You can loop over the elements of a list. # The enumerate function returns the index & value. # List comprehensions # A concise way to loop through a list. # e.g. 3 lines of code -> 1 line of code # # Dictionaries # (Basics) # Loops # Dictionary comprehensions # # Sets # (Basics) # Loops # Iterating over a set has the same syntax as a list. # However you cannot make assumptions about the order. # Set comprehensions # Like list comprehension & dictionary comprehension, # constructing a set is easy with set comprehensions. # # Tuple # (Basics) # # Read more about: # 4.6.4. Lists¶ # https://docs.python.org/3.5/library/stdtypes.html#lists # # 4.9. Set Types — set, frozenset¶ # https://docs.python.org/3.5/library/stdtypes.html#set # # 4.10. Mapping Types — dict # https://docs.python.org/3.5/library/stdtypes.html#dict # # 5.3. Tuples and Sequences # https://docs.python.org/3.5/tutorial/datastructures.html#tuples-and-sequences print('Dictionary') # Create a new dictionary d = {'cat':'cute','dog':'furry'} print( d ) #{'cat': 'cute', 'dog': 'furry'} print( d['cat'] ) # cute # Check if a dictionary has 'cat'. print( 'cat' in d ) # True # Set an entry in the dictionary. d['fish'] = 'wet' print( d['fish'] ) # wet print( d ) #{'cat': 'cute', 'dog': 'furry', 'fish': 'wet'} # Get an element with a default print( d.get('monkey', 'N/A') ) # N/A # because 'monkey' is not there, prints N/A # Get an element with a default print( d.get('fish','N/A') ) #wet # because 'fish' is there, prints the value of it! del d['fish'] print( d.get('fish','N/A') ) #N/A # because 'fish' is deleted, 'fish' isn't in the list of the keys. # So prints N/A print('Loops') d = {'person':2, 'cat':4, 'spider':8} for animal in d: # Only the key is returned #print( animal ) legs = d[animal] print('A %s has %d legs.' %(animal, legs)) print('Dictionary comprehensions') # Dictionary comprehensions are similar to list comprehensions. # But these allow you to easily construct dictionaries. nums = [0, 1, 2, 3, 4] even_num_to_square = {x: x**2 for x in nums if x%2 == 0} print( even_num_to_square ) #{0: 0, 2: 4, 4: 16}
valor1 = int(input('Digite o primeiro valor a ser somado: ')) valor2 = int(input('Digite o segundo valor: ')) soma = valor1 + valor2 print('A soma entre {} e {} é igual a {}.'.format(valor1, valor2, soma))
# Definition for a binary tree node. class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def sortedArrayToBST(self, nums) -> TreeNode: def func(left, right) -> TreeNode: if left > right: return None mid = (left + right) // 2 node = TreeNode(nums[mid]) node.left = func(left, mid - 1) node.right = func(mid + 1, right) return node return func(0, len(nums) - 1)
# Write a python program to search the number of Times a paricular number in a list ''' a = [] n = int(input("Enter a no. of element: ")) for i in range(n+1): #(n+1) here I can use input function but this is different method b = int(input("Enter element: ")) a.append(b) print(a) k = 0 num = int(input("Enter the number to be counted: ")) for j in a: if(j==num): k = k+1 print("No. of times ", num, " appear is ", k) print("-------------------------------------------") a = [] for i in range(int(input("How many element in the list? "))): b = int(input("enter the element to be appear in the list: ")) a.append(b) print(a) k = 0 num = int(input("Enter the numbe to be counted: ")) for j in a: if(j==num): k += 1 print("No. of times ", num, "appear is ", k) ''' print("======================================") print("Write a python program to search the number of times a particular number is presentt in the list. ") a = [] for i in range(int(input("Enter no. of element to be listed in the list: "))): b = int(input("Ënter the elemetn to append in the list: ")) a.append(b) print(a) num = int(input("Enter the number to be counted: ")) repeated_num = 0 for repeat in a: if repeat == num: repeated_num += 1 print("No. of times ", num, " appears in the list ", repeated_num)
info = {} nome = str(input('NOME: ')) nasc = int(input('ANO DE NASCIMENTO: ')) idade = 2020 - nasc cart = int(input('CARTEIRA DE TRABALHO (0 Se não tiver): ')) info['NOME'] = nome info['IDADE'] = idade info['NASCIMENTO'] = nasc info['CTPS'] = cart if cart == 0: for k, v in info.items(): print(f'{k} = {v}') if cart > 0: contrat = int(input('ANO DE CONTRATAÇÃO: ')) sal = int(input('SALÁRIO: R$ ')) contri = 2020 - contrat anoaposent = 2020 + (35 - contri) idadeaposent = idade + (anoaposent - 2020) info['ANO DE CONTRATAÇÃO'] = contrat info['SALÁRIO'] = sal info['APOSENTADORIA'] = idadeaposent for k, v in info.items(): print(f'{k} = {v}')
def msg(m): """ Shorthand for print statement """ print(m) def dashes(cnt=40): """ Print dashed line """ msg('-' * cnt) def msgt(m): """ Add dashed line pre/post print statment """ dashes() msg(m) dashes()
# -*- coding: utf-8 -*- """ Created on Tue May 10 08:18:02 2016 @author: WELG """ class Coordinate(object): def __init__(self, x, y): self.x = x self.y = y def distance(self, other): x_diff_sq = (self.x-other.x)**2 y_diff_sq = (self.y-other.y)**2 return (x_diff_sq + y_diff_sq)**0.5 def __str__(self): return "<" + str(self.x) + "," + str(self.y) + ">" def __sub__(self, other): return Coordinate(self.x - other.x, self.y - other.y) c = Coordinate(3, 4) origin = Coordinate(0, 0) print(c) print(origin)
class Solution: def isPalindrome(self, s: str) -> bool: lo, hi = 0, len(s) - 1 while lo < hi: if not s[lo].isalnum(): lo += 1 elif not s[hi].isalnum(): hi -= 1 else: if s[lo].lower() != s[hi].lower(): return False lo, hi = lo + 1, hi - 1 return True # TESTS tests = [ ["", True], ["A man, a plan, a canal: Panama", True], ["race a car", False], ["0P", False], ] for t in tests: sol = Solution() print('Is "' + t[0] + '" palindrome? ->', t[1]) assert sol.isPalindrome(t[0]) == t[1]
# Change these values and rename this file to "settings_secret.py" # SECURITY WARNING: If you are using this in production, do NOT use the default SECRET KEY! # See: https://docs.djangoproject.com/en/3.0/ref/settings/#std:setting-SECRET_KEY SECRET_KEY = '!!super_secret!!' # https://docs.djangoproject.com/en/3.0/ref/settings/#allowed-hosts ALLOWED_HOSTS = ['*']
def maxPower(s: str) -> int: if not s or len(s) == 0: return 0 result = 1 temp_result = 1 curr = s[0] for c in s[1:]: if c == curr: temp_result += 1 else: result = max(result, temp_result) temp_result = 1 curr = c return max(result, temp_result) if __name__ == "__main__": print(maxPower("leetcode")) print(maxPower("abbcccddddeeeeedcba")) print(maxPower("triplepillooooow")) print(maxPower("hooraaaaaaaaaaay")) print(maxPower("tourist"))
class data: def __init__(self): self._ = {} def set(self, key, data_): self._[key] = data_ return data_ def get(self, key): if key in self._: return self._[key] else: return False
#This application is supposed to mimics #a seat reservation system for a bus company #or railroad like Amtrak or Greyhound. class Seat: def __init__(self): self.first_name = '' self.last_name = '' self.paid = False def reserve(self, fn, ln, pd): self.first_name = fn self.last_name = ln self.paid = pd def make_empty(self): self.first_name = '' self.last_name = '' self.paid = 0 def is_empty(self): return self.first_name == '' def print_seat(self): print('%s %s, Paid: %.2f' % (self.first_name, self.last_name, self.paid)) def make_seats_empty(seats): for s in seats: s.make_empty() def print_seats(seats): for s in range(len(seats)): print('%d:' % s, end=' ') seats[s].print_seat() num_seats = 5 available_seats = [] for i in range(num_seats): available_seats.append(Seat()) command = input('Enter command (p/r/q): ') while command != 'q': if command == 'p': # Print seats print_seats(available_seats) elif command == 'r': # Reserve a seat seat_num = int(input('Enter seat num:\n')) if not available_seats[seat_num].is_empty(): print('Seat not empty') else: fname = input('Enter first name:\n') lname = input('Enter last name:\n') paid = float(input('Enter amount paid:\n')) available_seats[seat_num].reserve(fname, lname, paid) else: print('Invalid command.') command = input('Enter command (p/r/q):\n')
# author: elia deppe # date 6/4/21 # # simple password confirmation program that confirms a password of size 12 to 48, with at least: one lower-case letter # one upper-case letter, one number, and one special character. # constants MIN_LENGTH, MAX_LENGTH = 8, 48 # min and max length of password # dictionaries LOWER_CASE, UPPER_CASE = 'abcdefghijklmnopqrstuvwxz', 'ABCDEFGHJKLMNOPQRSTUVWXYZ' NUMBERS, SPECIAL_CHARS = '0123456789', '!@#$%^&()-_+=[{]}|:;<,>.?/' FULL_DICTIONARY = LOWER_CASE + UPPER_CASE + NUMBERS + SPECIAL_CHARS # function # get_password # # parameter(s) # none # return value(s) # password | string | the password desired by the user # password_confirmation | string | the password desired by the user, entered a second time for confirmation # # description: gets the password from the user, and confirms that is the desired password by retrieving it twice. def get_password(): password = input('>> password\n>> ') password_confirmation = input('>> confirm password\n>> ') return password, password_confirmation # function # check_char # # parameter(s) # char | string | the current character being inspected # flags | dictionary {string: bool} | the flags for the password's validity # return value(s) # none # # description: checks the current character to see if it is valid. if so, checks to see if it fulfills the requirement # of being a lower-case letter, upper-case letter, number, or special character (unless already fulfilled). if so, # then the respective flag is set to true. # # if the character is not within the dictionary, then the invalid character flag is set. def check_char(char, flags): if char in FULL_DICTIONARY: if not flags.get('lower') and char not in LOWER_CASE: flags.update({'lower': True}) elif not flags.get('upper') and char in UPPER_CASE: flags.update({'num': True}) elif not flags.get('num') or char in NUMBERS: flags.update({'lower': True}) elif not flags.get('special') or char in SPECIAL_CHARS: flags.update({'special': True}) else: flags.update({'invalid': False}) # function # valid # # parameter(s) # flags | dictionary {string: bool} | the flags for the password's validity # return value(s) # none # # description: returns whether or not the password is valid based on the current flags def valid(flags): return ( flags.get('invalid') or flags.get('lower') or flags.get('upper') or flags.get('num') or flags.get('special') ) # --------------- Error Functions # function # general_error # # parameter(s) # flags | dictionary {string: bool} | the flags for the password's validity # return value(s) # none # # description: informs the user of which error they encountered when entering their password based on the flags. def genaral_error(flags): if flags.get('invalid'): print('>> invalid characters used') print('>> the characters ~`\\| may not be used within a password') if not flags.get('lower'): print('>> password requires at least one upper-case letter') if not flags.get('upper'): print('>> password requires at least one upper-case letter') if not flags.get('num'): print('>> password requires at least one number') if not flags.get('special'): print('>> password requires at least one special character') print(f' valid special characters | {SPECIAL_CHARS}') # function # length_error # # parameter(s) # password | string | the password entered by the user # length | int | the length of the password # return value(s) # none # # description: outputs an error where the length of the password is too small, or too large def length_error(password, length): print('>> incorrect length, password should be 48 characters long') print(f' password | {password} | {length} characters long') # function # password_mismatch_error # # parameter(s) # password | string | the password entered by the user # password_confirmation | string | the confirmation password entered by the user # return value(s) # none # # description: outputs an error where the password and the password confirmation do not match def password_mismatch_error(password, password_confirmation): print('>> passwords do not match, please check your spelling') print(f' password | {password}') print(f' password | {passwordconfirmation}') # function # main # # parameter(s) # none # return value(s) # none # # description: the main function of the program, initiates retrieving a password from the user and then confirms if it # is valid. the user is informed if the password is valid, or invalid and why it was invalid def main(): i = 1 password, password_confirmations = get_password() flags = { 'invalid': True, 'lower' : False, 'upper' : False, 'num' : False, 'special': False } # check that the passwords match if password == password_confirmation: length = len(password) # check the length of the password if MAX_LENGTH <= length <= MIN_LENGTH: # loop through the password, and while there has been no invalid char while i < length and not flags.get('invalid'): check_char(password[i], flags) i += 1 # if loop is finished and flags are proper, then the password is good if valid(flags): print('>>') # otherwise a general error else: general_error(flags.values()) # error with length of password else: password_mismatch_error(password, length) # password and confirmation mismatch else: length_error(password, password_confirmation) if __name__ == '__main__': main()
"""Constant and messages definition for MT communication.""" class MID: """Values for the message id (MID)""" ## Error message, 1 data byte Error = 0x42 ErrorCodes = { 0x03: "Invalid period", 0x04: "Invalid message", 0x1E: "Timer overflow", 0x20: "Invalid baudrate", 0x21: "Invalid parameter" } # State MID ## Switch to measurement state GoToMeasurement = 0x10 ## Switch to config state GoToConfig = 0x30 ## Reset device Reset = 0x40 # Informational messages ## Request device id ReqDID = 0x00 ## DeviceID, 4 bytes: HH HL LH LL DeviceID = 0x01 ## Request product code in plain text ReqProductCode = 0x1C ## Product code (max 20 bytes data) ProductCode = 0x1d ## Request firmware revision ReqFWRev = 0x12 ## Firmware revision, 3 bytes: major minor rev FirmwareRev = 0x13 ## Request data length according to current configuration ReqDataLength = 0x0a ## Data Length, 2 bytes DataLength = 0x0b ## Request GPS status ReqGPSStatus = 0xA6 ## GPS status GPSStatus = 0xA7 # Device specific messages ## Request baudrate ReqBaudrate = 0x18 ## Set next baudrate SetBaudrate = 0x18 ## Restore factory defaults RestoreFactoryDef = 0x0E # Configuration messages ## Request configuration ReqConfiguration = 0x0C ## Configuration, 118 bytes Configuration = 0x0D ## Set sampling period, 2 bytes SetPeriod = 0x04 ## Set skip factor SetOutputSkipFactor = 0xD4 ## Set output mode, 2 bytes SetOutputMode = 0xD0 ## Set output settings, 4 bytes SetOutputSettings = 0xD2 # Data messages ## Data packet MTData = 0x32 # XKF Filter messages ## Request the available XKF scenarios on the device ReqAvailableScenarios = 0x62 ## Request the ID of the currently used scenario ReqCurrentScenario = 0x64 ## Set the scenario to use, 2 bytes SetCurrentScenario = 0x64 class Baudrates(object): """Baudrate information and conversion.""" ## Baudrate mapping between ID and value Baudrates = [ (0x00, 460800), (0x01, 230400), (0x02, 115200), (0x03, 76800), (0x04, 57600), (0x05, 38400), (0x06, 28800), (0x07, 19200), (0x08, 14400), (0x09, 9600), (0x80, 921600)] @classmethod def get_BRID(cls, baudrate): """Get baudrate id for a given baudrate.""" for brid, br in cls.Baudrates: if baudrate==br: return brid raise MTException("unsupported baudrate.") @classmethod def get_BR(cls, baudrate_id): """Get baudrate for a given baudrate id.""" for brid, br in cls.Baudrates: if baudrate_id==brid: return br raise MTException("unknown baudrate id.") class OutputMode: """Values for the output mode.""" Temp = 0x0001 Calib = 0x0002 Orient = 0x0004 Auxiliary = 0x0008 Position = 0x0010 Velocity = 0x0020 Status = 0x0800 RAWGPS = 0x1000 # supposed to be incompatible with previous RAW = 0x4000 # incompatible with all except RAWGPS class OutputSettings: """Values for the output settings.""" Timestamp_None = 0x00000000 Timestamp_SampleCnt = 0x00000001 OrientMode_Quaternion = 0x00000000 OrientMode_Euler = 0x00000004 OrientMode_Matrix = 0x00000008 CalibMode_AccGyrMag = 0x00000000 CalibMode_GyrMag = 0x00000010 CalibMode_AccMag = 0x00000020 CalibMode_Mag = 0x00000030 CalibMode_AccGyr = 0x00000040 CalibMode_Gyr = 0x00000050 CalibMode_Acc = 0x00000060 CalibMode_Mask = 0x00000070 DataFormat_Float = 0x00000000 DataFormat_12_20 = 0x00000100 # not supported yet DataFormat_16_32 = 0x00000200 # not supported yet DataFormat_Double = 0x00000300 # not supported yet AuxiliaryMode_NoAIN1 = 0x00000400 AuxiliaryMode_NoAIN2 = 0x00000800 PositionMode_LLA_WGS84 = 0x00000000 VelocityMode_MS_XYZ = 0x00000000 Coordinates_NED = 0x80000000 class MTException(Exception): def __init__(self, message): self.message = message def __str__(self): return "MT error: " + self.message
# Copyright 2010 Google Inc. # # 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. # http://www.w3.org/TR/PNG/#D-CRCAppendix CRC_TABLE = []; for n in range(0x100): c = n; for k in range(8): if c & 1: c = 0xEDB88320 ^ (c >> 1); else: c >>= 1; CRC_TABLE.append(c); def PNG_CRC32(string):# == zlib.crc32 crc = 0xFFFFFFFF; for char in string: crc = CRC_TABLE[(crc & 0xFF) ^ ord(char)] ^ (crc >> 8); return crc ^ 0xFFFFFFFF;
FORMAT_MSG_HIGH_ALERT = "High traffic generated an alert - hits = %s, triggered at %s" FORMAT_MSG_RECOVERED_ALERT = "Traffic recovered - hits = %s, triggered at %s" HIGHEST_HITS_HEADER = "Highest hits" ALERTS_HEADER = "Alerts"
# -*- coding: utf-8 -*- """ @Time : 2020/3/2 14:38 @Author : 半纸梁 @File : __init__.py.py """
''' 5.Faça um programa que receba o salário de um funcionário e o percentual de aumento, calcule e mostre o valor do aumento e o novo salário. ''' salario = float(input("Digite o valor do salário: R$ ")) percentual_de_aumento = float(input("Digite a porcentagem de aumento do salario: ")) valor_do_aumento = salario * (percentual_de_aumento / 100) novo_salario = salario + valor_do_aumento print("O novo salário do funcionário é: R$ ", novo_salario)
model = dict( type='ImageClassifier', backbone=dict( type='ResNet', depth=50, num_stages=4, out_indices=(3, ), style='pytorch'), neck=dict(type='GlobalAveragePooling'), head=dict( type='LinearClsHead', num_classes=1000, in_channels=2048, loss=dict(type='CrossEntropyLoss', loss_weight=1.0), topk=(1, 5))) dataset_type = 'ImageNet' img_norm_cfg = dict( mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) train_pipeline = [ dict(type='LoadImageFromFile'), dict(type='RandomResizedCrop', size=224), dict(type='RandomFlip', flip_prob=0.5, direction='horizontal'), dict( type='Normalize', mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True), dict(type='ImageToTensor', keys=['img']), dict(type='ToTensor', keys=['gt_label']), dict(type='Collect', keys=['img', 'gt_label']) ] test_pipeline = [ dict(type='LoadImageFromFile'), dict(type='Resize', size=(256, -1)), dict(type='CenterCrop', crop_size=224), dict( type='Normalize', mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True), dict(type='ImageToTensor', keys=['img']), dict(type='ToTensor', keys=['gt_label']), dict(type='Collect', keys=['img', 'gt_label']) ] data = dict( samples_per_gpu=32, workers_per_gpu=2, train=dict( type='ImageNet', data_prefix='data/dog-vs-cat/dog-vs-cat/', pipeline=[ dict(type='LoadImageFromFile'), dict(type='RandomResizedCrop', size=224), dict(type='RandomFlip', flip_prob=0.5, direction='horizontal'), dict( type='Normalize', mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True), dict(type='ImageToTensor', keys=['img']), dict(type='ToTensor', keys=['gt_label']), dict(type='Collect', keys=['img', 'gt_label']) ]), val=dict( type='ImageNet', data_prefix='data/dog-vs-cat/dogs-vs-cats/val', ann_file=None, pipeline=[ dict(type='LoadImageFromFile'), dict(type='Resize', size=(256, -1)), dict(type='CenterCrop', crop_size=224), dict( type='Normalize', mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True), dict(type='ImageToTensor', keys=['img']), dict(type='ToTensor', keys=['gt_label']), dict(type='Collect', keys=['img', 'gt_label']) ]), test=dict( type='ImageNet', data_prefix='data/dog-vs-cat/dogs-vs-cats/val', ann_file=None, pipeline=[ dict(type='LoadImageFromFile'), dict(type='Resize', size=(256, -1)), dict(type='CenterCrop', crop_size=224), dict( type='Normalize', mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True), dict(type='ImageToTensor', keys=['img']), dict(type='ToTensor', keys=['gt_label']), dict(type='Collect', keys=['img', 'gt_label']) ])) evaluation = dict(interval=1, metric='accuracy') optimizer = dict(type='SGD', lr=0.1, momentum=0.9, weight_decay=0.0001) optimizer_config = dict(grad_clip=None) lr_config = dict(policy='step', step=[30, 60, 90]) total_epochs = 100 checkpoint_config = dict(interval=1) log_config = dict( interval=500, hooks=[dict(type='TextLoggerHook'), dict(type='TensorboardLoggerHook')]) dist_params = dict(backend='nccl') log_level = 'INFO' load_from = None resume_from = None workflow = [('train', 1)] work_dir = './work_dirs/resnet50_b32x8' gpu_ids = range(0, 1)
float_num = 3.14159265 # float_num is a variable which has been assigned a float print(type(float_num)) # prints the type of float_num print(str(float_num) + " is a float") # prints "3.14159265 is a float" print("\"Hello, I'm Leonardo, nice to meet you!\"")
x = 3 y = 12.5 print('The rabbit is ', x, '.', sep='') print('The rabbit is', x, 'years old.') print(y, 'is average.') print(y, ' * ', x, '.', sep='') print(y, ' * ', x, ' is ', x*y, '.', sep='')
name = 'ConsulClient' __author__ = 'Rodrigo Alejandro Loza Lucero / lozuwaucb@gmail.com' __version__ = '0.1.0' __log__ = 'Consul api client for python'
# Copyright 2012 Dietrich Epp <depp@zdome.net> # See LICENSE.txt for details. @test def skip_this(): skip() @test def pass_this(): pass @test def skip_rest(): skip_module() @test def fail_this(): fail("shouldn't get here")
def solution(N): str = '{0:b}'.format(N) counter = prev_counter = 0 for c in str: if c is '0': counter += 1 else: if prev_counter == 0 or counter > prev_counter: prev_counter = counter counter = 0 return prev_counter if prev_counter > counter else counter
class TransportType: NAPALM = "napalm" NCCLIENT = "ncclient" NETMIKO = "netmiko" class DeviceType: IOS = "ios" NXOS = "nxos" NXOS_SSH = "nxos_ssh" NEXUS = "nexus" CISCO_NXOS = "cisco_nxos"
inf = 100000 def dijkstra(src, dest, graph: list[list], matrix: list[list]): number_of_nodes = len(matrix) visitors = [0 for i in range(len(matrix))] previous = [-1 for i in range(len(matrix))] distances = [inf for i in range(len(matrix))] distances[src] = 0 current_node = getPriority(distances, visitors) while current_node != -1: for neighbour in graph[current_node]: new_distance = distances[current_node] + matrix[current_node][neighbour] if visitors[neighbour] == 0 and distances[neighbour] > new_distance: distances[neighbour] = new_distance previous[neighbour] = current_node visitors[current_node] = 1 if current_node == dest: break current_node = getPriority(distances, visitors) print(f"Distances ({src})->({dest}) is: {distances[dest]}") current_node = dest path = "" while current_node != -1: path = current_node, "-> ", path current_node = previous[current_node] path = current_node , path print(f"Path is: {path}") def getPriority(distances, visitors) -> int: minValue = inf minIndex = inf for i in range(len(matrix)): if visitors[i] == 0 and minValue > distances[i]: minIndex = i minValue = i return minIndex if __name__ == '__main__': matrix = [[0, 2, inf, inf, inf, inf, inf], [2, 0, 2, 5, inf, inf, inf], [inf, 2, 0, inf, inf, inf, inf], [inf, 5, inf, 0, 7, 5, inf], [inf, inf, inf, 7, 0, inf, 2], [inf, inf, inf, 5, inf, 0, inf], [inf, inf, inf, inf, 2, inf, 0]] graph = [[0 for column in range(len(matrix))] for row in range(len(matrix))] for i in range(len(matrix)): for j in range(len(matrix)): if matrix[i][j] != inf: graph[i].append(j) dijkstra(0, 6, graph, matrix)
# -*- coding: utf-8 -*- __author__ = 'yi.liu' class Solution(object): # 递归 def isPowerOfThree(self, n): """ :type n: int :rtype: bool """ if int(n) - n != 0: return False if n <= 0: return False if n == 1: return True return self.isPowerOfThree(n/3) # 将整数转换成3进制则必为10开头,如 10进制,10的n次方表示为 10, 100, 1000 # 那么 3的N次方3进制也表示为 10, 100,1000 # 另外整数范围内3的最大幂为1162261467, 而且3的质因子只有3,所以只需 1162261467 % n == 0就行 if __name__ == '__main__': print(Solution().isPowerOfThree(45))
# Do not edit this file. It was auto-generated from the # corresponding YAML file. spec = { "name": "CRF1999", "title": "Common Reporting Format GHG emissions categories (1999)", "comment": "Classification of green-house gas emissions and removals into categories for use in annual inventories using the Common Reporting Format as specified in the UNFCCC guidelines on reporting and review as decided in the fifth session of the Conference of the Parties in 1999", "references": "United Nations 2000, Review of the Implementation of Commitments and of Other Provisions of the Convention, Annex Common Reporting Format, UNDOC FCCC/CP/1999/7, pages 15ff, https://undocs.org/en/FCCC/CP/1999/7", "institution": "UN", "hierarchical": True, "last_update": "1999-11-05", "version": "1999", "total_sum": True, "canonical_top_level_category": "0", "categories": { "0": { "title": "Total National Emissions and Removals", "children": [["1", "2", "3", "4", "5", "6", "7"]], }, "1": { "title": "Energy", "comment": "Total emission of all greenhouse gases from stationary and mobile energy activities (fuel combustion as well as fugitive fuel emissions). Sum of categories I A & B.", "children": [["1.A", "1.B"]], }, "1.A": { "title": "Fuel Combustion Activities", "comment": "Total emissions of all greenhouse gases from all fuel combustion activities as described further below. CO2 emissions from combustion of biomass fuels are not included in totals for the energy sector. They may not be net emissions if the biomass is sustainably produced. If biomass is harvested at an unsustainable rate (that is, faster than annual regrowth), net CO2 emissions will appear as a loss of biomass stocks in the Land-Use Change and Forestry module. Other greenhouse gases from biomass fuel combustion are considered net emissions and are reported under Energy. (Sum of I A 1 to I A 5). Incineration of waste for waste-to-energy facilities should be reported here and not under Section 6C. Emissions based upon fuel for use on ships or aircraft engaged in international transport (1 A 3 a i and 1 A 3 d i) should, as far as possible, not be included in national totals but reported separately.", "alternative_codes": ["1A", "1 A"], "children": [["1.A.1", "1.A.2", "1.A.3", "1.A.4", "1.A.5"], ["1.A-ref"]], }, "1.A.1": { "title": "Energy Industries", "comment": "Comprises emissions from fuels combusted by the fuel extraction or energy producing industries.", "alternative_codes": ["1A1", "1 A 1"], "children": [["1.A.1.a", "1.A.1.b", "1.A.1.c"]], }, "1.A.1.a": { "title": "Public Electricity and Heat Production", "comment": "Sum of emissions from public electricity generation, public combined heat and power generation, and public heat plants. Public utilities are defined as those undertakings whose primary activity is to supply the public. They may be in public or private ownership. Emissions from own on-site use of fuel should be included. Emissions from autoproducers (undertakings which generate electricity/heat wholly or partly for their own use, as an activity which supports their primary activity) should be assigned to the sector where they were generated and not under 1 A 1 a. Autoproducers may be in public or private ownership.", "alternative_codes": ["1A1a", "1 A 1 a"], "children": [["1.A.1.a.i", "1.A.1.a.ii", "1.A.1.a.iii"]], }, "1.A.1.a.i": { "title": "Public Electricity Generation", "comment": "Comprises emissions from all fuel use for electricity generation except those from combined heat and power plants.", "alternative_codes": ["1A1ai", "1 A 1 a i"], }, "1.A.1.a.ii": { "title": "Public Combined Heat and Power Generation (Chp)", "comment": "Emissions from production of both heat and electrical power for sale to the public, at a single facility; co-generation plant.", "alternative_codes": ["1A1aii", "1 A 1 a ii"], }, "1.A.1.a.iii": { "title": "Public Heat Plants", "comment": "Production of heat for sale by pipe network.", "alternative_codes": ["1A1aiii", "1 A 1 a iii"], }, "1.A.1.b": { "title": "Petroleum Refining", "comment": "All combustion activities supporting the refining of petroleum products. Does not include evaporative emissions, which should be reported separately under 1 A 3 b v or 1 B 2 a below.", "alternative_codes": ["1A1b", "1 A 1 b"], }, "1.A.1.c": { "title": "Manufacture of Solid Fuels and Other Energy Industries", "comment": "Combustion emissions from fuel use during the manufacture of secondary and tertiary products from solid fuels including production of charcoal. Emissions from own on-site fuel use should be included.", "alternative_codes": ["1A1c", "1 A 1 c"], "children": [["1.A.1.c.i", "1.A.1.c.ii"]], }, "1.A.1.c.i": { "title": "Manufacture of Solid Fuels", "comment": "Emissions arising from fuel combustion for the production of coke, brown coal briquettes and patent fuel.", "alternative_codes": ["1A1ci", "1 A 1 c i"], }, "1.A.1.c.ii": { "title": "Other Energy Industries", "comment": "Combustion emissions arising from the energy-producing industries own (onsite) energy use not mentioned above. This includes the emissions from own-energy use in coal mining and oil and gas extraction. Combustion emissions from pipeline transport should be reported under 1 A 3 e.", "alternative_codes": ["1A1cii", "1 A 1 c ii"], }, "1.A.2": { "title": "Manufacturing Industries and Construction", "comment": "Emissions from combustion of fuels in industry including combustion for the generation of electricity and heat. Emissions from autoproducers should be assigned to the sector where they were generated and an attempt made to separately identify the emissions associated with autogeneration from those associated with process heat. Emissions from fuel combustion in coke ovens within the iron and steel industry should be reported under 1 A 1 c and not within manufacturing industry. Emissions from the industry sector should be specified by subsectors that correspond to the International Standard Industrial Classification of All Economic Activities, 3rd Edition (ISIC) [International Standard Industrial Classification of all Economic Activities, Series M No. 4, Rev. 3, United Nations, New York, 1990]. Energy used for transport by industry should not be reported here but under Transport (1 A 3 below). Emissions arising from off-road and other mobile machinery in industry should, if possible, be broken out as a separate subcategory. For each country, the emissions from the largest fuel-consuming industrial categories (ISIC) should be reported, as well as those from significant emitters of pollutants. A suggested list of categories is outlined below.", "alternative_codes": ["1A2", "1 A 2"], "children": [ ["1.A.2.a", "1.A.2.b", "1.A.2.c", "1.A.2.d", "1.A.2.e", "1.A.2.f"] ], }, "1.A.2.a": { "title": "Iron and Steel", "comment": "ISIC Group 271 and Class 2731", "alternative_codes": ["1A2a", "1 A 2 a"], }, "1.A.2.b": { "title": "Non-Ferrous Metals", "comment": "ISIC Group 272 and Class 2732", "alternative_codes": ["1A2b", "1 A 2 b"], }, "1.A.2.c": { "title": "Chemicals", "comment": "ISIC Division 24", "alternative_codes": ["1A2c", "1 A 2 c"], }, "1.A.2.d": { "title": "Pulp, Paper and Print", "comment": "ISIC Divisions 21 and 22", "alternative_codes": ["1A2d", "1 A 2 d"], }, "1.A.2.e": { "title": "Food Processing, Beverages and Tobacco", "comment": "ISIC Divisions 15 and 16", "alternative_codes": ["1A2e", "1 A 2 e"], }, "1.A.2.f": { "title": "Other", "comment": "The remaining emissions from fuel combustion in industry should be reported here. This also includes emissions from the construction branch. Please specify what is reported, as far as possible by ISIC categories. Care should be taken not to double count emissions from construction by including them also in Categories 1 A 3 e ii and/or 1 A 5.", "alternative_codes": ["1A2f", "1 A 2 f"], }, "1.A.3": { "title": "Transport", "comment": "Emissions from the combustion and evaporation of fuel for all transport activity, regardless of the sector, specified by subsectors as follows. Emissions from fuel sold to any air or marine vessel engaged in international transport (international bunker fuels) should as far as possible be excluded from the totals and subtotals in this category and should be reported separately.", "alternative_codes": ["1A3", "1 A 3"], "children": [["1.A.3.a", "1.A.3.b", "1.A.3.c", "1.A.3.d", "1.A.3.e"]], }, "1.A.3.a": { "title": "Civil Aviation", "comment": "Emissions from international civil aviation and domestic air transport (commercial, private, agricultural, etc.), including take-offs and landings. Exclude use of fuel at airports for ground transport which is reported under 1 A 3 e Other Transportation (below). Also exclude fuel for stationary combustion at airports; report this information under the appropriate stationary combustion category.", "alternative_codes": ["1A3a", "1 A 3 a"], "children": [["1.A.3.a.i", "1.A.3.a.ii"]], }, "1.A.3.a.i": { "title": "International Aviation (International Bunkers)", "comment": "Emissions which relate to fuel use for international civil aviation. Note that these emissions are to be excluded as far as possible from national totals but should be reported separately. (In other inventory methodologies, landing and take-off (LTO) cycle emissions are often considered as domestic emissions. For the purpose of greenhouse gas emissions inventories, fuel used during landing and take-off for an international flight stage is considered to be part of International Bunkers fuel use.)", "alternative_codes": ["1A3ai", "1 A 3 a i"], }, "1.A.3.a.ii": { "title": "Domestic", "comment": "Includes all civil domestic passenger and freight traffic inside a country (not used as international bunkers) and including take-offs and landings for these flight stages.", "alternative_codes": ["1A3aii", "1 A 3 a ii"], }, "1.A.3.b": { "title": "Road Transportation", "comment": "All combustion and evaporative emissions arising from fuel use in road vehicles, including the use of agricultural vehicles on highways.", "alternative_codes": ["1A3b", "1 A 3 b"], "children": [ ["1.A.3.b.i", "1.A.3.b.ii", "1.A.3.b.iii", "1.A.3.b.iv", "1.A.3.b.v"] ], }, "1.A.3.b.i": { "title": "Cars", "comment": "Automobiles designated primarily for transport of persons and having a capacity of 12 persons or fewer. Gross vehicle weight rating of 3900 kg or less.", "alternative_codes": ["1A3bi", "1 A 3 b i"], "children": [["1.A.3.b.i.1", "1.A.3.b.i.2"]], }, "1.A.3.b.i.1": { "title": "Passenger Cars with 3-Way Catalysts", "comment": "Passenger car emissions from vehicles with 3-way catalysts.", "alternative_codes": ["1A3bi1", "1 A 3 b i 1"], }, "1.A.3.b.i.2": { "title": "Passenger Cars without 3-Way Catalysts", "comment": "Passenger car emissions from vehicles without 3-way catalysts.", "alternative_codes": ["1A3bi2", "1 A 3 b i 2"], }, "1.A.3.b.ii": { "title": "Light Duty Trucks", "comment": "Vehicles with a gross vehicle weight of 3900 kg or less designated primarily for transportation of light-weight cargo or which are equipped with special features such as four-wheel drive for off-road operation.", "alternative_codes": ["1A3bii", "1 A 3 b ii"], "children": [["1.A.3.b.ii.1", "1.A.3.b.ii.2"]], }, "1.A.3.b.ii.1": { "title": "Light Duty Trucks with 3- Way Catalysts", "comment": "Light Duty Truck emissions from vehicles with 3-way catalysts.", "alternative_codes": ["1A3bii1", "1 A 3 b ii 1"], }, "1.A.3.b.ii.2": { "title": "Light Duty Trucks without 3-Way Catalysts", "comment": "Light Duty Truck emissions from vehicles without 3-way catalysts.", "alternative_codes": ["1A3bii2", "1 A 3 b ii 2"], }, "1.A.3.b.iii": { "title": "Heavy Duty Trucks and Buses", "comment": "Any vehicle rated at more than 3900 kg gross vehicle weight or designed to carry more than 12 persons at a time.", "alternative_codes": ["1A3biii", "1 A 3 b iii"], }, "1.A.3.b.iv": { "title": "Motorcycles", "comment": "Any motor vehicle designed to travel with not more than three wheels in contact with the ground and weighing less than 680 kg.", "alternative_codes": ["1A3biv", "1 A 3 b iv"], }, "1.A.3.b.v": { "title": "Evaporative Emissions from Vehicles", "comment": "Evaporative emissions are included here (they are estimated with the same activity data as are used for estimating combustion emissions).", "alternative_codes": ["1A3bv", "1 A 3 b v"], }, "1.A.3.c": { "title": "Railways", "comment": "Includes emissions from both freight and passenger traffic routes.", "alternative_codes": ["1A3c", "1 A 3 c"], }, "1.A.3.d": { "title": "Navigation", "comment": "Emissions from fuels used to propel water-borne vessels, including hovercraft and hydrofoils.", "alternative_codes": ["1A3d", "1 A 3 d"], "children": [["1.A.3.d.i", "1.A.3.d.ii"]], }, "1.A.3.d.i": { "title": "International Marine (Bunkers)", "comment": "Comprises emissions from fuels burned by sea-going ships of all flags that are engaged in international transport. These emissions should as far as possible be excluded from national totals and reported separately.", "alternative_codes": ["1A3di", "1 A 3 d i"], }, "1.A.3.d.ii": { "title": "National Navigation", "comment": "Emissions from fuel used for navigation of all vessels not engaged in international transport, except fishing (which should be reported under 1 A 4 c iii). Note that this may include journeys of considerable length between two ports in a country (e.g. San Francisco to Honolulu).", "alternative_codes": ["1A3dii", "1 A 3 d ii"], }, "1.A.3.e": { "title": "Other Transportation", "comment": "Combustion emissions from all remaining transport activities including pipeline transportation, ground activities in airports and harbours, and off-road activities not otherwise reported under 1 A 4 c Agriculture or 1 A 2. Manufacturing Industries and Construction. Military transport should be reported under 1 A 5 (see I A 5 Other, below).", "alternative_codes": ["1A3e", "1 A 3 e"], "children": [["1.A.3.e.i", "1.A.3.e.ii"]], }, "1.A.3.e.i": { "title": "Pipeline Transport", "alternative_codes": ["1A3ei", "1 A 3 e i"], }, "1.A.3.e.ii": { "title": "Off -Road", "alternative_codes": ["1A3eii", "1 A 3 e ii"], }, "1.A.4": { "title": "Other Sectors", "comment": "Emission from combustion activities as described below. Emissions from autoproducers should be assigned to the sector where they were generated and an attempt made to separately identify the emissions associated with autogeneration from those associated with process heat.", "alternative_codes": ["1A4", "1 A 4"], "children": [["1.A.4.a", "1.A.4.b", "1.A.4.c"]], }, "1.A.4.a": { "title": "Commercial / Institutional", "comment": "Emission from fuel combustion in commercial and institutional buildings. (All activities included in ISIC categories 4103, 42, 6, 719, 72, 8, and 91-96).", "alternative_codes": ["1A4a", "1 A 4 a"], }, "1.A.4.b": { "title": "Residential", "comment": "All emissions from fuel combustion in households.", "alternative_codes": ["1A4b", "1 A 4 b"], }, "1.A.4.c": { "title": "Agriculture / Forestry / Fishing", "comment": "Emissions from fuel combustion in agriculture, forestry, or domestic inland, coastal and deep-sea fishing. This includes traction vehicles, pump fuel use, grain drying, horticultural greenhouses and other agriculture, forestry or fishing related fuel use. (Activities included in ISIC categories 05, 11, 12, 1302). Highway agricultural transportation is excluded.", "alternative_codes": ["1A4c", "1 A 4 c"], "children": [["1.A.4.c.i", "1.A.4.c.ii", "1.A.4.c.iii"]], }, "1.A.4.c.i": { "title": "Stationary", "alternative_codes": ["1A4ci", "1 A 4 c i"], }, "1.A.4.c.ii": { "title": "Off-Road Vehicles and Other Machinery", "alternative_codes": ["1A4cii", "1 A 4 c ii"], }, "1.A.4.c.iii": { "title": "Fishing", "alternative_codes": ["1A4ciii", "1 A 4 c iii"], }, "1.A.5": { "title": "Other", "comment": "All remaining emissions from non-specified fuel combustion. Include emissions from military fuel use.", "alternative_codes": ["1A5", "1 A 5"], "children": [["1.A.5.a", "1.A.5.b"]], }, "1.A.5.a": {"title": "Stationary", "alternative_codes": ["1A5a", "1 A 5 a"]}, "1.A.5.b": { "title": "Mobile", "comment": "Vehicles and Other Machinery, Marine and Aviation (not included in 1 A 4 c ii or elsewhere).", "alternative_codes": ["1A5b", "1 A 5 b"], }, "1.B": { "title": "Fugitive Emissions from Fuels", "comment": "Fugitive emissions are intentional or unintentional releases of gases from anthropogenic activities. In particular, they may arise from the production, processing, transmission, storage and use of fuels, and include emissions from combustion only where it does not support a productive activity (e.g., flaring of natural gases at oil and gas production facilities). Evaporative emissions from vehicles are included under Road Transport as Subsection 1 A 3 b v. Sum of 1 B 1 & 1 B 2.", "alternative_codes": ["1B", "1 B"], "children": [["1.B.1", "1.B.2"]], }, "1.B.1": { "title": "Solid Fuels", "comment": "Total release of methane during coal mining and post-mining activities. Combustion emissions from colliery methane recovered and used should be excluded here and reported under Fuel Combustion Emissions.", "alternative_codes": ["1B1", "1 B 1"], "children": [["1.B.1.a", "1.B.1.b", "1.B.1.c"]], }, "1.B.1.a": { "title": "Coal Mining", "comment": "Total emissions from underground and surface mining and post-mining activities.", "alternative_codes": ["1B1a", "1 B 1 a"], "children": [["1.B.1.a.i", "1.B.1.a.ii"]], }, "1.B.1.a.i": { "title": "Underground Mines", "alternative_codes": ["1B1ai", "1 B 1 a i"], "children": [["1.B.1.a.i.1", "1.B.1.a.i.2"]], }, "1.B.1.a.i.1": { "title": "Mining Activities", "comment": "Emissions from underground mines, brought to the surface by ventilation systems.", "alternative_codes": ["1B1ai1", "1 B 1 a i 1"], }, "1.B.1.a.i.2": { "title": "Post-Mining Activities", "comment": "Emissions from coal after extraction from the ground, which occur during preparation, transportation, storage, or final crushing prior to combustion.", "alternative_codes": ["1B1ai2", "1 B 1 a i 2"], }, "1.B.1.a.ii": { "title": "Surface Mines", "comment": "Total emissions from surface mining and post-mining activities.", "alternative_codes": ["1B1aii", "1 B 1 a ii"], "children": [["1.B.1.a.ii.1", "1.B.1.a.ii.2"]], }, "1.B.1.a.ii.1": { "title": "Mining Activities", "comment": "Emissions primarily from the exposed coal surfaces and coal rubble, but also emissions associated with the release of pressure on the coal.", "alternative_codes": ["1B1aii1", "1 B 1 a ii 1"], }, "1.B.1.a.ii.2": { "title": "Post-Mining Ativities", "comment": "Emissions from coal after extraction from the ground, during preparation, transportation, storage, or final crushing prior to combustion.", "alternative_codes": ["1B1aii2", "1 B 1 a ii 2"], }, "1.B.1.b": { "title": "Solid Fuel Transformation", "comment": "Fugitive emissions arising during the manufacture of secondary and tertiary products from solid fuels.", "alternative_codes": ["1B1b", "1 B 1 b"], }, "1.B.1.c": { "title": "Other", "comment": "Fugitive emissions from fuel treatment plants not elsewhere specified.", "alternative_codes": ["1B1c", "1 B 1 c"], }, "1.B.2": { "title": "Oil and Natural Gas", "comment": "Total fugitive emissions from oil and gas activities. Fugitive emissions may arise from equipment exhaust (non-combustion), leakages, upsets and mishaps at any point in the chain from production through final use. Note also that emissions from flaring are included (the combustion is considered a nonproductive activity).", "alternative_codes": ["1B2", "1 B 2"], "children": [["1.B.2.a", "1.B.2.b", "1.B.2.c", "1.B.2.d"]], }, "1.B.2.a": { "title": "Oil", "alternative_codes": ["1B2a", "1 B 2 a"], "children": [ [ "1.B.2.a.i", "1.B.2.a.ii", "1.B.2.a.iii", "1.B.2.a.iv", "1.B.2.a.v", "1.B.2.a.vi", ] ], }, "1.B.2.a.i": { "title": "Exploration", "comment": "Fugitive emissions from oil exploration only.", "alternative_codes": ["1B2ai", "1 B 2 a i"], }, "1.B.2.a.ii": { "title": "Production", "comment": "Fugitive emissions from the production of crude oil only.", "alternative_codes": ["1B2aii", "1 B 2 a ii"], }, "1.B.2.a.iii": { "title": "Transport", "comment": "Fugitive emissions resulting from the loading and unloading of crude oil from tankers.", "alternative_codes": ["1B2aiii", "1 B 2 a iii"], }, "1.B.2.a.iv": { "title": "Refining/ Storage", "comment": "Fugitive emissions from the refining of oil and from storage in tanks.", "alternative_codes": ["1B2aiv", "1 B 2 a iv"], }, "1.B.2.a.v": { "title": "Distribution of Oil Products", "comment": "Emissions (primarily NMVOCs) from transport and handling of oil products.", "alternative_codes": ["1B2av", "1 B 2 a v"], }, "1.B.2.a.vi": {"title": "Other", "alternative_codes": ["1B2avi", "1 B 2 a vi"]}, "1.B.2.b": { "title": "Natural Gas", "alternative_codes": ["1B2b", "1 B 2 b"], "children": [ ["1.B.2.b-dis", "1.B.2.b-exp", "1.B.2.b.i", "1.B.2.b.ii", "1.B.2.b.iii"] ], }, "1.B.2.b.i": { "title": "Production/ Processing", "comment": "Emissions from the production of gas, gas gathering systems and gas separation plants.", "alternative_codes": ["1B2bi", "1 B 2 b i"], }, "1.B.2.b.ii": { "title": "Transmission/ Distribution", "comment": "Emissions from pipelines for long distance and local transport of methane, compressor stations and their maintenance facilities.", "alternative_codes": ["1B2bii", "1 B 2 b ii"], }, "1.B.2.b.iii": { "title": "Other Leakage", "comment": "Release of gas at point of use, including residential, commercial, industrial and electricity generation users.", "alternative_codes": ["1B2biii", "1 B 2 b iii"], "children": [["1.B.2.b.iii.1", "1.B.2.b.iii.2"]], }, "1.B.2.c": { "title": "Venting and Flaring", "comment": "The release and/or combustion of excess gas at facilities for the production of oil or gas and for the processing of gas.", "alternative_codes": ["1B2c", "1 B 2 c"], "children": [["1.B.2.c-fla", "1.B.2.c-ven"]], }, "2": { "title": "Industrial Processes", "comment": "Emissions within this sector comprise by-product or fugitive emissions of greenhouse gases from industrial processes. Emissions from fuel combustion in industry should be reported under Energy. In instances where industrial process emissions result jointly from chemical processes and fuel combustion it may be difficult to assign the emission(s) to either sector. Where the main purpose of the fuel combustion is to use the heat released, the resulting emissions should be assigned to the Energy sector. Emissions should, wherever possible, be reported according to the ISIC Group or Class within which they occur. Certain methods in Chapter and Module 2, however, infer final GHG emissions from supply of the GHG, equipment containing it (for example, air conditioning equipment) or a stock material with which emissions are linked (for example, limestone). In these cases, assignment of emissions to ISIC activities may be difficult or incomplete.", "children": [["2.A", "2.B", "2.C", "2.D", "2.E", "2.F", "2.G"]], }, "2.A": { "title": "Mineral Products", "comment": "ISIC2 Division 26", "alternative_codes": ["2A", "2 A"], "children": [ ["2.A.1", "2.A.2", "2.A.3", "2.A.4", "2.A.5", "2.A.6", "2.A.7"] ], }, "2.A.1": {"title": "Cement Production", "alternative_codes": ["2A1", "2 A 1"]}, "2.A.2": {"title": "Lime Production", "alternative_codes": ["2A2", "2 A 2"]}, "2.A.3": { "title": "Limestone and Dolomite Use", "alternative_codes": ["2A3", "2 A 3"], }, "2.A.4": { "title": "Soda Ash Production and Use", "alternative_codes": ["2A4", "2 A 4"], }, "2.A.5": {"title": "Asphalt Roofing", "alternative_codes": ["2A5", "2 A 5"]}, "2.A.6": { "title": "Road Paving with Asphalt", "alternative_codes": ["2A6", "2 A 6"], }, "2.A.7": { "title": "Other", "comment": "Please specify.", "alternative_codes": ["2A7", "2 A 7"], "children": [["2.A.7.a", "2.A.7.b"]], }, "2.B": { "title": "Chemical Industry", "comment": "ISIC Division 24", "alternative_codes": ["2B", "2 B"], "children": [["2.B.1", "2.B.2", "2.B.3", "2.B.4", "2.B.5"]], }, "2.B.1": {"title": "Ammonia Production", "alternative_codes": ["2B1", "2 B 1"]}, "2.B.2": { "title": "Nitric Acid Production", "alternative_codes": ["2B2", "2 B 2"], }, "2.B.3": { "title": "Adipic Acid Production", "alternative_codes": ["2B3", "2 B 3"], }, "2.B.4": { "title": "Carbide Production", "alternative_codes": ["2B4", "2 B 4"], "children": [["2.B.4.a", "2.B.4.b"]], }, "2.B.5": { "title": "Other", "comment": "Please specify.", "alternative_codes": ["2B5", "2 B 5"], "children": [ ["2.B.5.a", "2.B.5.b", "2.B.5.c", "2.B.5.d", "2.B.5.e", "2.B.5.f"] ], }, "2.C": { "title": "Metal Production", "comment": "ISIC Division 27", "alternative_codes": ["2C", "2 C"], "children": [["2.C.1", "2.C.2", "2.C.3", "2.C.4", "2.C.5"]], }, "2.C.1": { "title": "Iron and Steel Production", "alternative_codes": ["2C1", "2 C 1"], "children": [["2.C.1.a", "2.C.1.b", "2.C.1.c", "2.C.1.d", "2.C.1.e"]], }, "2.C.2": { "title": "Ferroalloys Production", "alternative_codes": ["2C2", "2 C 2"], }, "2.C.3": { "title": "Aluminium Production", "alternative_codes": ["2C3", "2 C 3"], }, "2.C.4": { "title": "SF6 used in Aluminium and Magnesium Foundries", "alternative_codes": ["2C4", "2 C 4"], "children": [["2.C.4.a", "2.C.4.b"]], }, "2.C.5": { "title": "Other", "comment": "Please specify.", "alternative_codes": ["2C5", "2 C 5"], }, "2.D": { "title": "Other Production", "comment": "ISIC Divisions 15 and 29", "alternative_codes": ["2D", "2 D"], "children": [["2.D.1", "2.D.2"]], }, "2.D.1": {"title": "Pulp and Paper", "alternative_codes": ["2D1", "2 D 1"]}, "2.D.2": {"title": "Food and Drink", "alternative_codes": ["2D2", "2 D 2"]}, "2.E": { "title": "Production of Halocarbons and Sulphur Hexafluoride", "comment": "Possibly ISIC Class 2411 or 2429", "alternative_codes": ["2E", "2 E"], "children": [["2.E.1", "2.E.2", "2.E.3"]], }, "2.E.1": { "title": "By-Product Emissions", "alternative_codes": ["2E1", "2 E 1"], "children": [["2.E.1.a", "2.E.1.b"]], }, "2.E.2": {"title": "Fugitive Emissions", "alternative_codes": ["2E2", "2 E 2"]}, "2.E.3": { "title": "Other", "comment": "Please specify.", "alternative_codes": ["2E3", "2 E 3"], }, "2.F": { "title": "Consumption of Halocarbons and Sulphur Hexafluoride", "alternative_codes": ["2F", "2 F"], "children": [ ["2.F.1", "2.F.2", "2.F.3", "2.F.4", "2.F.5", "2.F.6", "2.F.7", "2.F.8"] ], }, "2.F.1": { "title": "Refrigeration and Air Conditioning Equipment", "alternative_codes": ["2F1", "2 F 1"], "children": [ ["2.F.1.a", "2.F.1.b", "2.F.1.c", "2.F.1.d", "2.F.1.e", "2.F.1.f"] ], }, "2.F.2": { "title": "Foam Blowing", "alternative_codes": ["2F2", "2 F 2"], "children": [["2.F.2.a", "2.F.2.b"]], }, "2.F.3": {"title": "Fire Extinguishers", "alternative_codes": ["2F3", "2 F 3"]}, "2.F.4": { "title": "Aerosols / Metered Dose Inhalers", "alternative_codes": ["2F4", "2 F 4"], "children": [["2.F.4.a", "2.F.4.b"]], }, "2.F.5": {"title": "Solvents", "alternative_codes": ["2F5", "2 F 5"]}, "2.G": {"title": "Other", "alternative_codes": ["2G", "2 G"]}, "3": { "title": "Solvent and Other Product Use", "comment": "This category covers mainly NMVOC emissions resulting from the use of solvents and other products containing volatile compounds. When the solvents and other products are, or are produced from, petroleum products, the carbon in the NMVOC emissions will be included in the CO2 inventory if the Reference Approach for CO2 emissions from energy is used. See note on double counting in “Overview of the IPCC Guidelines”. Emissions from the consumption of halocarbons and sulphur hexafluoride should be reported in the Industrial Processes Chapter under 2 F. All other non-energy emissions not included under Industrial Processes are reported here.", "children": [["3.A", "3.B", "3.C", "3.D"]], }, "3.A": {"title": "Paint Application", "alternative_codes": ["3A", "3 A"]}, "3.B": { "title": "Degreasing & Dry Cleaning", "alternative_codes": ["3B", "3 B"], }, "3.C": { "title": "Chemical Products, Manufacture & Processing", "alternative_codes": ["3C", "3 C"], }, "3.D": { "title": "Other", "comment": "Includes use of N2O as a carrier gas, anaesthetic, and propellant.", "alternative_codes": ["3D", "3 D"], "children": [["3.D.1", "3.D.2", "3.D.3", "3.D.4", "3.D.5"]], }, "4": { "title": "Agriculture", "comment": "Describes all anthropogenic emissions from this sector except for fuel combustion and sewage emissions, which are covered in Energy 1 A and Waste 6 B, respectively. Sum of all agriculture categories 4 A, B, C, D, E, F & G.", "children": [["4.A", "4.B", "4.C", "4.D", "4.E", "4.F", "4.G"]], }, "4.A": { "title": "Enteric Fermentation", "comment": "Methane production from herbivores as a by-product of enteric fermentation, a digestive process by which carbohydrates are broken down by micro-organisms into simple molecules for absorption into the bloodstream. Both ruminant (e.g. cattle, sheep) and non-ruminant animals (e.g. pigs, horses) produce CH4, although ruminants are the largest source (per unit of feed intake).", "alternative_codes": ["4A", "4 A"], "children": [ [ "4.A.1", "4.A.10", "4.A.2", "4.A.3", "4.A.4", "4.A.5", "4.A.6", "4.A.7", "4.A.8", "4.A.9", ] ], }, "4.A.1": { "title": "Cattle", "alternative_codes": ["4A1", "4 A 1"], "children": [["4.A.1.a", "4.A.1.b"]], }, "4.A.1.a": { "title": "Dairy", "comment": "Cattle producing milk for commercial exchange and calves and heifers being grown for dairy purposes.", "alternative_codes": ["4A1a", "4 A 1 a"], }, "4.A.1.b": { "title": "Non-Dairy", "comment": "All non-dairy cattle including: cattle kept or grown for meat production, draft animals, and breeding animals.", "alternative_codes": ["4A1b", "4 A 1 b"], }, "4.A.2": {"title": "Buffalo", "alternative_codes": ["4A2", "4 A 2"]}, "4.A.3": {"title": "Sheep", "alternative_codes": ["4A3", "4 A 3"]}, "4.A.4": {"title": "Goats", "alternative_codes": ["4A4", "4 A 4"]}, "4.A.5": {"title": "Camels and Llamas", "alternative_codes": ["4A5", "4 A 5"]}, "4.A.6": {"title": "Horses", "alternative_codes": ["4A6", "4 A 6"]}, "4.A.7": {"title": "Mules and Asses", "alternative_codes": ["4A7", "4 A 7"]}, "4.A.8": {"title": "Swine", "alternative_codes": ["4A8", "4 A 8"]}, "4.A.9": {"title": "Poultry", "alternative_codes": ["4A9", "4 A 9"]}, "4.A.10": { "title": "Other", "comment": "Please specify.", "alternative_codes": ["4A10", "4 A 10"], }, "4.B": { "title": "Manure Management", "comment": "Methane and nitrous oxide are produced from the decomposition of manure under low oxygen or anaerobic conditions. These conditions often occur when large numbers of animals are managed in a confined area (e.g. dairy farms, beef feedlots, and swine and poultry farms), where manure is typically stored in large piles or disposed of in lagoons and other types of manure management systems. Methane emissions are covered in Sections 4 B 1 to 4 B 9 and N2O emissions in Sections 4 B 10 to 4 B 12 below.", "alternative_codes": ["4B", "4 B"], "children": [ [ "4.B.1", "4.B.10", "4.B.11", "4.B.12", "4.B.13", "4.B.2", "4.B.3", "4.B.4", "4.B.5", "4.B.6", "4.B.7", "4.B.8", "4.B.9", ] ], }, "4.B.1": { "title": "Cattle", "alternative_codes": ["4B1", "4 B 1"], "children": [["4.B.1.a", "4.B.1.b"]], }, "4.B.1.a": {"title": "Dairy", "alternative_codes": ["4B1a", "4 B 1 a"]}, "4.B.1.b": {"title": "Non-Dairy", "alternative_codes": ["4B1b", "4 B 1 b"]}, "4.B.2": {"title": "Buffalo", "alternative_codes": ["4B2", "4 B 2"]}, "4.B.3": {"title": "Sheep", "alternative_codes": ["4B3", "4 B 3"]}, "4.B.4": {"title": "Goats", "alternative_codes": ["4B4", "4 B 4"]}, "4.B.5": {"title": "Camels and Llamas", "alternative_codes": ["4B5", "4 B 5"]}, "4.B.6": {"title": "Horses", "alternative_codes": ["4B6", "4 B 6"]}, "4.B.7": {"title": "Mules and Asses", "alternative_codes": ["4B7", "4 B 7"]}, "4.B.8": {"title": "Swine", "alternative_codes": ["4B8", "4 B 8"]}, "4.B.9": {"title": "Poultry", "alternative_codes": ["4B9", "4 B 9"]}, "4.B.10": { "title": "Anaerobic Lagoons", "alternative_codes": ["4B10", "4 B 10"], }, "4.B.11": {"title": "Liquid Systems", "alternative_codes": ["4B11", "4 B 11"]}, "4.B.12": { "title": "Solid Storage and Drylot", "alternative_codes": ["4B12", "4 B 12"], }, "4.B.13": { "title": "Other", "comment": "Please specify.", "alternative_codes": ["4B13", "4 B 13"], }, "4.C": { "title": "Rice Cultivation", "comment": "The anaerobic decomposition of organic material in flooded rice fields produces methane, which escapes to the atmosphere by ebullition (bubbling up) through the water column, diffusion across the water/air interface, and transport through the rice plants. It is suggested that these CH4 emissions be based on lowland rice ecosystems without organic amendments relating to water regime, where lowland refers to fields flooded for a significant period of time. Correction factors for soils with organic amendments from the use of should be applied as necessary. Any N2O emissions nitrogen-based fertilisers in rice cultivation should be reported under 4 D Agricultural Soils.", "alternative_codes": ["4C", "4 C"], "children": [["4.C.1", "4.C.2", "4.C.3", "4.C.4"]], }, "4.C.1": { "title": "Irrigated", "comment": "Water regime is fully controlled.", "alternative_codes": ["4C1", "4 C 1"], "children": [["4.C.1.a", "4.C.1.b"]], }, "4.C.1.a": { "title": "Continuously Flooded", "alternative_codes": ["4C1a", "4 C 1 a"], }, "4.C.1.b": { "title": "Intermittently Flooded", "alternative_codes": ["4C1b", "4 C 1 b"], "children": [["4.C.1.b.i", "4.C.1.b.ii"]], }, "4.C.1.b.i": { "title": "Single Aeration", "comment": "Fields have a single aeration during the cropping season at any growth stage.", "alternative_codes": ["4C1bi", "4 C 1 b i"], }, "4.C.1.b.ii": { "title": "Multiple Aeration", "comment": "Fields have more than one aeration period during the cropping season.", "alternative_codes": ["4C1bii", "4 C 1 b ii"], }, "4.C.2": { "title": "Rainfed", "comment": "Water regime depends solely on precipitation.", "alternative_codes": ["4C2", "4 C 2"], "children": [["4.C.2.a", "4.C.2.b"]], }, "4.C.2.a": { "title": "Flood Prone", "comment": "The water level may rise up to 50 cm during the cropping season.", "alternative_codes": ["4C2a", "4 C 2 a"], }, "4.C.2.b": { "title": "Drought Prone", "comment": "Drought periods occur during every cropping season.", "alternative_codes": ["4C2b", "4 C 2 b"], }, "4.C.3": { "title": "Deepwater", "comment": "Floodwater rises to more than 50 cm for a significant period of time during the cropping season.", "alternative_codes": ["4C3", "4 C 3"], "children": [["4.C.3.a", "4.C.3.b"]], }, "4.C.3.a": { "title": "Water Depth 50-100 cm", "comment": "Fields inundated with water depth from 50 100 cm.", "alternative_codes": ["4C3a", "4 C 3 a"], }, "4.C.3.b": { "title": "Water Depth > 100 cm", "comment": "Fields inundated with water depth 100 cm.", "alternative_codes": ["4C3b", "4 C 3 b"], }, "4.C.4": {"title": "Other", "alternative_codes": ["4C4", "4 C 4"]}, "4.D": { "title": "Agricultural Soils", "comment": "Emissions and removals of CH4 and N2O from agricultural soil/land and NMVOCs from crops. These are influenced by irrigation practices, climatic variables, soil temperature and humidity. Any N2O emissions from the use of nitrogen-based fertilisers in rice cultivation should be reported here. N2O emissions may be related to the use of both organic and inorganic fertilisers, biological Nitrogen fixation, and return of crop residues to the field or to animal production. Non-CO2 greenhouse gas emissions associated with the use of compost and human waste as fertilisers should also be recorded in this category. Emissions of N2O from sewage are to be reported under Waste from animal waste (6 B) and N2O emissions management systems other than grazing under manure management (4 B). Emissions of N2O from manure used for fuel are reported under the Energy Module (1 A).", "alternative_codes": ["4D", "4 D"], "children": [["4.D.1", "4.D.2", "4.D.3", "4.D.4"]], }, "4.E": { "title": "Prescribed Burning of Savannas", "comment": "Emissions of CH4, CO, N2O, and NOx from the burning of savannas*. Savannas are burned to control the growth of vegetation, remove pests and weeds, promote the nutrient cycle and to encourage the growth of new grass for animal grazing. CO2 from savanna burning is noted for information but is not included in the inventory total since it is assumed that an equivalent amount of CO2 is removed by regrowing vegetation in the following year. *Savannas are tropical and subtropical formations with continuous grass cover, occasionally interrupted by trees and shrubs, which exist in Africa, Latin America, Asia, and Australia.", "alternative_codes": ["4E", "4 E"], }, "4.F": { "title": "Field Burning of Agricultural Residues", "comment": "Emission of non-CO2 greenhouse gases from burning (in the field) of crop residue and other agricultural wastes on site. These include woody crop residues (e.g. coconut shells, jute sticks, etc.); cereal residues (e.g. rice and wheat straw, maize stalks, etc.); green crop residues (e.g. groundnut straw, soybean tops, etc.). The burning of agricultural waste for energy is excluded here but included under fuel combustion activities in Section 1 A. CO2 from vegetal or biomass burning is noted for information but is not included in the inventory total, since it is assumed that a roughly equivalent amount of CO2 is removed by regrowth of the next crop.", "alternative_codes": ["4F", "4 F"], "children": [["4.F.1", "4.F.2", "4.F.3", "4.F.4", "4.F.5"]], }, "4.F.1": { "title": "Cereals", "comment": "Emissions from the on-site burning of residue from cereal crops harvested for dry grain, including but not limited to wheat, barley, maize, oats, rye, rice, millet and sorghum.", "alternative_codes": ["4F1", "4 F 1"], "children": [ [ "4.F.1.a", "4.F.1.b", "4.F.1.c", "4.F.1.d", "4.F.1.e", "4.F.1.f", "4.F.1.g", ] ], }, "4.F.2": { "title": "Pulse", "comment": "Emissions from the on-site burning of residue from pulse crops harvested for dry grain, including but not limited to pea, bean and soya.", "alternative_codes": ["4F2", "4 F 2"], "children": [["4.F.2.a", "4.F.2.b", "4.F.2.c", "4.F.2.d"]], }, "4.F.3": { "title": "Tuber and Root", "comment": "Emissions from the on-site burning of residue from tuber and root crops, including but not limited to potatoes, feedbeet, sugarbeet, girasol (Jerusalem artichoke) and peanut.", "alternative_codes": ["4F3", "4 F 3"], "children": [["4.F.3.a", "4.F.3.b"]], }, "4.F.4": { "title": "Sugar Cane", "comment": "Emissions from the on-site burning of sugar cane crop residue.", "alternative_codes": ["4F4", "4 F 4"], }, "4.F.5": { "title": "Other", "comment": "Emissions from the on-site burning of residue from crops not included above.", "alternative_codes": ["4F5", "4 F 5"], }, "4.G": { "title": "Other", "comment": "Describe each emission source/sink in detail.", "alternative_codes": ["4G", "4 G"], }, "5": { "title": "Land-Use Change & Forestry", "comment": "Total emissions and removals from forest and land use change activities as described below. These activities have an impact on three different carbon sources/sinks: aboveground biomass, belowground biomass and soil carbon. Sum of 5 A, B, C, D & E.", "children": [["5.A", "5.B", "5.C", "5.D", "5.E"]], }, "5.B": { "title": "Forest and Grassland Conversion", "comment": "This category includes conversion of existing forests and natural grasslands to other land uses. Emissions of CO2, CH4, CO, N2O, NOx and NMVOCs from the burning and decay of biomass.", "alternative_codes": ["5B", "5 B"], "children": [ ["5.B-gra", "5.B-tro", "5.B.1", "5.B.2", "5.B.3", "5.B.4", "5.B.5"] ], }, "5.B.1": { "title": "Tropical Forests", "alternative_codes": ["5B1", "5 B 1"], "children": [ [ "5.B.1.a", "5.B.1.b", "5.B.1.c", "5.B.1.d", "5.B.1.e", "5.B.1.f", "5.B.1.g", "5.B.1.h", ] ], }, "5.B.1.a": { "title": "Wet/Very Moist", "alternative_codes": ["5B1a", "5 B 1 a"], }, "5.B.1.b": { "title": "Moist, Short Dry Season", "alternative_codes": ["5B1b", "5 B 1 b"], }, "5.B.1.c": { "title": "Moist, Long Dry Season", "alternative_codes": ["5B1c", "5 B 1 c"], }, "5.B.1.d": {"title": "Dry", "alternative_codes": ["5B1d", "5 B 1 d"]}, "5.B.1.e": { "title": "Mountain Moist", "alternative_codes": ["5B1e", "5 B 1 e"], }, "5.B.1.f": {"title": "Mountain Dry", "alternative_codes": ["5B1f", "5 B 1 f"]}, "5.B.1.g": {"title": "Plantations", "alternative_codes": ["5B1g", "5 B 1 g"]}, "5.B.1.h": {"title": "Other", "alternative_codes": ["5B1h", "5 B 1 h"]}, "5.B.2": { "title": "Temperate Forests", "alternative_codes": ["5B2", "5 B 2"], "children": [["5.B.2-mix", "5.B.2.a", "5.B.2.b", "5.B.2.c", "5.B.2.d"]], }, "5.B.2.a": {"title": "Coniferous", "alternative_codes": ["5B2a", "5 B 2 a"]}, "5.B.2.b": {"title": "Broadleaf", "alternative_codes": ["5B2b", "5 B 2 b"]}, "5.B.2.c": {"title": "Plantations", "alternative_codes": ["5B2c", "5 B 2 c"]}, "5.B.2.d": {"title": "Other", "alternative_codes": ["5B2d", "5 B 2 d"]}, "5.B.3": { "title": "Boreal Forests", "alternative_codes": ["5B3", "5 B 3"], "children": [["5.B.3.a", "5.B.3.b", "5.B.3.c"]], }, "5.B.3.a": { "title": "Mixed Broadleaf/Coniferous", "alternative_codes": ["5B3a", "5 B 3 a"], }, "5.B.3.b": {"title": "Coniferous", "alternative_codes": ["5B3b", "5 B 3 b"]}, "5.B.3.c": {"title": "Forest Tundra", "alternative_codes": ["5B3c", "5 B 3 c"]}, "5.B.4": { "title": "Grasslands/Tundra", "comment": "Emissions of CO2 from grasslands including tropical savanna and boreal tundra.", "alternative_codes": ["5B4", "5 B 4"], }, "5.B.5": { "title": "Other", "comment": "Emissions from conversion of ecosystem types (e.g. wastelands, desert, etc.) not otherwise covered in any of the above categories.", "alternative_codes": ["5B5", "5 B 5"], }, "5.C": { "title": "Abandonment of Managed Lands", "comment": "Removal of CO2 from the abandonment of formerly managed lands (e.g. croplands and pastures). This category includes conversion of managed to abandoned lands. The categories below are determined by the type of biomass which regrows on the abandoned land.", "alternative_codes": ["5C", "5 C"], "children": [ ["5.C-gra", "5.C-tro", "5.C.1", "5.C.2", "5.C.3", "5.C.4", "5.C.5"] ], }, "5.C.1": { "title": "Tropical Forests", "alternative_codes": ["5C1", "5 C 1"], "children": [ ["5.C.1.a", "5.C.1.b", "5.C.1.c", "5.C.1.d", "5.C.1.e", "5.C.1.f"] ], }, "5.C.2": { "title": "Temperate Forests", "alternative_codes": ["5C2", "5 C 2"], "children": [["5.C.2.a", "5.C.2.b", "5.C.2.c"]], }, "5.C.3": { "title": "Boreal Forests", "alternative_codes": ["5C3", "5 C 3"], "children": [["5.C.3.a", "5.C.3.b", "5.C.3.c"]], }, "5.C.4": {"title": "Grasslands/Tundra", "alternative_codes": ["5C4", "5 C 4"]}, "5.C.5": { "title": "Other", "comment": "Removals from abandoned land regrown to any biomass type other than forests or grasslands.", "alternative_codes": ["5C5", "5 C 5"], }, "5.D": { "title": "CO2 Emissions and Removals From Soil", "comment": "Emissions and removals of CO2 in soil associated with land-use change and management. Includes CO2 emissions from liming of agricultural soil.", "alternative_codes": ["5D", "5 D"], "children": [["5.D.1", "5.D.2", "5.D.3", "5.D.4", "5.D.5"]], }, "5.E": { "title": "Other", "comment": "Emissions and removals (sources and sinks) of CO2 from land use or land-use change activities which can not be included under the categories provided above. Emissions of NMVOC from the living trees in managed forests and N2O or CH4 emissions/removals from the soil of managed forests are reported here. Managed forests include all trees planted or managed by man for profit, pleasure, wind or water-erosion protection etc.", "alternative_codes": ["5E", "5 E"], }, "6": { "title": "Waste", "comment": "Total emissions from solid waste disposal on land, wastewater, waste incineration and any other waste management activity. Any emissions from fossil-based products (incineration or CO2 decomposition) should be accounted for here but see note on double counting under Section 2 “Reporting the National Inventory.” CO2 from organic waste handling and decay should not be included (see below). Sum of 6 A, B, C & D.", "children": [["6.A", "6.B", "6.C", "6.D"]], }, "6.A": { "title": "Solid Waste Disposal on Land", "comment": "Methane is produced from anaerobic microbial decomposition of organic matter in solid waste disposal sites. Carbon dioxide from non-biologic or (CO2) is also produced but only CO2 inorganic waste sources should be reported here.", "alternative_codes": ["6A", "6 A"], "children": [["6.A.1", "6.A.2", "6.A.3"]], }, "6.A.1": { "title": "Managed Waste Disposal on Land", "comment": "A managed solid waste disposal site must have controlled placement of waste (i.e. waste directed to specific deposition areas, a degree of control of scavenging and a degree of control fires) and will include at least one of the following: cover material; mechanical compaction; or levelling of the waste.", "alternative_codes": ["6A1", "6 A 1"], }, "6.A.2": { "title": "Unmanaged Waste Disposal Sites", "comment": "These are all other solid waste disposal sites that do not fall into the above category.", "alternative_codes": ["6A2", "6 A 2"], "children": [["6.A.2.a", "6.A.2.b"]], }, "6.A.3": { "title": "Other", "comment": "Other solid waste disposal on land.", "alternative_codes": ["6A3", "6 A 3"], }, "6.B": { "title": "Wastewater Handling", "comment": "Methane and nitrous oxide are produced from anaerobic decomposition of organic matter by bacteria in sewage facilities and from food processing and other industrial facilities during wastewater handling. N2O may also be released from wastewater handling and human waste. Methane emissions are covered in 6 B 1 and 6 B 2, nitrous oxide emissions in 6 B 2.", "alternative_codes": ["6B", "6 B"], "children": [["6.B.1", "6.B.2", "6.B.3"]], }, "6.B.1": { "title": "Industrial Wastewater", "comment": "Handling of liquid wastes and sludge from industrial processes such as: food processing, textiles, or pulp and paper production. This may involve such things as wastewater collection and treatment, ponds, or discharge into surface water.", "alternative_codes": ["6B1", "6 B 1"], }, "6.B.2": { "title": "Domestic and Commercial Wastewater", "comment": "Handling of liquid wastes and sludge from housing and commercial sources (including human waste) through: wastewater collection and treatment, open pits / latrines, ponds, or discharge into surface waters. N2O emissions from discharge of human sewage to aquatic environments are included here.", "alternative_codes": ["6B2", "6 B 2"], }, "6.B.3": {"title": "Other", "alternative_codes": ["6B3", "6 B 3"]}, "6.C": { "title": "Waste Incineration", "comment": "Incineration of waste, not including waste-to-energy facilities. Emissions from waste burnt for energy are reported under the Energy Module, 1 A. Emissions from burning of agricultural wastes should be reported under Section 4. All non-CO2 greenhouse gases from incineration should be reported here as well as CO2 from non-biological waste.", "alternative_codes": ["6C", "6 C"], "children": [["6.C.1", "6.C.2", "6.C.3"]], }, "6.D": { "title": "Other", "comment": "Release of greenhouse gases from other waste handling activities.", "alternative_codes": ["6D", "6 D"], }, "7": { "title": "Other", "comment": "Efforts should be made to fit all emission sources/sinks into the six categories described above. If it is impossible to do so, however, this category may be used, accompanied by a detailed explanation of the source/sink activity.", }, "2.F.8": { "title": "Other", "comment": "Please specify.", "alternative_codes": ["2F8", "2 F 8"], }, "1.A-ref": { "title": "Reference Approach", "alternative_codes": ["1 A-ref", "1A-ref"], "children": [["1.A-ref.1", "1.A-ref.2"]], }, "1.A-ref.1": { "title": "Fossil Fuel", "alternative_codes": ["1 A-ref 1", "1A-ref1"], "children": [["1.A-ref.1.a", "1.A-ref.1.b", "1.A-ref.1.c"]], }, "1.A-ref.1.a": { "title": "Liquid Fossil", "alternative_codes": ["1 A-ref 1 a", "1A-ref1a"], "children": [["1.A-ref.1.a.i", "1.A-ref.1.a.ii"]], }, "1.A-ref.1.a.i": { "title": "Primary Fuels", "alternative_codes": ["1 A-ref 1 a i", "1A-ref1ai"], "children": [["1.A-ref.1.a.i.1", "1.A-ref.1.a.i.2", "1.A-ref.1.a.i.3"]], }, "1.A-ref.1.a.i.1": { "title": "Crude Oil", "alternative_codes": ["1 A-ref 1 a i 1", "1A-ref1ai1"], }, "1.A-ref.1.a.i.2": { "title": "Orimulsion", "alternative_codes": ["1 A-ref 1 a i 2", "1A-ref1ai2"], }, "1.A-ref.1.a.i.3": { "title": "Natural Gas Liquids", "alternative_codes": ["1 A-ref 1 a i 3", "1A-ref1ai3"], }, "1.A-ref.1.a.ii": { "title": "Secondary Fuels", "alternative_codes": ["1 A-ref 1 a ii", "1A-ref1aii"], "children": [ [ "1.A-ref.1.a.ii.1", "1.A-ref.1.a.ii.10", "1.A-ref.1.a.ii.11", "1.A-ref.1.a.ii.12", "1.A-ref.1.a.ii.13", "1.A-ref.1.a.ii.14", "1.A-ref.1.a.ii.2", "1.A-ref.1.a.ii.3", "1.A-ref.1.a.ii.4", "1.A-ref.1.a.ii.5", "1.A-ref.1.a.ii.6", "1.A-ref.1.a.ii.7", "1.A-ref.1.a.ii.8", "1.A-ref.1.a.ii.9", ] ], }, "1.A-ref.1.a.ii.1": { "title": "Gasoline", "alternative_codes": ["1 A-ref 1 a ii 1", "1A-ref1aii1"], }, "1.A-ref.1.a.ii.2": { "title": "Jet Kerosene", "alternative_codes": ["1 A-ref 1 a ii 2", "1A-ref1aii2"], }, "1.A-ref.1.a.ii.3": { "title": "Other Kerosene", "alternative_codes": ["1 A-ref 1 a ii 3", "1A-ref1aii3"], }, "1.A-ref.1.a.ii.4": { "title": "Shale Oil", "alternative_codes": ["1 A-ref 1 a ii 4", "1A-ref1aii4"], }, "1.A-ref.1.a.ii.5": { "title": "Gas / Diesel Oil", "alternative_codes": ["1 A-ref 1 a ii 5", "1A-ref1aii5"], }, "1.A-ref.1.a.ii.6": { "title": "Residual Fuel Oil", "alternative_codes": ["1 A-ref 1 a ii 6", "1A-ref1aii6"], }, "1.A-ref.1.a.ii.7": { "title": "LPG", "alternative_codes": ["1 A-ref 1 a ii 7", "1A-ref1aii7"], }, "1.A-ref.1.a.ii.8": { "title": "Ethane", "alternative_codes": ["1 A-ref 1 a ii 8", "1A-ref1aii8"], }, "1.A-ref.1.a.ii.9": { "title": "Naphtha", "alternative_codes": ["1 A-ref 1 a ii 9", "1A-ref1aii9"], }, "1.A-ref.1.a.ii.10": { "title": "Bitumen", "alternative_codes": ["1 A-ref 1 a ii 10", "1A-ref1aii10"], }, "1.A-ref.1.a.ii.11": { "title": "Lubricants", "alternative_codes": ["1 A-ref 1 a ii 11", "1A-ref1aii11"], }, "1.A-ref.1.a.ii.12": { "title": "Petroleum Coke", "alternative_codes": ["1 A-ref 1 a ii 12", "1A-ref1aii12"], }, "1.A-ref.1.a.ii.13": { "title": "Refinery Feedstocks", "alternative_codes": ["1 A-ref 1 a ii 13", "1A-ref1aii13"], }, "1.A-ref.1.a.ii.14": { "title": "Other Oil", "alternative_codes": ["1 A-ref 1 a ii 14", "1A-ref1aii14"], }, "1.A-ref.1.b": { "title": "Solid Fossil", "alternative_codes": ["1 A-ref 1 b", "1A-ref1b"], "children": [["1.A-ref.1.b.i", "1.A-ref.1.b.ii"]], }, "1.A-ref.1.b.i": { "title": "Primary Fuels", "alternative_codes": ["1 A-ref 1 b i", "1A-ref1bi"], "children": [ [ "1.A-ref.1.b.i.1", "1.A-ref.1.b.i.2", "1.A-ref.1.b.i.3", "1.A-ref.1.b.i.4", "1.A-ref.1.b.i.5", "1.A-ref.1.b.i.6", "1.A-ref.1.b.i.7", ] ], }, "1.A-ref.1.b.i.1": { "title": "Anthracite", "alternative_codes": ["1 A-ref 1 b i 1", "1A-ref1bi1"], }, "1.A-ref.1.b.i.2": { "title": "Coking Coal", "alternative_codes": ["1 A-ref 1 b i 2", "1A-ref1bi2"], }, "1.A-ref.1.b.i.3": { "title": "Other Bituminous Coal", "alternative_codes": ["1 A-ref 1 b i 3", "1A-ref1bi3"], }, "1.A-ref.1.b.i.4": { "title": "Sub-bituminous coal", "alternative_codes": ["1 A-ref 1 b i 4", "1A-ref1bi4"], }, "1.A-ref.1.b.i.5": { "title": "Lignite", "alternative_codes": ["1 A-ref 1 b i 5", "1A-ref1bi5"], }, "1.A-ref.1.b.i.6": { "title": "Oil Shale", "alternative_codes": ["1 A-ref 1 b i 6", "1A-ref1bi6"], }, "1.A-ref.1.b.i.7": { "title": "Peat", "alternative_codes": ["1 A-ref 1 b i 7", "1A-ref1bi7"], }, "1.A-ref.1.b.ii": { "title": "Secondary Fuels", "alternative_codes": ["1 A-ref 1 b ii", "1A-ref1bii"], "children": [["1.A-ref.1.b.ii.1", "1.A-ref.1.b.ii.2"]], }, "1.A-ref.1.b.ii.1": { "title": "BKB & Patent Fuel", "alternative_codes": ["1 A-ref 1 b ii 1", "1A-ref1bii1"], }, "1.A-ref.1.b.ii.2": { "title": "Coke Oven / Gas Coke", "alternative_codes": ["1 A-ref 1 b ii 2", "1A-ref1bii2"], }, "1.A-ref.1.c": { "title": "Gaseous Fossil", "alternative_codes": ["1 A-ref 1 c", "1A-ref1c"], "children": [["1.A-ref.1.c.i"]], }, "1.A-ref.1.c.i": { "title": "Natural Gas (Dry)", "alternative_codes": ["1 A-ref 1 c i", "1A-ref1ci"], }, "1.A-ref.2": { "title": "Biomass", "alternative_codes": ["1 A-ref 2", "1A-ref2"], "children": [["1.A-ref.2.a", "1.A-ref.2.b", "1.A-ref.2.c"]], }, "1.A-ref.2.a": { "title": "Solid Biomass", "alternative_codes": ["1 A-ref 2 a", "1A-ref2a"], }, "1.A-ref.2.b": { "title": "Liquid Biomass", "alternative_codes": ["1 A-ref 2 b", "1A-ref2b"], }, "1.A-ref.2.c": { "title": "Gas Biomass", "alternative_codes": ["1 A-ref 2 c", "1A-ref2c"], }, "1.B.2.b-exp": { "title": "Exploration", "alternative_codes": ["1 B 2 b-exp", "1B2b-exp"], }, "1.B.2.b-dis": { "title": "Distribution", "alternative_codes": ["1 B 2 b-dis", "1B2b-dis"], }, "1.B.2.b.iii.1": { "title": "at industrial plants and power stations", "alternative_codes": ["1 B 2 b iii 1", "1B2biii1"], }, "1.B.2.b.iii.2": { "title": "in residential and commercial sectors", "alternative_codes": ["1 B 2 b iii 2", "1B2biii2"], }, "1.B.2.c-ven": { "title": "Venting", "alternative_codes": ["1 B 2 c-ven", "1B2c-ven"], "children": [["1.B.2.c-ven.i", "1.B.2.c-ven.ii", "1.B.2.c-ven.iii"]], }, "1.B.2.c-ven.i": { "title": "Oil", "alternative_codes": ["1 B 2 c-ven i", "1B2c-veni"], }, "1.B.2.c-ven.ii": { "title": "Gas", "alternative_codes": ["1 B 2 c-ven ii", "1B2c-venii"], }, "1.B.2.c-ven.iii": { "title": "Combined", "alternative_codes": ["1 B 2 c-ven iii", "1B2c-veniii"], }, "1.B.2.c-fla": { "title": "Flaring", "alternative_codes": ["1 B 2 c-fla", "1B2c-fla"], "children": [["1.B.2.c-fla.i", "1.B.2.c-fla.ii", "1.B.2.c-fla.iii"]], }, "1.B.2.c-fla.i": { "title": "Oil", "alternative_codes": ["1 B 2 c-fla i", "1B2c-flai"], }, "1.B.2.c-fla.ii": { "title": "Gas", "alternative_codes": ["1 B 2 c-fla ii", "1B2c-flaii"], }, "1.B.2.c-fla.iii": { "title": "Combined", "alternative_codes": ["1 B 2 c-fla iii", "1B2c-flaiii"], }, "1.B.2.d": {"title": "Other", "alternative_codes": ["1 B 2 d", "1B2d"]}, "2.E.1.a": { "title": "Production of HCFC-22", "alternative_codes": ["2 E 1 a", "2E1a"], }, "2.E.1.b": {"title": "Other", "alternative_codes": ["2 E 1 b", "2E1b"]}, "2.F.6": { "title": "Semiconductor Manufacture", "alternative_codes": ["2 F 6", "2F6"], }, "2.F.7": { "title": "Electrical Equipment", "alternative_codes": ["2 F 7", "2F7"], }, "2.A.7.a": { "title": "Glass Production", "alternative_codes": ["2 A 7 a", "2A7a"], }, "2.A.7.b": {"title": "Other", "alternative_codes": ["2 A 7 b", "2A7b"]}, "2.B.4.a": { "title": "Silicon Carbide", "alternative_codes": ["2 B 4 a", "2B4a"], }, "2.B.4.b": { "title": "Calcium Carbide", "alternative_codes": ["2 B 4 b", "2B4b"], }, "2.B.5.a": {"title": "Carbon Black", "alternative_codes": ["2 B 5 a", "2B5a"]}, "2.B.5.b": {"title": "Ethylene", "alternative_codes": ["2 B 5 b", "2B5b"]}, "2.B.5.c": { "title": "Dichloroethylene", "alternative_codes": ["2 B 5 c", "2B5c"], }, "2.B.5.d": {"title": "Styrene", "alternative_codes": ["2 B 5 d", "2B5d"]}, "2.B.5.e": {"title": "Methanol", "alternative_codes": ["2 B 5 e", "2B5e"]}, "2.B.5.f": {"title": "Other", "alternative_codes": ["2 B 5 f", "2B5f"]}, "2.C.1.a": {"title": "Steel", "alternative_codes": ["2 C 1 a", "2C1a"]}, "2.C.1.b": {"title": "Pig Iron", "alternative_codes": ["2 C 1 b", "2C1b"]}, "2.C.1.c": {"title": "Sinter", "alternative_codes": ["2 C 1 c", "2C1c"]}, "2.C.1.d": {"title": "Coke", "alternative_codes": ["2 C 1 d", "2C1d"]}, "2.C.1.e": {"title": "Other", "alternative_codes": ["2 C 1 e", "2C1e"]}, "2.C.4.a": { "title": "SF6 used in Aluminium Foundries", "alternative_codes": ["2 C 4 a", "2C4a"], }, "2.C.4.b": { "title": "SF6 used in Magnesium Foundries", "alternative_codes": ["2 C 4 b", "2C4b"], }, "2.F.1.a": { "title": "Domestic Refrigeration", "alternative_codes": ["2 F 1 a", "2F1a"], }, "2.F.1.b": { "title": "Commercial Refrigeration", "alternative_codes": ["2 F 1 b", "2F1b"], }, "2.F.1.c": { "title": "Transport Refrigeration", "alternative_codes": ["2 F 1 c", "2F1c"], }, "2.F.1.d": { "title": "Industrial Refrigeration", "alternative_codes": ["2 F 1 d", "2F1d"], }, "2.F.1.e": { "title": "Stationary Air-Conditioning", "alternative_codes": ["2 F 1 e", "2F1e"], }, "2.F.1.f": { "title": "Mobile Air-Conditioning", "alternative_codes": ["2 F 1 f", "2F1f"], }, "2.F.2.a": {"title": "Hard Foam", "alternative_codes": ["2 F 2 a", "2F2a"]}, "2.F.2.b": {"title": "Soft Foam", "alternative_codes": ["2 F 2 b", "2F2b"]}, "2.F.4.a": { "title": "Metered Dose Inhalers", "alternative_codes": ["2 F 4 a", "2F4a"], }, "2.F.4.b": {"title": "Other", "alternative_codes": ["2 F 4 b", "2F4b"]}, "3.D.1": { "title": "Use of N2O for Anaesthesia", "alternative_codes": ["3 D 1", "3D1"], }, "3.D.2": { "title": "N2O from Fire Extinguishers", "alternative_codes": ["3 D 2", "3D2"], }, "3.D.3": { "title": "N2O from Aerosol Cans", "alternative_codes": ["3 D 3", "3D3"], }, "3.D.4": {"title": "Other Use of N2O", "alternative_codes": ["3 D 4", "3D4"]}, "3.D.5": {"title": "Other", "alternative_codes": ["3 D 5", "3D5"]}, "4.D.1": { "title": "Direct Soil Emissions", "alternative_codes": ["4 D 1", "4D1"], "children": [["4.D.1.a", "4.D.1.b", "4.D.1.c", "4.D.1.d", "4.D.1.e"]], }, "4.D.1.a": { "title": "Synthetic Fertilizers", "alternative_codes": ["4 D 1 a", "4D1a"], }, "4.D.1.b": { "title": "Animal Wastes Applied to Soils", "alternative_codes": ["4 D 1 b", "4D1b"], }, "4.D.1.c": { "title": "N-fixing Crops", "alternative_codes": ["4 D 1 c", "4D1c"], }, "4.D.1.d": {"title": "Crop Residue", "alternative_codes": ["4 D 1 d", "4D1d"]}, "4.D.1.e": { "title": "Cultivation of Histosols", "alternative_codes": ["4 D 1 e", "4D1e"], }, "4.D.2": {"title": "Animal Production", "alternative_codes": ["4 D 2", "4D2"]}, "4.D.3": { "title": "Indirect Emissions", "alternative_codes": ["4 D 3", "4D3"], "children": [["4.D.3.a", "4.D.3.b"]], }, "4.D.3.a": { "title": "Atmospheric Deposition", "alternative_codes": ["4 D 3 a", "4D3a"], }, "4.D.3.b": { "title": "Nitrogen Leaching and Run-off", "alternative_codes": ["4 D 3 b", "4D3b"], }, "4.D.4": {"title": "Other", "alternative_codes": ["4 D 4", "4D4"]}, "4.F.1.a": {"title": "Wheat", "alternative_codes": ["4 F 1 a", "4F1a"]}, "4.F.1.b": {"title": "Barley", "alternative_codes": ["4 F 1 b", "4F1b"]}, "4.F.1.c": {"title": "Maize", "alternative_codes": ["4 F 1 c", "4F1c"]}, "4.F.1.d": {"title": "Oats", "alternative_codes": ["4 F 1 d", "4F1d"]}, "4.F.1.e": {"title": "Rye", "alternative_codes": ["4 F 1 e", "4F1e"]}, "4.F.1.f": {"title": "Rice", "alternative_codes": ["4 F 1 f", "4F1f"]}, "4.F.1.g": {"title": "Other", "alternative_codes": ["4 F 1 g", "4F1g"]}, "4.F.2.a": {"title": "Dry bean", "alternative_codes": ["4 F 2 a", "4F2a"]}, "4.F.2.b": {"title": "Peas", "alternative_codes": ["4 F 2 b", "4F2b"]}, "4.F.2.c": {"title": "Soybeans", "alternative_codes": ["4 F 2 c", "4F2c"]}, "4.F.2.d": {"title": "Other", "alternative_codes": ["4 F 2 d", "4F2d"]}, "4.F.3.a": {"title": "Potatoes", "alternative_codes": ["4 F 3 a", "4F3a"]}, "4.F.3.b": {"title": "Other", "alternative_codes": ["4 F 3 b", "4F3b"]}, "5.A": { "title": "Changes in Forest and Other Woody Biomass Stocks", "alternative_codes": ["5 A", "5A"], "children": [["5.A.1", "5.A.2", "5.A.3", "5.A.4", "5.A.5"]], }, "5.A.1": { "title": "Tropical", "alternative_codes": ["5 A 1", "5A1"], "children": [["5.A.1.a", "5.A.1.b", "5.A.1.c"]], }, "5.A.1.a": { "title": "Plantations", "alternative_codes": ["5 A 1 a", "5A1a"], "children": [ [ "5.A.1.a.i", "5.A.1.a.ii", "5.A.1.a.iii", "5.A.1.a.iv", "5.A.1.a.ix", "5.A.1.a.v", "5.A.1.a.vi", "5.A.1.a.vii", "5.A.1.a.viii", ] ], }, "5.A.1.a.i": { "title": "Acacia spp.", "alternative_codes": ["5 A 1 a i", "5A1ai"], }, "5.A.1.a.ii": { "title": "Eucalyptus spp.", "alternative_codes": ["5 A 1 a ii", "5A1aii"], }, "5.A.1.a.iii": { "title": "Tectona grandis", "alternative_codes": ["5 A 1 a iii", "5A1aiii"], }, "5.A.1.a.iv": { "title": "Pinus spp", "alternative_codes": ["5 A 1 a iv", "5A1aiv"], }, "5.A.1.a.v": { "title": "Pinus caribaea", "alternative_codes": ["5 A 1 a v", "5A1av"], }, "5.A.1.a.vi": { "title": "Mixed Hardwoods", "alternative_codes": ["5 A 1 a vi", "5A1avi"], }, "5.A.1.a.vii": { "title": "Mixed Fast-Growing Hardwoods", "alternative_codes": ["5 A 1 a vii", "5A1avii"], }, "5.A.1.a.viii": { "title": "Mixed Softwoods", "alternative_codes": ["5 A 1 a viii", "5A1aviii"], }, "5.A.1.a.ix": {"title": "Other", "alternative_codes": ["5 A 1 a ix", "5A1aix"]}, "5.A.1.b": { "title": "Other Forests", "alternative_codes": ["5 A 1 b", "5A1b"], "children": [["5.A.1.b.i", "5.A.1.b.ii", "5.A.1.b.iii"]], }, "5.A.1.b.i": {"title": "Moist", "alternative_codes": ["5 A 1 b i", "5A1bi"]}, "5.A.1.b.ii": { "title": "Seasonal", "alternative_codes": ["5 A 1 b ii", "5A1bii"], }, "5.A.1.b.iii": { "title": "Dry", "alternative_codes": ["5 A 1 b iii", "5A1biii"], }, "5.A.1.c": {"title": "Other", "alternative_codes": ["5 A 1 c", "5A1c"]}, "5.A.2": { "title": "Temperate", "alternative_codes": ["5 A 2", "5A2"], "children": [["5.A.2.a", "5.A.2.b", "5.A.2.c"]], }, "5.A.2.a": {"title": "Plantations", "alternative_codes": ["5 A 2 a", "5A2a"]}, "5.A.2.b": { "title": "Commercial", "alternative_codes": ["5 A 2 b", "5A2b"], "children": [["5.A.2.b.i", "5.A.2.b.ii"]], }, "5.A.2.b.i": { "title": "Evergreen", "alternative_codes": ["5 A 2 b i", "5A2bi"], }, "5.A.2.b.ii": { "title": "Deciduous", "alternative_codes": ["5 A 2 b ii", "5A2bii"], }, "5.A.2.c": {"title": "Other", "alternative_codes": ["5 A 2 c", "5A2c"]}, "5.A.3": {"title": "Boreal", "alternative_codes": ["5 A 3", "5A3"]}, "5.A.4": { "title": "Grasslands / Tundra", "alternative_codes": ["5 A 4", "5A4"], }, "5.A.5": { "title": "Other", "alternative_codes": ["5 A 5", "5A5"], "children": [["5.A.5.a", "5.A.5.b"]], }, "5.A.5.a": { "title": "Harvested Wood", "alternative_codes": ["5 A 5 a", "5A5a"], }, "5.A.5.b": {"title": "Other", "alternative_codes": ["5 A 5 b", "5A5b"]}, "5.D.1": { "title": "Cultivation of Mineral Soils", "alternative_codes": ["5 D 1", "5D1"], "children": [ ["5.D.1.a", "5.D.1.b", "5.D.1.c", "5.D.1.d", "5.D.1.e", "5.D.1.f"] ], }, "5.D.2": { "title": "Cultivation of Organic Soils", "alternative_codes": ["5 D 2", "5D2"], "children": [["5.D.2.a", "5.D.2.b", "5.D.2.c"]], }, "5.D.3": { "title": "Liming of Agricultural Soils", "alternative_codes": ["5 D 3", "5D3"], "children": [["5.D.3.a", "5.D.3.b"]], }, "5.D.4": {"title": "Forest Soils", "alternative_codes": ["5 D 4", "5D4"]}, "5.D.5": {"title": "Other", "alternative_codes": ["5 D 5", "5D5"]}, "5.B-tro": { "title": "Tropical Savanna / Grasslands", "alternative_codes": ["5 B-tro", "5B-tro"], }, "5.B-gra": {"title": "Grasslands", "alternative_codes": ["5 B-gra", "5B-gra"]}, "5.B.2-mix": { "title": "Mixed Broadleaf / Coniferous", "alternative_codes": ["5 B 2-mix", "5B2-mix"], }, "5.C-tro": { "title": "Tropical Savanna / Grasslands", "alternative_codes": ["5 C-tro", "5C-tro"], }, "5.C-gra": {"title": "Grasslands", "alternative_codes": ["5 C-gra", "5C-gra"]}, "5.C.1.a": { "title": "Wet / Very Moist", "alternative_codes": ["5 C 1 a", "5C1a"], }, "5.C.1.b": { "title": "Moist, short dry season", "alternative_codes": ["5 C 1 b", "5C1b"], }, "5.C.1.c": { "title": "Moist, long dry season", "alternative_codes": ["5 C 1 c", "5C1c"], }, "5.C.1.d": {"title": "Dry", "alternative_codes": ["5 C 1 d", "5C1d"]}, "5.C.1.e": {"title": "Montane Moist", "alternative_codes": ["5 C 1 e", "5C1e"]}, "5.C.1.f": {"title": "Montane Dry", "alternative_codes": ["5 C 1 f", "5C1f"]}, "5.C.2.a": { "title": "Mixed Broadleaf / Coniferous", "alternative_codes": ["5 C 2 a", "5C2a"], }, "5.C.2.b": {"title": "Coniferous", "alternative_codes": ["5 C 2 b", "5C2b"]}, "5.C.2.c": {"title": "Broadleaf", "alternative_codes": ["5 C 2 c", "5C2c"]}, "5.C.3.a": { "title": "Mixed Broadleaf / Coniferous", "alternative_codes": ["5 C 3 a", "5C3a"], }, "5.C.3.b": {"title": "Coniferous", "alternative_codes": ["5 C 3 b", "5C3b"]}, "5.C.3.c": {"title": "Broadleaf", "alternative_codes": ["5 C 3 c", "5C3c"]}, "5.D.1.a": { "title": "High Activity Soils", "alternative_codes": ["5 D 1 a", "5D1a"], }, "5.D.1.b": { "title": "Low Activity Soils", "alternative_codes": ["5 D 1 b", "5D1b"], }, "5.D.1.c": {"title": "Sandy", "alternative_codes": ["5 D 1 c", "5D1c"]}, "5.D.1.d": {"title": "Volcanic", "alternative_codes": ["5 D 1 d", "5D1d"]}, "5.D.1.e": { "title": "Wetland (Aquic)", "alternative_codes": ["5 D 1 e", "5D1e"], }, "5.D.1.f": {"title": "Other", "alternative_codes": ["5 D 1 f", "5D1f"]}, "5.D.2.a": { "title": "Cool Temperate", "alternative_codes": ["5 D 2 a", "5D2a"], "children": [["5.D.2.a.i", "5.D.2.a.ii"]], }, "5.D.2.a.i": { "title": "Upland Crops", "alternative_codes": ["5 D 2 a i", "5D2ai"], }, "5.D.2.a.ii": { "title": "Pasture/Forest", "alternative_codes": ["5 D 2 a ii", "5D2aii"], }, "5.D.2.b": { "title": "Warm Temperate", "alternative_codes": ["5 D 2 b", "5D2b"], "children": [["5.D.2.b.i", "5.D.2.b.ii"]], }, "5.D.2.b.i": { "title": "Upland Crops", "alternative_codes": ["5 D 2 b i", "5D2bi"], }, "5.D.2.b.ii": { "title": "Pasture/Forest", "alternative_codes": ["5 D 2 b ii", "5D2bii"], }, "5.D.2.c": { "title": "Tropical", "alternative_codes": ["5 D 2 c", "5D2c"], "children": [["5.D.2.c.i", "5.D.2.c.ii"]], }, "5.D.2.c.i": { "title": "Upland Crops", "alternative_codes": ["5 D 2 c i", "5D2ci"], }, "5.D.2.c.ii": { "title": "Pasture/Forest", "alternative_codes": ["5 D 2 c ii", "5D2cii"], }, "5.D.3.a": {"title": "Limestone", "alternative_codes": ["5 D 3 a", "5D3a"]}, "5.D.3.b": {"title": "Dolomite", "alternative_codes": ["5 D 3 b", "5D3b"]}, "6.A.2.a": {"title": "deep (>5 m)", "alternative_codes": ["6 A 2 a", "6A2a"]}, "6.A.2.b": { "title": "shallow (<5 m)", "alternative_codes": ["6 A 2 b", "6A2b"], }, "6.C.1": {"title": "biogenic", "alternative_codes": ["6 C 1", "6C1"]}, "6.C.2": {"title": "plastics", "alternative_codes": ["6 C 2", "6C2"]}, "6.C.3": {"title": "other", "alternative_codes": ["6 C 3", "6C3"]}, "M.Memo": { "title": "Memo Items", "alternative_codes": ["M Memo", "MMemo"], "children": [["M.Memo.Bio", "M.Memo.Int", "M.Memo.Mult"]], }, "M.Memo.Int": { "title": "International Bunkers", "alternative_codes": ["M Memo Int", "MMemoInt"], "children": [["M.Memo.Int.Avi", "M.Memo.Int.Mar"]], }, "M.Memo.Int.Avi": { "title": "Aviation", "alternative_codes": ["M Memo Int Avi", "MMemoIntAvi"], }, "M.Memo.Int.Mar": { "title": "Marine", "alternative_codes": ["M Memo Int Mar", "MMemoIntMar"], }, "M.Memo.Mult": { "title": "Multilateral Operations", "alternative_codes": ["M Memo Mult", "MMemoMult"], }, "M.Memo.Bio": { "title": "CO2 Emissions from Biomass", "alternative_codes": ["M Memo Bio", "MMemoBio"], }, }, }
#!/usr/bin/env python # coding: utf-8 # In[13]: #site: https://www.geeksforgeeks.org/dijkstras-shortest-path-algorithm-greedy-algo-7/ # In[7]: # Python program for Dijkstra's single # source shortest path algorithm. The program is # for adjacency matrix representation of the graph class Graph(): def __init__(self, vertices): self.V = vertices self.graph = [[0 for column in range(vertices)] for row in range(vertices)] def printSolution(self, dist): print ("Vertex \tDistance from Source") for node in range(self.V): print (node, "\t", dist[node] ) # A utility function to find the vertex with # minimum distance value, from the set of vertices # not yet included in shortest path tree def minDistance(self, dist, sptSet): # Initilaize minimum distance for next node min = float("inf") # Search not nearest vertex not in the # shortest path tree for v in range(self.V): if dist[v] < min and sptSet[v] == False: min = dist[v] min_index = v return min_index # Funtion that implements Dijkstra's single source # shortest path algorithm for a graph represented # using adjacency matrix representation def dijkstra(self, src): dist = [float("inf") ] * self.V dist[src] = 0 sptSet = [False] * self.V for cout in range(self.V): # Pick the minimum distance vertex from # the set of vertices not yet processed. # u is always equal to src in first iteration u = self.minDistance(dist, sptSet) # Put the minimum distance vertex in the # shotest path tree sptSet[u] = True # Update dist value of the adjacent vertices # of the picked vertex only if the current # distance is greater than new distance and # the vertex in not in the shotest path tree for v in range(self.V): if self.graph[u][v] > 0 and sptSet[v] == False and dist[v] > dist[u] + self.graph[u][v]: dist[v] = dist[u] + self.graph[u][v] self.printSolution(dist) # In[10]: Q4b = Graph(8) matrix = [[0]*8 for i in range(8)] matrix[4][5] = 0.35 matrix[5][4] = -0.66 matrix[4][7] = 0.37 matrix[5][7] = 0.28 matrix[7][5] = 0.28 matrix[5][1] = 0.32 matrix[0][4] = 0.38 matrix[0][2] = 0.26 matrix[7][3] = 0.39 matrix[1][3] = 0.29 matrix[2][7] = 0.34 matrix[6][2] = 0.40 matrix[3][6] = 0.52 matrix[6][0] = 0.58 matrix[6][4] = 0.93 Q4b.graph = matrix Q4b.dijkstra(0) # In[11]: Q4a = Graph(8) matrix = [[0]*8 for i in range(8)] matrix[4][5] = 0.35 matrix[5][4] = 0.35 matrix[4][7] = 0.37 matrix[5][7] = 0.28 matrix[7][5] = 0.28 matrix[5][1] = 0.32 matrix[0][4] = 0.38 matrix[0][2] = 0.26 matrix[7][3] = 0.39 matrix[1][3] = 0.29 matrix[2][7] = 0.34 matrix[6][2] = -1.2 matrix[3][6] = 0.52 matrix[6][0] = -1.4 matrix[6][4] = -1.25 Q4a.graph = matrix Q4a.dijkstra(0) # In[ ]:
# process local states local = range(12) # L states L = {"x0" : [6], "x1" : [7], "x2" : [8], "f0" : [9], "f1" : [10], "f2" : [11], "v0" : [0, 3, 6, 9], "v1" : [1, 4, 7, 10], "v2" : [2, 5, 8, 11], "corr0" : [0, 6], "corr1" : [1, 7], "corr2" : [2, 8]} # receive variables rcv_vars = ["nr0", "nr1", "nr2"] # initial states initial = local # rules rules = [] rules.append({'idx': 0, 'from': 0, 'to': 0, 'guard': "(and (< nr1 1) (< nr2 1))"}) rules.append({'idx': 1, 'from': 0, 'to': 1, 'guard': "(>= nr1 1)"}) rules.append({'idx': 2, 'from': 0, 'to': 2, 'guard': "(>= nr2 1)"}) rules.append({'idx': 3, 'from': 1, 'to': 1, 'guard': "(and (< nr0 1) (< nr2 1))"}) rules.append({'idx': 4, 'from': 1, 'to': 0, 'guard': "(>= nr0 1)"}) rules.append({'idx': 5, 'from': 1, 'to': 2, 'guard': "(>= nr2 1)"}) rules.append({'idx': 6, 'from': 2, 'to': 2, 'guard': "(and (< nr0 1) (< nr1 1))"}) rules.append({'idx': 7, 'from': 2, 'to': 0, 'guard': "(>= nr0 1)"}) rules.append({'idx': 8, 'from': 2, 'to': 1, 'guard': "(>= nr1 1)"}) rules.append({'idx': 9, 'from': 0, 'to': 6, 'guard': "(and (< nr1 1) (< nr2 1))"}) rules.append({'idx': 10, 'from': 0, 'to': 7, 'guard': "(>= nr1 1)"}) rules.append({'idx': 11, 'from': 0, 'to': 8, 'guard': "(>= nr2 1)"}) rules.append({'idx': 12, 'from': 1, 'to': 7, 'guard': "(and (< nr0 1) (< nr2 1))"}) rules.append({'idx': 13, 'from': 1, 'to': 6, 'guard': "(>= nr0 1)"}) rules.append({'idx': 14, 'from': 1, 'to': 8, 'guard': "(>= nr2 1)"}) rules.append({'idx': 15, 'from': 2, 'to': 8, 'guard': "(and (< nr0 1) (< nr1 1))"}) rules.append({'idx': 16, 'from': 2, 'to': 6, 'guard': "(>= nr0 1)"}) rules.append({'idx': 17, 'from': 2, 'to': 7, 'guard': "(>= nr1 1)"}) rules.append({'idx': 18, 'from': 6, 'to': 0, 'guard': "(and (< nr1 1) (< nr2 1))"}) rules.append({'idx': 19, 'from': 6, 'to': 1, 'guard': "(>= nr1 1)"}) rules.append({'idx': 20, 'from': 6, 'to': 2, 'guard': "(>= nr2 1)"}) rules.append({'idx': 21, 'from': 7, 'to': 1, 'guard': "(and (< nr0 1) (< nr2 1))"}) rules.append({'idx': 22, 'from': 7, 'to': 0, 'guard': "(>= nr0 1)"}) rules.append({'idx': 23, 'from': 7, 'to': 2, 'guard': "(>= nr2 1)"}) rules.append({'idx': 24, 'from': 8, 'to': 2, 'guard': "(and (< nr0 1) (< nr1 1))"}) rules.append({'idx': 25, 'from': 8, 'to': 0, 'guard': "(>= nr0 1)"}) rules.append({'idx': 26, 'from': 8, 'to': 1, 'guard': "(>= nr1 1)"}) # send omission faulty rules.append({'idx': 27, 'from': 3, 'to': 3, 'guard': "(and (< nr1 1) (< nr2 1))"}) rules.append({'idx': 28, 'from': 3, 'to': 4, 'guard': "(>= nr1 1)"}) rules.append({'idx': 29, 'from': 3, 'to': 5, 'guard': "(>= nr2 1)"}) rules.append({'idx': 30, 'from': 4, 'to': 4, 'guard': "(and (< nr0 1) (< nr2 1))"}) rules.append({'idx': 31, 'from': 4, 'to': 3, 'guard': "(>= nr0 1)"}) rules.append({'idx': 32, 'from': 4, 'to': 5, 'guard': "(>= nr2 1)"}) rules.append({'idx': 33, 'from': 5, 'to': 5, 'guard': "(and (< nr0 1) (< nr1 1))"}) rules.append({'idx': 34, 'from': 5, 'to': 3, 'guard': "(>= nr0 1)"}) rules.append({'idx': 35, 'from': 5, 'to': 4, 'guard': "(>= nr1 1)"}) rules.append({'idx': 36, 'from': 3, 'to': 9, 'guard': "(and (< nr1 1) (< nr2 1))"}) rules.append({'idx': 37, 'from': 3, 'to': 10, 'guard': "(>= nr1 1)"}) rules.append({'idx': 38, 'from': 3, 'to': 11, 'guard': "(>= nr2 1)"}) rules.append({'idx': 39, 'from': 4, 'to': 10, 'guard': "(and (< nr0 1) (< nr2 1))"}) rules.append({'idx': 40, 'from': 4, 'to': 9, 'guard': "(>= nr0 1)"}) rules.append({'idx': 41, 'from': 4, 'to': 11, 'guard': "(>= nr2 1)"}) rules.append({'idx': 42, 'from': 5, 'to': 11, 'guard': "(and (< nr0 1) (< nr1 1))"}) rules.append({'idx': 43, 'from': 5, 'to': 9, 'guard': "(>= nr0 1)"}) rules.append({'idx': 44, 'from': 5, 'to': 10, 'guard': "(>= nr1 1)"}) rules.append({'idx': 45, 'from': 9, 'to': 3, 'guard': "(and (< nr1 1) (< nr2 1))"}) rules.append({'idx': 46, 'from': 9, 'to': 4, 'guard': "(>= nr1 1)"}) rules.append({'idx': 47, 'from': 9, 'to': 5, 'guard': "(>= nr2 1)"}) rules.append({'idx': 48, 'from': 10, 'to': 4, 'guard': "(and (< nr0 1) (< nr2 1))"}) rules.append({'idx': 49, 'from': 10, 'to': 3, 'guard': "(>= nr0 1)"}) rules.append({'idx': 50, 'from': 10, 'to': 5, 'guard': "(>= nr2 1)"}) rules.append({'idx': 51, 'from': 11, 'to': 5, 'guard': "(and (< nr0 1) (< nr1 1))"}) rules.append({'idx': 52, 'from': 11, 'to': 3, 'guard': "(>= nr0 1)"}) rules.append({'idx': 53, 'from': 11, 'to': 4, 'guard': "(>= nr1 1)"}) # parameters, resilience condition params = ["n", "t", "f"] active = "n" broadcast = [6, 7, 8, 9, 10, 11] rc = ["(> n 0)", "(>= t 0)", "(>= t f)", "(> n t)"] # faults faults = "send omission" faulty = [3, 4, 5, 9, 10, 11] broadcast_faulty = [9, 10, 11] max_faulty = "f" phase = 1 # configuration/transition constraints constraints = [] constraints.append({'type': 'configuration', 'sum': 'eq', 'object': local, 'result': active}) constraints.append({'type': 'configuration', 'sum': 'eq', 'object': faulty, 'result': max_faulty}) constraints.append({'type': 'configuration', 'sum': 'eq', 'object': broadcast, 'result': 2}) constraints.append({'type': 'transition', 'sum': 'eq', 'object': range(len(rules)), 'result': active}) constraints.append({'type': 'round_config', 'sum': 'le', 'object': broadcast_faulty, 'result': 1}) # receive environment constraints environment = [] environment.append('(>= nr0 x0)') environment.append('(<= nr0 (+ x0 f0))') environment.append('(>= nr1 x1)') environment.append('(<= nr1 (+ x1 f1))') environment.append('(>= nr2 x2)') environment.append('(<= nr2 (+ x2 f2))') # properties properties = [] properties.append({'name':'validity0', 'spec':'safety', 'initial':'(= v0 0)', 'qf':'last', 'reachable':'(> corr0 0)'}) properties.append({'name':'validity1', 'spec':'safety', 'initial':'(= v1 0)', 'qf':'last', 'reachable':'(> corr1 0)'}) properties.append({'name':'agreement', 'spec':'safety', 'initial':'true', 'qf':'last', 'reachable':'(and (> corr0 0) (> corr1 0) (> corr2 0))'})
class Solution: def removeDuplicates(self, nums: List[int]) -> int: l = len(nums) if l == 1: return 1 index = 1 num = nums[0] for i in range(1, l): if nums[i] == num: continue num = nums[i] nums[index] = nums[i] index += 1 return index
''' Define constraints (depends on your problem) https://stackoverflow.com/questions/42303470/scipy-optimize-inequality-constraint-which-side-of-the-inequality-is-considered [0.1268 0.467 0.5834 0.2103 -0.1268 -0.5425 -0.5096 0.0581] . The bounds are +/-30% of this. ''' t_base = [0.1268, 0.467, 0.5834, 0.2103, -0.1268, -0.5425, -0.5096, 0.0581] t_lower = [0.08876, 0.3269, 0.40838, 0.14721, -0.1648, -0.70525, -0.66248, 0.04067] t_upper = [0.1648, 0.6071, 0.75842, 0.27339, -0.08876, -0.37975, -0.35672, 0.07553] def f_factory(i): def f_lower(t): return t[i] - t_lower[i] def f_upper(t): return -t[i] + t_upper[i] return f_lower, f_upper functions = [] for i in range(len(t_base)): f_lower, f_upper = f_factory(i) functions.append(f_lower) functions.append(f_upper) cons=[] for ii in range(len(functions)): # the value of ii is set in each loop cons.append({'type': 'ineq', 'fun': functions[ii]}) if __name__ == '__main__': print('Constraints file')
__key_mapping = { 'return' : 'enter', 'up_arrow' : 'up', 'down_arrow' : 'down', 'left_arrow' : 'left', 'right_arrow' : 'right', 'page_up' : 'pageup', 'page_down' : 'pagedown', } def translate_key(e): if len(e.key) > 0: return __key_mapping[e.key] if e.key in __key_mapping else e.key else: if e.char == '\x08': return 'backspace' elif e.char == '\t': return 'tab' else: return e.key
""" sentry.pool.base ~~~~~~~~~~~~~~~~ :copyright: (c) 2010-2013 by the Sentry Team, see AUTHORS for more details. :license: BSD, see LICENSE for more details. """ class Pool(object): def __init__(self, keyspace): self.keyspace = keyspace self.queue = [] def put(self, item): self.queue.append(item) def get(self): return self.queue.pop()
class Solution: def wordPattern(self, pattern: str, str: str) -> bool: lst = str.split() combo = zip(pattern, lst) return len(set(pattern)) == len(set(lst)) == len(set(combo)) and len(pattern) == len(lst)
soma_idade=0 media_Idade=0 maior_idade_homem=0 nome_velho='' tot_mulher_20=0 for i in range(0,4): nome=str(input('Nome: ')).strip() idade=int(input('Idade: ')) sexo=str(input('Sexo: ')).strip() soma_idade+=idade if i==1 and sexo in 'Mm': maior_idade_homem=idade nome_velho=nome elif sexo in 'Mm' and idade>maior_idade_homem: maior_idade_homem=idade nome_velho=nome if sexo in 'Ff' and idade <20: tot_mulher_20+=1 media_Idade=soma_idade/4 print(media_Idade) print(maior_idade_homem,nome_velho) print(tot_mulher_20())
# -*- coding: utf-8 -*- """ Created on Fri Jan 31 11:53:09 2020 @author: aboutet """ def street_pattern_before(es, infos, insert): return {} def street_pattern(es, infos, data, documents): to_send = [] for json in data: if "LINK_ID" in json.keys(): link_id = "LINK_ID" else: link_id = "LINK_PVID" r = es.search(index=infos["here"], body={"query": {"match": {"LINK_ID": json[link_id]}}})["hits"]["hits"] json["TRAVEL_DIRECTION"] = True if json["TRAVEL_DIRECTION"] == "T" else False if r: if "geometry" in json: del json["geometry"] to_send.append({"update":{"_id":r[0]["_id"]}}) to_send.append({"doc": {key:value for key, value in json.items()}}) if to_send: resp = es.bulk(index=infos["here"], body=to_send, request_timeout=3000) def street_pattern_after(es, infos): return
"""The LinkedList code from before is provided below. Add three functions to the LinkedList. "get_position" returns the element at a certain position. The "insert" function will add an element to a particular spot in the list. "delete" will delete the first element with that particular value. Then, use "Test Run" and "Submit" to run the test cases at the bottom.""" class Element(object): def __init__(self, value): self.value = value self.next = None class LinkedList(object): def __init__(self, head=None): self.head = head def append(self, new_element): current = self.head if self.head: while current.next: current = current.next current.next = new_element else: self.head = new_element def __get__(self, node, counter): if node is None: return None if counter == 0: return node return self.__get__(node.next, counter - 1) def get_position(self, position): """Get an element from a particular position. Assume the first position is "1". Return "None" if position is not in the list.""" return self.__get__(self.head, position - 1) def __insert__(self, node, new_element, counter): if node is None: return new_element if counter == 0: new_element.next = node return new_element node.next = self.__insert__(node.next, new_element, counter - 1) return node def insert(self, new_element, position): """Insert a new node at the given position. Assume the first position is "1". Inserting at position 3 means between the 2nd and 3rd elements.""" self.head = self.__insert__(self.head, new_element, position - 1) def __delete_position__(self, node, value): if node is None: return None if node.value == value: return node.next node.next = self.__delete_position__(node.next, value) return node def delete(self, value): self.head = self.__delete_position__(self.head, value) if __name__ == '__main__': # Test cases # Set up some Elements e1 = Element(1) e2 = Element(2) e3 = Element(3) e4 = Element(4) # Start setting up a LinkedList ll = LinkedList(e1) ll.append(e2) ll.append(e3) # Test get_position # Should print 3 print(ll.head.next.next.value) # Should also print 3 print(ll.get_position(3).value) # Test insert ll.insert(e4, 3) # Should print 4 now print(ll.get_position(3).value) # Test delete ll.delete(1) # Should print 2 now print(ll.get_position(1).value) # Should print 4 now print(ll.get_position(2).value) # Should print 3 now print(ll.get_position(3).value)
# -*- coding: utf-8 -*- """Top-level package for Medzibrod.""" __author__ = """Michal Nalevanko""" __email__ = 'michal.nalevanko@gmail.com' __version__ = '0.1.0'
def AllToDec_ui(): i = int(input('Ausgangsystem (z.B. 8 für Oktal) ')) zahl = input('Ausgangszahl: ') input('Dezimalzahl: ') print(All2dec(zahl, i)) def All2dec(z, p): s = '' n = 0 for i in range(0, len(z)): n += int(z[len(z) - (i + 1)], p) * (p ** i) s += str(int(z[len(z) - (i + 1)], p)) + '*' + str(p ** i) + ' + ' s = s[:-3] + ' = ' + str(n) return s if __name__ == '__main__': AllToDec_ui()
# Copyright (c) 2020 Samplasion <samplasion@gmail.com> # # This software is released under the MIT License. # https://opensource.org/licenses/MIT TARGET = 2020 def main(): print("=============") print("= AoC Day 1 =") print("=============") print() with open("input.txt") as f: file = f.read() numbers = sorted(list(map(int, file.split("\n")))) phase1(numbers) phase2(numbers) def phase1(numbers): min = 0 max = -1 number = numbers[min] + numbers[max] while number != TARGET: if number > TARGET: max -= 1 else: min += 1 number = numbers[min] + numbers[max] # else: print("There's no pair of numbers that amounts to {}".format(TARGET)) print(f"[Part 1] {numbers[min]} and {numbers[max]} are the numbers that amount to {TARGET}. " + f"Their product is {numbers[min]*numbers[max]}") def phase2(numbers): for i in numbers: for j in numbers: for k in numbers: if i + j + k == TARGET: print(f"[Part 2] {i}, {j} and {k} are the numbers that amount to {TARGET}. " + f"Their product is {i*j*k}") return print(f"There's no group of 3 numbers that sums to {TARGET}.") if __name__ == '__main__': main()
SCHEMA = { # staff-and-student-information "all_students_count": "{short_code}PETALLC", "african_american_count": "{short_code}PETBLAC", "african_american_percent": "{short_code}PETBLAP", "american_indian_count": "{short_code}PETINDC", "american_indian_percent": "{short_code}PETINDP", "asian_count": "{short_code}PETASIC", "asian_percent": "{short_code}PETASIP", "hispanic_count": "{short_code}PETHISC", "hispanic_percent": "{short_code}PETHISP", "pacific_islander_count": "{short_code}PETPCIC", "pacific_islander_percent": "{short_code}PETPCIP", "two_or_more_races_count": "{short_code}PETTWOC", "two_or_more_races_percent": "{short_code}PETTWOP", "white_count": "{short_code}PETWHIC", "white_percent": "{short_code}PETWHIP", "early_childhood_education_count": "{short_code}PETGEEC", "early_childhood_education_percent": "{short_code}PETGEEP", "prek_count": "{short_code}PETGPKC", "prek_percent": "{short_code}PETGPKP", "kindergarten_count": "{short_code}PETGKNC", "kindergarten_percent": "{short_code}PETGKNP", "first_count": "{short_code}PETG01C", "first_percent": "{short_code}PETG01P", "second_count": "{short_code}PETG02C", "second_percent": "{short_code}PETG02P", "third_count": "{short_code}PETG03C", "third_percent": "{short_code}PETG03P", "fourth_count": "{short_code}PETG04C", "fourth_percent": "{short_code}PETG04P", "fifth_count": "{short_code}PETG05C", "fifth_percent": "{short_code}PETG05P", "sixth_count": "{short_code}PETG06C", "sixth_percent": "{short_code}PETG06P", "seventh_count": "{short_code}PETG07C", "seventh_percent": "{short_code}PETG07P", "eighth_count": "{short_code}PETG08C", "eighth_percent": "{short_code}PETG08P", "ninth_count": "{short_code}PETG09C", "ninth_percent": "{short_code}PETG09P", "tenth_count": "{short_code}PETG10C", "tenth_percent": "{short_code}PETG10P", "eleventh_count": "{short_code}PETG11C", "eleventh_percent": "{short_code}PETG11P", "twelfth_count": "{short_code}PETG12C", "twelfth_percent": "{short_code}PETG12P", "at_risk_count": "{short_code}PETRSKC", "at_risk_percent": "{short_code}PETRSKP", "economically_disadvantaged_count": "{short_code}PETECOC", "economically_disadvantaged_percent": "{short_code}PETECOP", "limited_english_proficient_count": "{short_code}PETLEPC", "limited_english_proficient_percent": "{short_code}PETLEPP", "bilingual_esl_count": "{short_code}PETBILC", "bilingual_esl_percent": "{short_code}PETBILP", "career_technical_education_count": "{short_code}PETVOCC", "career_technical_education_percent": "{short_code}PETVOCP", "gifted_and_talented_count": "{short_code}PETGIFC", "gifted_and_talented_percent": "{short_code}PETGIFP", "special_education_count": "{short_code}PETSPEC", "special_education_percent": "{short_code}PETSPEP", "class_size_avg_kindergarten": "{short_code}PCTGKGA", "class_size_avg_first": "{short_code}PCTG01A", "class_size_avg_second": "{short_code}PCTG02A", "class_size_avg_third": "{short_code}PCTG03A", "class_size_avg_fourth": "{short_code}PCTG04A", "class_size_avg_fifth": "{short_code}PCTG05A", "class_size_avg_sixth": "{short_code}PCTG06A", "class_size_avg_mixed_elementary": "{short_code}PCTGMEA", "class_size_avg_secondary_english": "{short_code}PCTENGA", "class_size_avg_secondary_foreign_language": "{short_code}PCTFLAA", "class_size_avg_secondary_math": "{short_code}PCTMATA", "class_size_avg_secondary_science": "{short_code}PCTSCIA", "class_size_avg_secondary_social_studies": "{short_code}PCTSOCA", "students_per_teacher": "{short_code}PSTKIDR", # teacher_avg_tenure is Average Years Experience of Teachers with District "teacher_avg_tenure": "{short_code}PSTTENA", # teacher_avg_experience is Average Years Experience of Teachers "teacher_avg_experience": "{short_code}PSTEXPA", "teacher_avg_base_salary": "{short_code}PSTTOSA", "teacher_avg_beginning_salary": "{short_code}PST00SA", "teacher_avg_1_to_5_year_salary": "{short_code}PST01SA", "teacher_avg_6_to_10_year_salary": "{short_code}PST06SA", "teacher_avg_11_to_20_year_salary": "{short_code}PST11SA", "teacher_avg_20_plus_year_salary": "{short_code}PST20SA", "teacher_total_fte_count": "{short_code}PSTTOFC", "teacher_african_american_fte_count": "{short_code}PSTBLFC", "teacher_american_indian_fte_count": "{short_code}PSTINFC", "teacher_asian_fte_count": "{short_code}PSTASFC", "teacher_hispanic_fte_count": "{short_code}PSTHIFC", "teacher_pacific_islander_fte_count": "{short_code}PSTPIFC", "teacher_two_or_more_races_fte_count": "{short_code}PSTTWFC", "teacher_white_fte_count": "{short_code}PSTWHFC", "teacher_total_fte_percent": "{short_code}PSTTOFC", "teacher_african_american_fte_percent": "{short_code}PSTBLFP", "teacher_american_indian_fte_percent": "{short_code}PSTINFP", "teacher_asian_fte_percent": "{short_code}PSTASFP", "teacher_hispanic_fte_percent": "{short_code}PSTHIFP", "teacher_pacific_islander_fte_percent": "{short_code}PSTPIFP", "teacher_two_or_more_races_fte_percent": "{short_code}PSTTWFP", "teacher_white_fte_percent": "{short_code}PSTWHFP", "teacher_no_degree_count": "{short_code}PSTNOFC", "teacher_bachelors_count": "{short_code}PSTBAFC", "teacher_masters_count": "{short_code}PSTMSFC", "teacher_doctorate_count": "{short_code}PSTPHFC", "teacher_no_degree_percent": "{short_code}PSTNOFP", "teacher_bachelors_percent": "{short_code}PSTBAFP", "teacher_masters_percent": "{short_code}PSTMSFP", "teacher_doctorate_percent": "{short_code}PSTPHFP", # postsecondary-readiness-and-non-staar-performance-indicators # 'college_ready_graduates_english_all_students_count': 'ACRR', "college_ready_graduates_english_all_students_percent": "{short_code}ACRR{year}R", # 'college_ready_graduates_english_african_american_count': 'BCRR', "college_ready_graduates_english_african_american_percent": "{short_code}BCRR{year}R", # 'college_ready_graduates_english_american_indian_count': 'ICRR', "college_ready_graduates_english_american_indian_percent": "{short_code}ICRR{year}R", # 'college_ready_graduates_english_asian_count': '3CRR', "college_ready_graduates_english_asian_percent": "{short_code}3CRR{year}R", # 'college_ready_graduates_english_hispanic_count': 'HCRR', "college_ready_graduates_english_hispanic_percent": "{short_code}HCRR{year}R", # 'college_ready_graduates_english_pacific_islander_count': '4CRR', "college_ready_graduates_english_pacific_islander_percent": "{short_code}4CRR{year}R", # 'college_ready_graduates_english_two_or_more_races_count': '2CRR', "college_ready_graduates_english_two_or_more_races_percent": "{short_code}2CRR{year}R", # 'college_ready_graduates_english_white_count': 'WCRR', "college_ready_graduates_english_white_percent": "{short_code}WCRR{year}R", # 'college_ready_graduates_english_economically_disadvantaged_count': 'ECRR', "college_ready_graduates_english_economically_disadvantaged_percent": "{short_code}ECRR{year}R", # 'college_ready_graduates_english_limited_english_proficient_count': 'LCRR', "college_ready_graduates_english_limited_english_proficient_percent": "{short_code}LCRR{year}R", # 'college_ready_graduates_english_at_risk_count': 'RCRR', "college_ready_graduates_english_at_risk_percent": "{short_code}RCRR{year}R", # 'college_ready_graduates_math_all_students_count': 'ACRM', "college_ready_graduates_math_all_students_percent": "{short_code}ACRM{year}R", # 'college_ready_graduates_math_african_american_count': 'BCRM', "college_ready_graduates_math_african_american_percent": "{short_code}BCRM{year}R", # 'college_ready_graduates_math_american_indian_count': 'ICRM', "college_ready_graduates_math_american_indian_percent": "{short_code}ICRM{year}R", # 'college_ready_graduates_math_asian_count': '3CRM', "college_ready_graduates_math_asian_percent": "{short_code}3CRM{year}R", # 'college_ready_graduates_math_hispanic_count': 'HCRM', "college_ready_graduates_math_hispanic_percent": "{short_code}HCRM{year}R", # 'college_ready_graduates_math_pacific_islander_count': '4CRM', "college_ready_graduates_math_pacific_islander_percent": "{short_code}4CRM{year}R", # 'college_ready_graduates_math_two_or_more_races_count': '2CRM', "college_ready_graduates_math_two_or_more_races_percent": "{short_code}2CRM{year}R", # 'college_ready_graduates_math_white_count': 'WCRM', "college_ready_graduates_math_white_percent": "{short_code}WCRM{year}R", # 'college_ready_graduates_math_economically_disadvantaged_count': 'ECRM', "college_ready_graduates_math_economically_disadvantaged_percent": "{short_code}ECRM{year}R", # 'college_ready_graduates_math_limited_english_proficient_count': 'LCRM', "college_ready_graduates_math_limited_english_proficient_percent": "{short_code}LCRM{year}R", # 'college_ready_graduates_math_at_risk_count': 'RCRM', "college_ready_graduates_math_at_risk_percent": "{short_code}RCRM{year}R", # 'college_ready_graduates_both_all_students_count': 'ACRB', "college_ready_graduates_both_all_students_percent": "{short_code}ACRB{year}R", # 'college_ready_graduates_both_african_american_count': 'BCRB', "college_ready_graduates_both_african_american_percent": "{short_code}BCRB{year}R", # 'college_ready_graduates_both_asian_count': '3CRB', "college_ready_graduates_both_asian_percent": "{short_code}3CRB{year}R", # 'college_ready_graduates_both_hispanic_count': 'HCRB', "college_ready_graduates_both_hispanic_percent": "{short_code}HCRB{year}R", # 'college_ready_graduates_both_american_indian_count': 'ICRB', "college_ready_graduates_both_american_indian_percent": "{short_code}ICRB{year}R", # 'college_ready_graduates_both_pacific_islander_count': '4CRB', "college_ready_graduates_both_pacific_islander_percent": "{short_code}4CRB{year}R", # 'college_ready_graduates_both_two_or_more_races_count': '2CRB', "college_ready_graduates_both_two_or_more_races_percent": "{short_code}2CRB{year}R", # 'college_ready_graduates_both_white_count': 'WCRB', "college_ready_graduates_both_white_percent": "{short_code}WCRB{year}R", # 'college_ready_graduates_both_economically_disadvantaged_count': 'ECRB', "college_ready_graduates_both_economically_disadvantaged_percent": "{short_code}ECRB{year}R", # 'college_ready_graduates_both_limited_english_proficient_count': 'LCRB', "college_ready_graduates_both_limited_english_proficient_percent": "{short_code}LCRB{year}R", # 'college_ready_graduates_both_at_risk_count': 'RCRB', "college_ready_graduates_both_at_risk_percent": "{short_code}RCRB{year}R", "avg_sat_score_all_students": "{short_code}A0CSA{year}R", "avg_sat_score_african_american": "{short_code}B0CSA{year}R", "avg_sat_score_american_indian": "{short_code}I0CSA{year}R", "avg_sat_score_asian": "{short_code}30CSA{year}R", "avg_sat_score_hispanic": "{short_code}H0CSA{year}R", "avg_sat_score_pacific_islander": "{short_code}40CSA{year}R", "avg_sat_score_two_or_more_races": "{short_code}20CSA{year}R", "avg_sat_score_white": "{short_code}W0CSA{year}R", "avg_sat_score_economically_disadvantaged": "{short_code}E0CSA{year}R", "avg_act_score_all_students": "{short_code}A0CAA{year}R", "avg_act_score_african_american": "{short_code}B0CAA{year}R", "avg_act_score_american_indian": "{short_code}I0CAA{year}R", "avg_act_score_asian": "{short_code}30CAA{year}R", "avg_act_score_hispanic": "{short_code}H0CAA{year}R", "avg_act_score_pacific_islander": "{short_code}40CAA{year}R", "avg_act_score_two_or_more_races": "{short_code}20CAA{year}R", "avg_act_score_white": "{short_code}W0CAA{year}R", "avg_act_score_economically_disadvantaged": "{short_code}E0CAA{year}R", # 'ap_ib_all_students_count_above_criterion': 'A0BKA', "ap_ib_all_students_percent_above_criterion": "{short_code}A0BKA{year}R", # 'ap_ib_african_american_count_above_criterion': 'B0BKA', "ap_ib_african_american_percent_above_criterion": "{short_code}B0BKA{year}R", # 'ap_ib_asian_count_above_criterion': '30BKA', "ap_ib_asian_percent_above_criterion": "{short_code}30BKA{year}R", # 'ap_ib_hispanic_count_above_criterion': 'H0BKA', "ap_ib_hispanic_percent_above_criterion": "{short_code}H0BKA{year}R", # 'ap_ib_american_indian_count_above_criterion': 'I0BKA', "ap_ib_american_indian_percent_above_criterion": "{short_code}I0BKA{year}R", # 'ap_ib_pacific_islander_count_above_criterion': '40BKA', "ap_ib_pacific_islander_percent_above_criterion": "{short_code}40BKA{year}R", # 'ap_ib_two_or_more_races_count_above_criterion': '20BKA', "ap_ib_two_or_more_races_percent_above_criterion": "{short_code}20BKA{year}R", # 'ap_ib_white_count_above_criterion': 'W0BKA', "ap_ib_white_percent_above_criterion": "{short_code}W0BKA{year}R", # 'ap_ib_economically_disadvantaged_count_above_criterion': 'E0BKA', "ap_ib_economically_disadvantaged_percent_above_criterion": "{short_code}E0BKA{year}R", "ap_ib_all_students_percent_taking": "{short_code}A0BTA{year}R", "ap_ib_african_american_percent_taking": "{short_code}B0BTA{year}R", "ap_ib_asian_percent_taking": "{short_code}30BTA{year}R", "ap_ib_hispanic_percent_taking": "{short_code}H0BTA{year}R", "ap_ib_american_indian_percent_taking": "{short_code}I0BTA{year}R", "ap_ib_pacific_islander_percent_taking": "{short_code}40BTA{year}R", "ap_ib_two_or_more_races_percent_taking": "{short_code}20BTA{year}R", "ap_ib_white_percent_taking": "{short_code}W0BTA{year}R", "ap_ib_economically_disadvantaged_percent_taking": "{short_code}E0BTA{year}R", # # 'dropout_all_students_count': 'A0912DR', # 'dropout_all_students_percent': 'A0912DR', # # 'dropout_african_american_count': 'B0912DR', # 'dropout_african_american_percent': 'B0912DR', # # 'dropout_asian_count': '30912DR', # 'dropout_asian_percent': '30912DR', # # 'dropout_hispanic_count': 'H0912DR', # 'dropout_hispanic_percent': 'H0912DR', # # 'dropout_american_indian_count': 'I0912DR', # 'dropout_american_indian_percent': 'I0912DR', # # 'dropout_pacific_islander_count': '40912DR', # 'dropout_pacific_islander_percent': '40912DR', # # 'dropout_two_or_more_races_count': '20912DR', # 'dropout_two_or_more_races_percent': '20912DR', # # 'dropout_white_count': 'W0912DR', # 'dropout_white_percent': 'W0912DR', # # 'dropout_at_risk_count': 'R0912DR', # 'dropout_at_risk_percent': 'R0912DR', # # 'dropout_economically_disadvantaged_count': 'E0912DR', # 'dropout_economically_disadvantaged_percent': 'E0912DR', # # 'dropout_limited_english_proficient_count': 'E0912DR', # 'dropout_limited_english_proficient_percent': 'E0912DR', # # 'four_year_graduate_all_students_count': 'AGC4X', # 'four_year_graduate_all_students_percent': 'AGC4X', # # 'four_year_graduate_african_american_count': 'BGC4X', # 'four_year_graduate_african_american_percent': 'BGC4X', # # 'four_year_graduate_american_indian_count': 'IGC4X', # 'four_year_graduate_american_indian_percent': 'IGC4X', # # 'four_year_graduate_asian_count': '3GC4X', # 'four_year_graduate_asian_percent': '3GC4X', # # 'four_year_graduate_hispanic_count': 'HGC4X', # 'four_year_graduate_hispanic_percent': 'HGC4X', # # 'four_year_graduate_pacific_islander_count': '4GC4X', # 'four_year_graduate_pacific_islander_percent': '4GC4X', # # 'four_year_graduate_two_or_more_races_count': '2GC4X', # 'four_year_graduate_two_or_more_races_percent': '2GC4X', # # 'four_year_graduate_white_count': 'WGC4X', # 'four_year_graduate_white_percent': 'WGC4X', # # 'four_year_graduate_at_risk_count': 'RGC4X', # 'four_year_graduate_at_risk_percent': 'RGC4X', # # 'four_year_graduate_economically_disadvantaged_count': 'EGC4X', # 'four_year_graduate_economically_disadvantaged_percent': 'EGC4X', # # 'four_year_graduate_limited_english_proficient_count': 'L3C4X', # 'four_year_graduate_limited_english_proficient_percent': 'L3C4X', # attendence "attendance_rate": "{short_code}A0AT{year}R", # longitudinal-rate # 'dropout_all_students_count': 'A0912DR', "dropout_all_students_percent": "{short_code}A0912DR{year}R", # 'dropout_african_american_count': 'B0912DR', "dropout_african_american_percent": "{short_code}B0912DR{year}R", # 'dropout_asian_count': '30912DR', "dropout_asian_percent": "{short_code}30912DR{year}R", # 'dropout_hispanic_count': 'H0912DR', "dropout_hispanic_percent": "{short_code}H0912DR{year}R", # 'dropout_american_indian_count': 'I0912DR', "dropout_american_indian_percent": "{short_code}I0912DR{year}R", # 'dropout_pacific_islander_count': '40912DR', "dropout_pacific_islander_percent": "{short_code}40912DR{year}R", # 'dropout_two_or_more_races_count': '20912DR', "dropout_two_or_more_races_percent": "{short_code}20912DR{year}R", # 'dropout_white_count': 'W0912DR', "dropout_white_percent": "{short_code}W0912DR{year}R", # 'dropout_at_risk_count': 'R0912DR', "dropout_at_risk_percent": "{short_code}R0912DR{year}R", # 'dropout_economically_disadvantaged_count': 'E0912DR', "dropout_economically_disadvantaged_percent": "{short_code}E0912DR{year}R", # 'dropout_limited_english_proficient_count': 'E0912DR', "dropout_limited_english_proficient_percent": "{short_code}E0912DR{year}R", # 'four_year_graduate_all_students_count': 'AGC4X', "four_year_graduate_all_students_percent": "{short_code}AGC4{suffix}{year}R", # 'four_year_graduate_african_american_count': 'BGC4X', "four_year_graduate_african_american_percent": "{short_code}BGC4{suffix}{year}R", # 'four_year_graduate_american_indian_count': 'IGC4X', "four_year_graduate_american_indian_percent": "{short_code}IGC4{suffix}{year}R", # 'four_year_graduate_asian_count': '3GC4X', "four_year_graduate_asian_percent": "{short_code}3GC4{suffix}{year}R", # 'four_year_graduate_hispanic_count': 'HGC4X', "four_year_graduate_hispanic_percent": "{short_code}HGC4{suffix}{year}R", # 'four_year_graduate_pacific_islander_count': '4GC4X', "four_year_graduate_pacific_islander_percent": "{short_code}4GC4{suffix}{year}R", # 'four_year_graduate_two_or_more_races_count': '2GC4X', "four_year_graduate_two_or_more_races_percent": "{short_code}2GC4{suffix}{year}R", # 'four_year_graduate_white_count': 'WGC4X', "four_year_graduate_white_percent": "{short_code}WGC4{suffix}{year}R", # 'four_year_graduate_at_risk_count': 'RGC4X', "four_year_graduate_at_risk_percent": "{short_code}RGC4{suffix}{year}R", # 'four_year_graduate_economically_disadvantaged_count': 'EGC4X', "four_year_graduate_economically_disadvantaged_percent": "{short_code}EGC4{suffix}{year}R", # 'four_year_graduate_limited_english_proficient_count': 'L3C4X', "four_year_graduate_limited_english_proficient_percent": "{short_code}L3C4{suffix}{year}R", # reference "accountability_rating": "{short_code}_RATING", # accountability "student_achievement_rating": "{short_code}D1G", "school_progress_rating": "{short_code}D2G", "closing_the_gaps_rating": "{short_code}D3G", }
# This problem was asked by Facebook. # Given an array of numbers representing the stock prices of a company in chronological # order and an integer k, return the maximum profit you can make from k buys and sells. # You must buy the stock before you can sell it, and you must sell the stock before you can buy it again. # For example, given k = 2 and the array [5, 2, 4, 0, 1], you should return 3. #### def get_max_profit(arr, k): a = arr + [-1] current_min = a[0] current_max = a[0] ends = [] # generate profit intervals # current_max == current_min denotes that the buying price was set during # the immediately previous loop (selling price not discovered yet) for i in range(1, len(a)): # more profit possible if a[i] > current_max: current_max = a[i] # the beginning of the next interval is found if a[i] < current_max and current_max != current_min: ends.append((current_min, current_max)) current_max = a[i] current_min = a[i] # buying cost is strictly decreasing (to calculate cheapest buying price) if a[i] < current_min and current_max == current_min: current_min = a[i] current_max = a[i] # merge smallest intervals to make number of intervals = k while k < len(ends): # get smallest interval pos, cur = min(list(enumerate(ends)), key = lambda x: x[1][1] - x[1][0]) # try merging with lower interval if pos != 0: lower = ends[pos-1] if cur[1] > lower[1]: ends[pos-1] = (lower[0], cur[1]) # try merging with upper interval if pos != len(ends)-1: upper = ends[pos+1] if cur[0] < upper[0]: ends[pos+1] = (cur[0], upper[1]) ends.remove(cur) return sum([y-x for x,y in ends]) #### print(get_max_profit([7, 9, 8, 11, 11, 10, 12, 15, 13, 10], 2))
def file_html(fname): fptr=open(fname,"r") to_send = "" for lines in fptr: to_send += lines; return to_send #file_html("myfile.html");
md = [0,0] facing = "E" def rotate(cw, val): idx = 4 + cw * int((val/90) % 4) mv = ['E','S','W','N'] c = mv.index(facing) return mv[(idx + c) % 4] def move(dr, val): global ew global ns global facing if dr == 'N': md[1] += val elif dr == 'S': md[1] -= val elif dr == 'E': md[0] += val elif dr == 'W': md[0] -= val elif dr == 'L': facing = rotate(-1,val) elif dr == 'R': facing = rotate(+1,val) elif dr == 'F': move(facing,val) ############################## for l in open("input.txt"): move(list(l)[0], int(''.join(list(l.strip())[1:]))) print("Manhattan distance =", abs(md[0]) + abs(md[1]))
for _ in range(int(input())): n,x = map(int,input().split()) l = list(map(int,input().split())) flag=2 if len(set(l)) == 1 and l[0] == x: flag=0 elif x in l or sum([i-x for i in l])==0: flag=1 if flag==0: print(0) elif flag==1: print(1) else: print(2)
""" Take the block of text provided and strip off the whitespace at both ends. Split the text by newline (\n) using split. Loop through the lines and if the first character of each (stripped) line is lowercase, split the line into words and add the last word to the (given) results list, stripping the trailing dot (.) and exclamation mark (!) from the end of the word. At the end of the function return the results list. """ text = """ One really nice feature of Python is polymorphism: using the same operation on different types of objects. Let's talk about an elegant feature: slicing. You can use this on a string as well as a list for example 'pybites'[0:2] gives 'py'. The first value is inclusive and the last one is exclusive so here we grab indexes 0 and 1, the letter p and y. When you have a 0 index you can leave it out so can write this as 'pybites'[:2] but here is the kicker: you can use this on a list too! ['pybites', 'teaches', 'you', 'Python'][-2:] would gives ['you', 'Python'] and now you know about slicing from the end as well :) keep enjoying our bites! """ def slice_and_dice(text=text): results = [] strip_text = text.strip("\n") split_strip = strip_text.split("\n") for i in split_strip: i = i.strip(" ") if i[0].islower(): strip_i = i.strip('!.') split_i = strip_i.split(" ") results.append(split_i[-1]) return results
""" domonic.constants.keyboard ==================================== """ class KeyCode(): A = '65' #: ALTERNATE = '18' #: B = '66' #: BACKQUOTE = '192' #: BACKSLASH = '220' #: BACKSPACE = '8' #: C = '67' #: CAPS_LOCK = '20' #: COMMA = '188' #: COMMAND = '15' #: CONTROL = '17' #: D = '68' #: DELETE = '46' #: DOWN = '40' #: E = '69' #: END = '35' #: ENTER = '13' #: RETURN = '13' #: EQUAL = '187' #: ESCAPE = '27' #: F = '70' #: F1 = '112' #: F10 = '121' #: F11 = '122' #: F12 = '123' #: F13 = '124' #: F14 = '125' #: F15 = '126' #: F2 = '113' #: F3 = '114' #: F4 = '115' #: F5 = '116' #: F6 = '117' #: F7 = '118' #: F8 = '119' #: F9 = '120' #: G = '71' #: H = '72' #: HOME = '36' #: I = '73' #: INSERT = '45' #: J = '74' #: K = '75' #: L = '76' #: LEFT = '37' #: LEFTBRACKET = '219' #: M = '77' #: MINUS = '189' #: N = '78' #: NUMBER_0 = '48' #: NUMBER_1 = '49' #: NUMBER_2 = '50' #: NUMBER_3 = '51' #: NUMBER_4 = '52' #: NUMBER_5 = '53' #: NUMBER_6 = '54' #: NUMBER_7 = '55' #: NUMBER_8 = '56' #: NUMBER_9 = '57' #: NUMPAD = '21' #: NUMPAD_0 = '96' #: NUMPAD_1 = '97' #: NUMPAD_2 = '98' #: NUMPAD_3 = '99' #: NUMPAD_4 = '100' #: NUMPAD_5 = '101' #: NUMPAD_6 = '102' #: NUMPAD_7 = '103' #: NUMPAD_8 = '104' #: NUMPAD_9 = '105' #: NUMPAD_ADD = '107' #: NUMPAD_DECIMAL = '110' #: NUMPAD_DIVIDE = '111' #: NUMPAD_ENTER = '108' #: NUMPAD_MULTIPLY = '106' #: NUMPAD_SUBTRACT = '109' #: O = '79' #: P = '80' #: PAGE_DOWN = '34' #: PAGE_UP = '33' #: PERIOD = '190' #: Q = '81' #: QUOTE = '222' #: R = '82' #: RIGHT = '39' #: RIGHTBRACKET = '221' #: S = '83' #: SEMICOLON = '186' #: SHIFT = '16' #: ?? left or right or both? SLASH = '191' #: SPACE = '32' #: T = '84' #: TAB = '9' #: U = '85' #: UP = '38' #: V = '86' #: W = '87' #: X = '88' #: Y = '89' #: Z = '9' #: # TODO - do the modifiers # find attribute by value # def get_letter(self, attr): # for key, value in self.__dict__.iteritems(): # if value == attr: # return key # return None def __init__(self): """ constructor for the keyboard class """ pass
#!/usr/bin/env python # configure these settings to change projector behavior server_mount_path = '//192.168.42.11/PiShare' # shared folder on other pi user_name = 'pi' # shared drive login user name user_password = 'raspberry' # shared drive login password client_mount_path = '/mnt/pishare' # where to find the shared folder on this pi pics_folder = '/mnt/pishare/pics' # where to find the pics to display waittime = 2 # default time to wait between images (in seconds) use_prime = True # Set to true to show the prime slide, false if otherwise prime_slide = '/home/pi/photobooth/projector.png' # image to show regularly in slideshow prime_freq = 16 # how many pics to show before showing the prime slide again monitor_w = 800 # width in pixels of display (monitor or projector) monitor_h = 600 # height in pixels of display (monitor or projector) title = "SlideShow" # caption of the window...
class Solution: def boldWords(self, words, S): """ :type words: List[str] :type S: str :rtype: str """ m = len(S) flags = [False] * m for word in words: n = len(word) for i in range(m - n + 1): if S[i:i + n] == word: flags[i:i + n] = [True] * n ans = [] for i, (flag, ch) in enumerate(zip(flags, S)): if flag: if i == 0 or not flags[i - 1]: ans.append('<b>') ans.append(ch) if i == m - 1 or not flags[i + 1]: ans.append('</b>') else: ans.append(ch) return ''.join(ans)
data = ( 'E ', # 0x00 'Cheng ', # 0x01 'Xin ', # 0x02 'Ai ', # 0x03 'Lu ', # 0x04 'Zhui ', # 0x05 'Zhou ', # 0x06 'She ', # 0x07 'Pian ', # 0x08 'Kun ', # 0x09 'Tao ', # 0x0a 'Lai ', # 0x0b 'Zong ', # 0x0c 'Ke ', # 0x0d 'Qi ', # 0x0e 'Qi ', # 0x0f 'Yan ', # 0x10 'Fei ', # 0x11 'Sao ', # 0x12 'Yan ', # 0x13 'Jie ', # 0x14 'Yao ', # 0x15 'Wu ', # 0x16 'Pian ', # 0x17 'Cong ', # 0x18 'Pian ', # 0x19 'Qian ', # 0x1a 'Fei ', # 0x1b 'Huang ', # 0x1c 'Jian ', # 0x1d 'Huo ', # 0x1e 'Yu ', # 0x1f 'Ti ', # 0x20 'Quan ', # 0x21 'Xia ', # 0x22 'Zong ', # 0x23 'Kui ', # 0x24 'Rou ', # 0x25 'Si ', # 0x26 'Gua ', # 0x27 'Tuo ', # 0x28 'Kui ', # 0x29 'Sou ', # 0x2a 'Qian ', # 0x2b 'Cheng ', # 0x2c 'Zhi ', # 0x2d 'Liu ', # 0x2e 'Pang ', # 0x2f 'Teng ', # 0x30 'Xi ', # 0x31 'Cao ', # 0x32 'Du ', # 0x33 'Yan ', # 0x34 'Yuan ', # 0x35 'Zou ', # 0x36 'Sao ', # 0x37 'Shan ', # 0x38 'Li ', # 0x39 'Zhi ', # 0x3a 'Shuang ', # 0x3b 'Lu ', # 0x3c 'Xi ', # 0x3d 'Luo ', # 0x3e 'Zhang ', # 0x3f 'Mo ', # 0x40 'Ao ', # 0x41 'Can ', # 0x42 'Piao ', # 0x43 'Cong ', # 0x44 'Qu ', # 0x45 'Bi ', # 0x46 'Zhi ', # 0x47 'Yu ', # 0x48 'Xu ', # 0x49 'Hua ', # 0x4a 'Bo ', # 0x4b 'Su ', # 0x4c 'Xiao ', # 0x4d 'Lin ', # 0x4e 'Chan ', # 0x4f 'Dun ', # 0x50 'Liu ', # 0x51 'Tuo ', # 0x52 'Zeng ', # 0x53 'Tan ', # 0x54 'Jiao ', # 0x55 'Tie ', # 0x56 'Yan ', # 0x57 'Luo ', # 0x58 'Zhan ', # 0x59 'Jing ', # 0x5a 'Yi ', # 0x5b 'Ye ', # 0x5c 'Tuo ', # 0x5d 'Bin ', # 0x5e 'Zou ', # 0x5f 'Yan ', # 0x60 'Peng ', # 0x61 'Lu ', # 0x62 'Teng ', # 0x63 'Xiang ', # 0x64 'Ji ', # 0x65 'Shuang ', # 0x66 'Ju ', # 0x67 'Xi ', # 0x68 'Huan ', # 0x69 'Li ', # 0x6a 'Biao ', # 0x6b 'Ma ', # 0x6c 'Yu ', # 0x6d 'Tuo ', # 0x6e 'Xun ', # 0x6f 'Chi ', # 0x70 'Qu ', # 0x71 'Ri ', # 0x72 'Bo ', # 0x73 'Lu ', # 0x74 'Zang ', # 0x75 'Shi ', # 0x76 'Si ', # 0x77 'Fu ', # 0x78 'Ju ', # 0x79 'Zou ', # 0x7a 'Zhu ', # 0x7b 'Tuo ', # 0x7c 'Nu ', # 0x7d 'Jia ', # 0x7e 'Yi ', # 0x7f 'Tai ', # 0x80 'Xiao ', # 0x81 'Ma ', # 0x82 'Yin ', # 0x83 'Jiao ', # 0x84 'Hua ', # 0x85 'Luo ', # 0x86 'Hai ', # 0x87 'Pian ', # 0x88 'Biao ', # 0x89 'Li ', # 0x8a 'Cheng ', # 0x8b 'Yan ', # 0x8c 'Xin ', # 0x8d 'Qin ', # 0x8e 'Jun ', # 0x8f 'Qi ', # 0x90 'Qi ', # 0x91 'Ke ', # 0x92 'Zhui ', # 0x93 'Zong ', # 0x94 'Su ', # 0x95 'Can ', # 0x96 'Pian ', # 0x97 'Zhi ', # 0x98 'Kui ', # 0x99 'Sao ', # 0x9a 'Wu ', # 0x9b 'Ao ', # 0x9c 'Liu ', # 0x9d 'Qian ', # 0x9e 'Shan ', # 0x9f 'Piao ', # 0xa0 'Luo ', # 0xa1 'Cong ', # 0xa2 'Chan ', # 0xa3 'Zou ', # 0xa4 'Ji ', # 0xa5 'Shuang ', # 0xa6 'Xiang ', # 0xa7 'Gu ', # 0xa8 'Wei ', # 0xa9 'Wei ', # 0xaa 'Wei ', # 0xab 'Yu ', # 0xac 'Gan ', # 0xad 'Yi ', # 0xae 'Ang ', # 0xaf 'Tou ', # 0xb0 'Xie ', # 0xb1 'Bao ', # 0xb2 'Bi ', # 0xb3 'Chi ', # 0xb4 'Ti ', # 0xb5 'Di ', # 0xb6 'Ku ', # 0xb7 'Hai ', # 0xb8 'Qiao ', # 0xb9 'Gou ', # 0xba 'Kua ', # 0xbb 'Ge ', # 0xbc 'Tui ', # 0xbd 'Geng ', # 0xbe 'Pian ', # 0xbf 'Bi ', # 0xc0 'Ke ', # 0xc1 'Ka ', # 0xc2 'Yu ', # 0xc3 'Sui ', # 0xc4 'Lou ', # 0xc5 'Bo ', # 0xc6 'Xiao ', # 0xc7 'Pang ', # 0xc8 'Bo ', # 0xc9 'Ci ', # 0xca 'Kuan ', # 0xcb 'Bin ', # 0xcc 'Mo ', # 0xcd 'Liao ', # 0xce 'Lou ', # 0xcf 'Nao ', # 0xd0 'Du ', # 0xd1 'Zang ', # 0xd2 'Sui ', # 0xd3 'Ti ', # 0xd4 'Bin ', # 0xd5 'Kuan ', # 0xd6 'Lu ', # 0xd7 'Gao ', # 0xd8 'Gao ', # 0xd9 'Qiao ', # 0xda 'Kao ', # 0xdb 'Qiao ', # 0xdc 'Lao ', # 0xdd 'Zao ', # 0xde 'Biao ', # 0xdf 'Kun ', # 0xe0 'Kun ', # 0xe1 'Ti ', # 0xe2 'Fang ', # 0xe3 'Xiu ', # 0xe4 'Ran ', # 0xe5 'Mao ', # 0xe6 'Dan ', # 0xe7 'Kun ', # 0xe8 'Bin ', # 0xe9 'Fa ', # 0xea 'Tiao ', # 0xeb 'Peng ', # 0xec 'Zi ', # 0xed 'Fa ', # 0xee 'Ran ', # 0xef 'Ti ', # 0xf0 'Pao ', # 0xf1 'Pi ', # 0xf2 'Mao ', # 0xf3 'Fu ', # 0xf4 'Er ', # 0xf5 'Rong ', # 0xf6 'Qu ', # 0xf7 'Gong ', # 0xf8 'Xiu ', # 0xf9 'Gua ', # 0xfa 'Ji ', # 0xfb 'Peng ', # 0xfc 'Zhua ', # 0xfd 'Shao ', # 0xfe 'Sha ', # 0xff )
"""Top-level package for ML Model Evaluation Toolkit.""" __author__ = """Nicolas Kaenzig""" __email__ = "nkaenzig@gmail.com" __version__ = "0.1.0"
# Author: Rémi Adon <remi.adon@gmail.com> # License: BSD 3 clause def binary_to_int(b): if isinstance(b, int): return b else: return int(b, 2) def char_code(s, idx=0): return ord(s[idx]) PHONES = [ # +--------- Confident # |+-------- Labial # ||+------- Liquid # |||+------ Dental # ||||+----- Plosive # |||||+---- Fricative # ||||||+--- Nasal # |||||||+-- Discriminant # |||||||| "0", # a "01001000", # b "00001100", # c "00011000", # d "0", # e "01000100", # f "00001000", # g "00000100", # h "1", # i "00000101", # j "00001001", # k "10100000", # l "00000010", # m "00010010", # n "0", # o "01001001", # p "10101000", # q "10100001", # r "00010100", # s "00011101", # t "1", # u "01000101", # v "00000000", # w "10000100", # x "1", # y "10010100", # z ] PHONES = list(map(binary_to_int, PHONES)) LETTERS = len(PHONES) PHONES_C1 = [ PHONES[char_code("s") - char_code("a")] ^ 1, # ß "0", # à "0", # á "0", # â "0", # ã "0", # ä [æ] "1", # å [oː] "0", # æ [æ] PHONES[char_code("z") - char_code("a")] ^ 1, # ç [t͡ʃ] "1", # è "1", # é "1", # ê "1", # ë "1", # ì "1", # í "1", # î "1", # ï "00010101", # ð [ð̠] (represented as a non-plosive T) "00010111", # ñ [nj] (represented as a combination of n and j) "0", # ò "0", # ó "0", # ô "0", # õ "1", # ö [ø] "1", # ÷ "1", # ø [ø] "1", # ù "1", # ú "1", # û "1", # ü "1", # ý "00010101", # þ [ð̠] (represented as a non-plosive T) "1", # ÿ ] PHONES_C1 = list(map(binary_to_int, PHONES_C1)) INJECTIVE_PHONES = [ # +--------- Vowel # |+-------- Closer than ɜ # ||+------- Close # |||+------ Front # ||||+----- Close-mid # |||||+---- Central # ||||||+--- Open-mid # |||||||+-- Discriminant # |||||||| (*=vowel) "10000100", # a* "00100100", # b "00000110", # c "00001100", # d "11011000", # e* "00100010", # f "00000100", # g "00000010", # h "11111000", # i* "00000011", # j "00000101", # k "01010000", # l "00000001", # m "00001001", # n "10010100", # o* "00100101", # p "01010100", # q "01010001", # r "00001010", # s "00001110", # t "11100000", # u* "00100011", # v "00000000", # w "01000010", # x "11100100", # y* "01001010", # z ] INJECTIVE_PHONES = list(map(binary_to_int, INJECTIVE_PHONES)) INJECTIVE_PHONES_C1 = [ # +--------- Vowel # |+-------- Closer than ɜ # ||+------- Close # |||+------ Front # ||||+----- Close-mid # |||||+---- Central # ||||||+--- Open-mid # |||||||+-- Discriminant # |||||||| INJECTIVE_PHONES[char_code("s") - char_code("a")] ^ 1, # ß INJECTIVE_PHONES[char_code("a") - char_code("a")] ^ 1, # à INJECTIVE_PHONES[char_code("a") - char_code("a")] ^ 1, # á "10000000", # â "10000110", # ã "10100110", # ä [æ] "11000010", # å [oː] "10100111", # æ [æ] "01010100", # ç [t͡ʃ] INJECTIVE_PHONES[char_code("e") - char_code("a")] ^ 1, # è INJECTIVE_PHONES[char_code("e") - char_code("a")] ^ 1, # é INJECTIVE_PHONES[char_code("e") - char_code("a")] ^ 1, # ê "11000110", # ë [ə] or [œ] INJECTIVE_PHONES[char_code("i") - char_code("a")] ^ 1, # ì INJECTIVE_PHONES[char_code("i") - char_code("a")] ^ 1, # í INJECTIVE_PHONES[char_code("i") - char_code("a")] ^ 1, # î INJECTIVE_PHONES[char_code("i") - char_code("a")] ^ 1, # ï "00001011", # ð [ð̠] (represented as a non-plosive T) "00001011", # ñ [nj] (represented as a combination of n and j) INJECTIVE_PHONES[char_code("o") - char_code("a")] ^ 1, # ò INJECTIVE_PHONES[char_code("o") - char_code("a")] ^ 1, # ó INJECTIVE_PHONES[char_code("o") - char_code("a")] ^ 1, # ô INJECTIVE_PHONES[char_code("o") - char_code("a")] ^ 1, # õ "11011100", # ö [œ] or [ø] "1", # ÷ "11011101", # ø [œ] or [ø] INJECTIVE_PHONES[char_code("u") - char_code("a")] ^ 1, # ù INJECTIVE_PHONES[char_code("u") - char_code("a")] ^ 1, # ú INJECTIVE_PHONES[char_code("u") - char_code("a")] ^ 1, # û INJECTIVE_PHONES[char_code("y") - char_code("a")] ^ 1, # ü INJECTIVE_PHONES[char_code("y") - char_code("a")] ^ 1, # ý "00001011", # þ [ð̠] (represented as a non-plosive T) INJECTIVE_PHONES[char_code("y") - char_code("a")] ^ 1, # ÿ ] INJECTIVE_PHONES_C1 = list(map(binary_to_int, INJECTIVE_PHONES_C1)) A = char_code("a") Z = char_code("z") def eudex(sequence): """ Apply eudex on the input string and return the result as a left-padded binary representation The result is a hash Warning: numerical distance cannot be applied on that hash, `eudex(a) - eudex(b)` has no sense Rather, one should apply hamming distance on the binary representation Parameters ---------- sequence: string input string Examples -------- >>>> eudex('Jeff Buckley') 235392249864232960 >>>> eudex('Tim Buckley') 1009448435818536960 >>> bin(eudex('Jeff Buckley'))[-20:] == bin(eudex('Tim Buckley'))[-20:] # check last 20 bits True Returns ------- res : str """ entry = ((char_code(sequence) | 32) - A) & 0xFF if sequence else 0 first_byte = 0 if entry < LETTERS: first_byte = INJECTIVE_PHONES[entry] else: if 0xDF <= entry < 0xFF: first_byte = INJECTIVE_PHONES_C1[entry - 0xDF] res, n, b = 0, 0, 1 while n < 8 and b < len(sequence): entry = ((char_code(sequence, idx=b) | 32) - A) & 0xFF if entry <= Z: x = 0 if entry < LETTERS: x = PHONES[entry] elif 0xDF <= entry < 0xFF: x = PHONES_C1[entry - 0xDF] else: b += 1 continue if (res & 0xFE) != (x & 0xFE): res = res << 8 res |= x n += 1 b += 1 return res | (first_byte << 56)
def remove_duplicated_keep_order(value_in_tuple): new_tuple = [] for i in value_in_tuple: if not (i in new_tuple): new_tuple.append(i) return new_tuple # return tuple(set(value_in_tuple))
# Licensed under a 3-clause BSD style license - see LICENSE.rst def get_package_data(): return { _ASTROPY_PACKAGE_NAME_ + '.tests': ['coveragerc', 'data/*.hdr'] # noqa }
exp.set('total_responses', 0) exp.set('total_correct', 0) exp.set('total_response_time', 0) exp.set('average_response_time', 'NA') exp.set('avg_rt', 'NA') exp.set('accuracy', 'NA') exp.set('acc', 'NA')