content
stringlengths
7
1.05M
#Task https://adventofcode.com/2020/day/2 inputExample = [['2-3','r','rrnr'], ['5-10','n','ltnnnknnvcnnn'], ['7-9','p','jtpptpllpj'], ['2-5','s','slssssszssssssss'], ['16-17','d','dddddddddddddddlp'], ['2-5','q','bbwqqbkmdhqmjhn'], ['7-10','m','qmpgmmsmmmmkmmkj'], ['1-3','a','abcde'], ['4-7','g','vczggdgbgxgg']] def getValidPasswords(inputL): validPasswords = 0 for row in inputL: ic = 0 rule = row[0].split('-') #client has a last minute change request #occurence = row[2].count(row[1]) #if occurence >= int(rule[0]) and occurence <= int(rule[1]): # validPasswords += 1 for idx, c in enumerate(row[2]): if(row[1] == c): if(idx == int(rule[0])-1): ic += 1 if(idx == int(rule[1])-1): ic += 1 if(ic == 1): validPasswords += 1 return validPasswords print(getValidPasswords(inputExample))
# -*- coding: utf-8 -*- DESC = "live-2018-08-01" INFO = { "DropLiveStream": { "params": [ { "name": "StreamName", "desc": "流名称。" }, { "name": "DomainName", "desc": "您的加速域名。" }, { "name": "AppName", "desc": "应用名称。" } ], "desc": "断开推流连接,但可以重新推流" }, "DescribeLiveWatermarks": { "params": [], "desc": "查询水印列表" }, "CreateLiveRecord": { "params": [ { "name": "StreamName", "desc": "流名称。" }, { "name": "AppName", "desc": "推流App名。" }, { "name": "DomainName", "desc": "推流域名。多域名推流必须设置。" }, { "name": "StartTime", "desc": "录制开始时间。中国标准时间,需要URLEncode。如 2017-01-01 10:10:01,编码为:2017-01-01+10%3a10%3a01。\n定时录制模式,必须设置该字段;实时视频录制模式,忽略该字段。" }, { "name": "EndTime", "desc": "录制结束时间。中国标准时间,需要URLEncode。如 2017-01-01 10:30:01,编码为:2017-01-01+10%3a30%3a01。\n定时录制模式,必须设置该字段;实时录制模式,为可选字段。如果通过Highlight参数,设置录制为实时视频录制模式,其设置的结束时间不应超过当前时间+30分钟,如果设置的结束时间超过当前时间+30分钟或者小于当前时间或者不设置该参数,则实际结束时间为当前时间+30分钟。" }, { "name": "RecordType", "desc": "录制类型。\n“video” : 音视频录制【默认】。\n“audio” : 纯音频录制。\n在定时录制模式或实时视频录制模式下,该参数均有效,不区分大小写。" }, { "name": "FileFormat", "desc": "录制文件格式。其值为:\n“flv”,“hls”,”mp4”,“aac”,”mp3”,默认“flv”。\n在定时录制模式或实时视频录制模式下,该参数均有效,不区分大小写。" }, { "name": "Highlight", "desc": "开启实时视频录制模式标志。0:不开启实时视频录制模式,即采用定时录制模式【默认】;1:开启实时视频录制模式。" }, { "name": "MixStream", "desc": "开启A+B=C混流C流录制标志。0:不开启A+B=C混流C流录制【默认】;1:开启A+B=C混流C流录制。\n在定时录制模式或实时视频录制模式下,该参数均有效。" }, { "name": "StreamParam", "desc": "录制流参数。当前支持以下参数:\nrecord_interval - 录制分片时长,单位 秒,1800 - 7200\nstorage_time - 录制文件存储时长,单位 秒\neg. record_interval=3600&storage_time=2592000\n注:参数需要url encode。\n在定时录制模式或实时视频录制模式下,该参数均有效。" } ], "desc": "- 使用前提\n 1. 录制文件存放于点播平台,所以用户如需使用录制功能,需首先自行开通点播服务。\n 2. 录制文件存放后相关费用(含存储以及下行播放流量)按照点播平台计费方式收取,具体请参考 [对应文档](https://cloud.tencent.com/document/product/266/2838)。\n\n- 模式说明\n 该接口支持两种录制模式:\n 1. 定时录制模式【默认模式】。\n 需要传入开始时间与结束时间,录制任务根据时间自动开始与结束。\n 2. 实时视频录制模式。\n 忽略传入的开始时间,在录制任务创建后立即开始录制,录制时长支持最大为30分钟,如果传入的结束时间与当前时间差大于30分钟,则按30分钟计算,实时视频录制主要用于录制精彩视频场景,时长建议控制在5分钟以内。\n\n- 注意事项\n 1. 调用接口超时设置应大于3秒,小于3秒重试以及频繁调用都有可能产生重复录制任务。" }, "UpdateLiveWatermark": { "params": [ { "name": "WatermarkId", "desc": "水印ID。" }, { "name": "PictureUrl", "desc": "水印图片url。" }, { "name": "XPosition", "desc": "显示位置,X轴偏移。" }, { "name": "YPosition", "desc": "显示位置,Y轴偏移。" }, { "name": "WatermarkName", "desc": "水印名称。" } ], "desc": "更新水印" }, "ModifyLiveSnapshotTemplate": { "params": [ { "name": "TemplateId", "desc": "模板Id。" }, { "name": "TemplateName", "desc": "模板名称。" }, { "name": "Description", "desc": "描述信息。" }, { "name": "SnapshotInterval", "desc": "截图时间间隔" }, { "name": "Width", "desc": "截图宽度。" }, { "name": "Height", "desc": "截图高度。" }, { "name": "PornFlag", "desc": "是否开启鉴黄,0:不开启,1:开启。" }, { "name": "CosAppId", "desc": "Cos AppId。" }, { "name": "CosBucket", "desc": "Cos Bucket名称。" }, { "name": "CosRegion", "desc": "Cos 地域。" } ], "desc": "修改截图模板配置" }, "ModifyLiveRecordTemplate": { "params": [ { "name": "TemplateId", "desc": "模板Id。" }, { "name": "TemplateName", "desc": "模板名称。" }, { "name": "Description", "desc": "描述信息。" }, { "name": "FlvParam", "desc": "Flv录制参数,开启Flv录制时设置。" }, { "name": "HlsParam", "desc": "Hls录制参数,开启hls录制时设置。" }, { "name": "Mp4Param", "desc": "Mp4录制参数,开启Mp4录制时设置。" }, { "name": "AacParam", "desc": "Aac录制参数,开启Aac录制时设置。" } ], "desc": "修改录制模板配置" }, "CreateLiveWatermarkRule": { "params": [ { "name": "DomainName", "desc": "推流域名。" }, { "name": "AppName", "desc": "推流路径。" }, { "name": "StreamName", "desc": "流名称。" }, { "name": "TemplateId", "desc": "水印Id,即调用[AddLiveWatermark](/document/product/267/30154)接口返回的WatermarkId。" } ], "desc": "创建水印规则,需要先调用[AddLiveWatermark](/document/product/267/30154)接口添加水印,将返回的水印id绑定到流使用。" }, "DescribeLiveStreamEventList": { "params": [ { "name": "StartTime", "desc": "起始时间。 \nUTC 格式,例如:2018-12-29T19:00:00Z。\n支持查询60天内的历史记录。" }, { "name": "EndTime", "desc": "结束时间。\nUTC 格式,例如:2018-12-29T20:00:00Z。\n不超过当前时间,且和起始时间相差不得超过30天。" }, { "name": "AppName", "desc": "应用名称。" }, { "name": "DomainName", "desc": "推流域名。" }, { "name": "StreamName", "desc": "流名称,不支持通配符(*)查询,默认模糊匹配。\n可使用IsStrict字段改为精确查询。" }, { "name": "PageNum", "desc": "取得第几页。\n默认值:1。\n注: 目前只支持10000条内的查询。" }, { "name": "PageSize", "desc": "分页大小。\n最大值:100。\n取值范围:1~100 之前的任意整数。\n默认值:10。\n注: 目前只支持10000条内的查询。" }, { "name": "IsFilter", "desc": "是否过滤,默认不过滤。\n0:不进行任何过滤。\n1:过滤掉开播失败的,只返回开播成功的。" }, { "name": "IsStrict", "desc": "是否精确查询,默认模糊匹配。\n0:模糊匹配。\n1:精确查询。\n注:使用StreamName时该参数生效。" }, { "name": "IsAsc", "desc": "是否按结束时间正序显示,默认逆序。\n0:逆序。\n1:正序。" } ], "desc": "查询推断流事件" }, "DescribePullStreamConfigs": { "params": [ { "name": "ConfigId", "desc": "配置id。" } ], "desc": "查询拉流配置" }, "DescribeProvinceIspPlayInfoList": { "params": [ { "name": "StartTime", "desc": "起始时间点,当前使用北京时间,\n例:2019-02-21 10:00:00。" }, { "name": "EndTime", "desc": "结束时间点,当前使用北京时间,\n例:2019-02-21 12:00:00。\n注:EndTime 和 StartTime 只支持最近1天的数据查询。" }, { "name": "Granularity", "desc": "支持如下粒度:\n1:1分钟粒度(跨度不支持超过1天)" }, { "name": "StatType", "desc": "统计指标类型:\n“Bandwidth”:带宽\n“FluxPerSecond”:平均流量\n“Flux”:流量\n“Request”:请求数\n“Online”:并发连接数" }, { "name": "PlayDomains", "desc": "播放域名列表。" }, { "name": "ProvinceNames", "desc": "非必传参数,要查询的省份(地区)英文名称列表,如 Beijing" }, { "name": "IspNames", "desc": "非必传参数,要查询的运营商英文名称列表,如 China Mobile ,如果为空,查询所有运营商的数据" } ], "desc": "查询某省份某运营商下行播放数据,包括带宽,流量,请求数,并发连接数信息。" }, "ModifyLivePushAuthKey": { "params": [ { "name": "DomainName", "desc": "推流域名。" }, { "name": "Enable", "desc": "是否启用,0:关闭,1:启用。" }, { "name": "MasterAuthKey", "desc": "主鉴权key。" }, { "name": "BackupAuthKey", "desc": "备鉴权key。" }, { "name": "AuthDelta", "desc": "有效时间,单位:秒。" } ], "desc": "修改直播推流鉴权key" }, "DescribeLiveSnapshotRules": { "params": [], "desc": "获取截图规则列表" }, "DeleteLiveTranscodeTemplate": { "params": [ { "name": "TemplateId", "desc": "模板Id。" } ], "desc": "删除转码模板" }, "ModifyPullStreamStatus": { "params": [ { "name": "ConfigIds", "desc": "配置id列表。" }, { "name": "Status", "desc": "目标状态。0无效,2正在运行,4暂停。" } ], "desc": "修改直播拉流配置状态" }, "DescribeLiveRecordTemplates": { "params": [], "desc": "获取录制模板列表" }, "ModifyLiveDomainCert": { "params": [ { "name": "DomainName", "desc": "播放域名。" }, { "name": "CertId", "desc": "证书Id。" }, { "name": "Status", "desc": "状态,0:关闭 1:打开。" } ], "desc": "修改域名和证书绑定信息" }, "ResumeDelayLiveStream": { "params": [ { "name": "AppName", "desc": "应用名称。" }, { "name": "DomainName", "desc": "您的加速域名。" }, { "name": "StreamName", "desc": "流名称。" } ], "desc": "恢复延迟播放设置" }, "DescribeLiveDomainCert": { "params": [ { "name": "DomainName", "desc": "播放域名。" } ], "desc": "获取域名证书信息" }, "AddLiveWatermark": { "params": [ { "name": "PictureUrl", "desc": "水印图片url。" }, { "name": "WatermarkName", "desc": "水印名称。" }, { "name": "XPosition", "desc": "显示位置,X轴偏移。" }, { "name": "YPosition", "desc": "显示位置,Y轴偏移。" } ], "desc": "添加水印,成功返回水印id后,需要调用[CreateLiveWatermarkRule](/document/product/267/32629)接口将水印id绑定到流使用。" }, "DeleteLiveWatermarkRule": { "params": [ { "name": "DomainName", "desc": "推流域名。" }, { "name": "AppName", "desc": "推流路径。" }, { "name": "StreamName", "desc": "流名称。" } ], "desc": "删除水印规则" }, "DeleteLiveCallbackRule": { "params": [ { "name": "DomainName", "desc": "推流域名。" }, { "name": "AppName", "desc": "推流路径。" } ], "desc": "删除回调规则" }, "ModifyPullStreamConfig": { "params": [ { "name": "ConfigId", "desc": "配置id。" }, { "name": "FromUrl", "desc": "源Url。" }, { "name": "ToUrl", "desc": "目的Url。" }, { "name": "AreaId", "desc": "区域id,1-深圳,2-上海,3-天津,4-香港。如有改动,需同时传入IspId。" }, { "name": "IspId", "desc": "运营商id,1-电信,2-移动,3-联通,4-其他,AreaId为4的时候,IspId只能为其他。如有改动,需同时传入AreaId。" }, { "name": "StartTime", "desc": "开始时间。\n使用UTC格式时间,\n例如:2019-01-08T10:00:00Z。" }, { "name": "EndTime", "desc": "结束时间,注意:\n1. 结束时间必须大于开始时间;\n2. 结束时间和开始时间必须大于当前时间;\n3. 结束时间 和 开始时间 间隔必须小于七天。\n\n使用UTC格式时间,\n例如:2019-01-08T10:00:00Z。" } ], "desc": "更新拉流配置" }, "CreateLiveSnapshotTemplate": { "params": [ { "name": "TemplateName", "desc": "模板名称。非空的字符串。" }, { "name": "CosAppId", "desc": "Cos AppId。" }, { "name": "CosBucket", "desc": "Cos Bucket名称。" }, { "name": "CosRegion", "desc": "Cos地区。" }, { "name": "Description", "desc": "描述信息。" }, { "name": "SnapshotInterval", "desc": "截图间隔,单位s,默认10s。" }, { "name": "Width", "desc": "截图宽度。默认:0(原始宽)。" }, { "name": "Height", "desc": "截图高度。默认:0(原始高)。" }, { "name": "PornFlag", "desc": "是否开启鉴黄,0:不开启,1:开启。默认:0。" } ], "desc": "创建截图模板,成功返回模板id后,需要调用[CreateLiveSnapshotRule](/document/product/267/32625)接口,将模板id绑定到流使用。\n<br>截图相关文档:[直播截图](/document/product/267/32737)。" }, "DescribeLiveStreamOnlineList": { "params": [ { "name": "DomainName", "desc": "推流域名。" }, { "name": "AppName", "desc": "应用名称。" }, { "name": "PageNum", "desc": "取得第几页,默认1。" }, { "name": "PageSize", "desc": "每页大小,最大100。 \n取值:10~100之间的任意整数。\n默认值:10。" }, { "name": "StreamName", "desc": "流名称,精确查询。" } ], "desc": "返回正在直播中的流列表" }, "DeleteLiveCallbackTemplate": { "params": [ { "name": "TemplateId", "desc": "模板Id。" } ], "desc": "删除回调模板" }, "DescribeLivePushAuthKey": { "params": [ { "name": "DomainName", "desc": "推流域名。" } ], "desc": "查询直播推流鉴权key" }, "DeletePullStreamConfig": { "params": [ { "name": "ConfigId", "desc": "配置id。" } ], "desc": "删除直播拉流配置" }, "DescribeLiveRecordTemplate": { "params": [ { "name": "TemplateId", "desc": "模板Id。" } ], "desc": "获取单个录制模板" }, "DeleteLiveWatermark": { "params": [ { "name": "WatermarkId", "desc": "水印ID。" } ], "desc": "删除水印" }, "SetLiveWatermarkStatus": { "params": [ { "name": "WatermarkId", "desc": "水印ID。" }, { "name": "Status", "desc": "状态。0:停用,1:启用" } ], "desc": "设置水印是否启用" }, "AddDelayLiveStream": { "params": [ { "name": "AppName", "desc": "应用名称。" }, { "name": "DomainName", "desc": "您的加速域名。" }, { "name": "StreamName", "desc": "流名称。" }, { "name": "DelayTime", "desc": "延播时间,单位:秒,上限:600秒。" }, { "name": "ExpireTime", "desc": "延播设置的过期时间。UTC 格式,例如:2018-11-29T19:00:00Z。\n注意:默认7天后过期,且最长支持7天内生效。" } ], "desc": "对流设置延播时间\n注意:如果在推流前设置延播,需要提前5分钟设置。\n" }, "DescribeStreamDayPlayInfoList": { "params": [ { "name": "DayTime", "desc": "日期,\n格式:YYYY-mm-dd。" }, { "name": "PlayDomain", "desc": "播放域名。" }, { "name": "PageNum", "desc": "页号,范围[1,10],默认值是1。" }, { "name": "PageSize", "desc": "每页个数,范围[100,1000],默认值是1000。" } ], "desc": "查询天维度每条流的播放数据,包括总流量等。" }, "ModifyLivePlayDomain": { "params": [ { "name": "DomainName", "desc": "播放域名。" }, { "name": "PlayType", "desc": "拉流域名类型。1-国内;2-全球;3-境外" } ], "desc": "修改播放域名信息" }, "ModifyLiveTranscodeTemplate": { "params": [ { "name": "TemplateId", "desc": "模板Id。" }, { "name": "Vcodec", "desc": "视频编码:\nh264/h265。" }, { "name": "Acodec", "desc": "音频编码:\naac/mp3。" }, { "name": "AudioBitrate", "desc": "音频码率,默认0。0-500" }, { "name": "Description", "desc": "模板描述。" }, { "name": "VideoBitrate", "desc": "视频码率。100-8000" }, { "name": "Width", "desc": "宽。0-3000" }, { "name": "NeedVideo", "desc": "是否保留视频,0:否,1:是。默认1。" }, { "name": "NeedAudio", "desc": "是否保留音频,0:否,1:是。默认1。" }, { "name": "Height", "desc": "高。0-3000" }, { "name": "Fps", "desc": "帧率。0-200" }, { "name": "Gop", "desc": "关键帧间隔,单位:秒。0-50" }, { "name": "Rotate", "desc": "旋转角度。0 90 180 270" }, { "name": "Profile", "desc": "编码质量:\nbaseline/main/high。" }, { "name": "BitrateToOrig", "desc": "是否不超过原始码率。0:否,1:是。默认0。" }, { "name": "HeightToOrig", "desc": "是否不超过原始高。0:否,1:是。默认0。" }, { "name": "FpsToOrig", "desc": "是否不超过原始帧率。0:否,1:是。默认0。" } ], "desc": "修改转码模板配置" }, "DeleteLiveTranscodeRule": { "params": [ { "name": "DomainName", "desc": "推流域名。域名维度转码,域名+AppName+StreamName唯一标识单个转码规则,如需删除需要强匹配,比如AppName为空也需要传空字符串进行强匹配" }, { "name": "AppName", "desc": "推流路径。域名+AppName+StreamName+TemplateId唯一标识单个转码规则,如需删除需要强匹配,比如AppName为空也需要传空字符串进行强匹配" }, { "name": "StreamName", "desc": "流名称。域名+AppName+StreamName+TemplateId唯一标识单个转码规则,如需删除需要强匹配,比如AppName为空也需要传空字符串进行强匹配" }, { "name": "TemplateId", "desc": "模板ID域名+AppName+StreamName+TemplateId唯一标识单个转码规则,如需删除需要强匹配,比如AppName为空也需要传空字符串进行强匹配" } ], "desc": "删除转码规则" }, "DescribeLiveCerts": { "params": [], "desc": "获取证书信息列表" }, "DescribeLiveForbidStreamList": { "params": [ { "name": "PageNum", "desc": "取得第几页,默认1。" }, { "name": "PageSize", "desc": "每页大小,最大100。 \n取值:1~100之前的任意整数。\n默认值:10。" } ], "desc": "获取禁推流列表" }, "DescribeLiveCert": { "params": [ { "name": "CertId", "desc": "证书Id。" } ], "desc": "获取证书信息" }, "ModifyLiveCert": { "params": [ { "name": "CertId", "desc": "证书Id。" }, { "name": "CertType", "desc": "证书类型。0-用户添加证书;1-腾讯云托管证书。" }, { "name": "CertName", "desc": "证书名称。" }, { "name": "HttpsCrt", "desc": "证书内容,即公钥。" }, { "name": "HttpsKey", "desc": "私钥。" }, { "name": "Description", "desc": "描述信息。" } ], "desc": "修改证书" }, "DescribeLiveDomains": { "params": [ { "name": "DomainStatus", "desc": "域名状态过滤。0-停用,1-启用" }, { "name": "DomainType", "desc": "域名类型过滤。0-推流,1-播放" }, { "name": "PageSize", "desc": "分页大小,范围:10~100。默认10" }, { "name": "PageNum", "desc": "取第几页,范围:1~100000。默认1" } ], "desc": "根据域名状态、类型等信息查询用户的域名信息" }, "DeleteLiveCert": { "params": [ { "name": "CertId", "desc": "证书Id。" } ], "desc": "删除域名对应的证书" }, "CreateLiveCallbackTemplate": { "params": [ { "name": "TemplateName", "desc": "模板名称。非空的字符串" }, { "name": "Description", "desc": "描述信息。" }, { "name": "StreamBeginNotifyUrl", "desc": "开播回调URL,\n相关协议文档:[事件消息通知](/document/product/267/32744)。" }, { "name": "StreamEndNotifyUrl", "desc": "断流回调URL,\n相关协议文档:[事件消息通知](/document/product/267/32744)。" }, { "name": "RecordNotifyUrl", "desc": "录制回调URL,\n相关协议文档:[事件消息通知](/document/product/267/32744)。" }, { "name": "SnapshotNotifyUrl", "desc": "截图回调URL,\n相关协议文档:[事件消息通知](/document/product/267/32744)。" }, { "name": "PornCensorshipNotifyUrl", "desc": "鉴黄回调URL,\n相关协议文档:[事件消息通知](/document/product/267/32741)。" }, { "name": "CallbackKey", "desc": "回调key,回调URL公用,鉴权回调说明详见回调格式文档" } ], "desc": "创建回调模板,成功返回模板id后,需要调用[CreateLiveCallbackRule](/document/product/267/32638)接口将模板id绑定到域名/路径使用。\n<br>回调协议相关文档:[事件消息通知](/document/product/267/32744)。" }, "ResumeLiveStream": { "params": [ { "name": "AppName", "desc": "应用名称。" }, { "name": "DomainName", "desc": "您的加速域名。" }, { "name": "StreamName", "desc": "流名称。" } ], "desc": "恢复某条流的推送。" }, "DescribeLiveCallbackTemplate": { "params": [ { "name": "TemplateId", "desc": "模板Id。" } ], "desc": "获取单个回调模板" }, "DeleteLiveDomain": { "params": [ { "name": "DomainName", "desc": "要删除的域名" }, { "name": "DomainType", "desc": "类型。0-推流,1-播放" } ], "desc": "删除已添加的直播域名" }, "ModifyLiveCallbackTemplate": { "params": [ { "name": "TemplateId", "desc": "模板Id。" }, { "name": "TemplateName", "desc": "模板名称。" }, { "name": "Description", "desc": "描述信息。" }, { "name": "StreamBeginNotifyUrl", "desc": "开播回调URL。" }, { "name": "StreamEndNotifyUrl", "desc": "断流回调URL。" }, { "name": "RecordNotifyUrl", "desc": "录制回调URL。" }, { "name": "SnapshotNotifyUrl", "desc": "截图回调URL。" }, { "name": "PornCensorshipNotifyUrl", "desc": "鉴黄回调URL。" }, { "name": "CallbackKey", "desc": "回调key,回调URL公用,鉴权回调说明详见回调格式文档" } ], "desc": "修改回调模板" }, "DescribeProIspPlaySumInfoList": { "params": [ { "name": "StartTime", "desc": "起始时间,北京时间,\n格式:yyyy-mm-dd HH:MM:SS。" }, { "name": "EndTime", "desc": "结束时间,北京时间,\n格式:yyyy-mm-dd HH:MM:SS。\n注:EndTime 和 StartTime 只支持最近1天的数据查询。" }, { "name": "StatType", "desc": "统计的类型,可选值包括”Province”,”Isp”" }, { "name": "PlayDomains", "desc": "不填则为总体数据。" }, { "name": "PageNum", "desc": "页号,\n范围是[1,1000],\n默认值是1" }, { "name": "PageSize", "desc": "每页个数,范围是[1,1000],\n默认值是20" } ], "desc": "查询某段时间内每个省份每个运营商的平均每秒流量,总流量,总请求数信息。" }, "DescribeStreamPlayInfoList": { "params": [ { "name": "StartTime", "desc": "开始时间,北京时间,\n当前时间 和 开始时间 间隔不超过30天。" }, { "name": "EndTime", "desc": "结束时间,北京时间,\n结束时间 和 开始时间 必须在同一天内。" }, { "name": "PlayDomain", "desc": "播放域名,\n若不填,则为查询所有播放域名的在线流数据。" }, { "name": "StreamName", "desc": "流名称,精确匹配。\n若不填,则为查询总体播放数据。" } ], "desc": "查询播放数据,支持按流名称查询详细播放数据,也可按播放域名查询详细总数据。" }, "CreateLiveCert": { "params": [ { "name": "CertType", "desc": "证书类型。0-用户添加证书;1-腾讯云托管证书。" }, { "name": "HttpsCrt", "desc": "证书内容,即公钥。" }, { "name": "HttpsKey", "desc": "私钥。" }, { "name": "CertName", "desc": "证书名称。" }, { "name": "Description", "desc": "描述。" } ], "desc": "添加证书" }, "DescribeLiveTranscodeRules": { "params": [], "desc": "获取转码规则列表" }, "DescribeLiveSnapshotTemplate": { "params": [ { "name": "TemplateId", "desc": "模板Id。" } ], "desc": "获取单个截图模板" }, "DescribeLiveCallbackTemplates": { "params": [], "desc": "获取回调模板列表" }, "DescribeLiveSnapshotTemplates": { "params": [], "desc": "获取截图模板列表" }, "StopLiveRecord": { "params": [ { "name": "StreamName", "desc": "流名称。" }, { "name": "TaskId", "desc": "任务ID,全局唯一标识录制任务。" } ], "desc": "说明:录制后的文件存放于点播平台。用户如需使用录制功能,需首先自行开通点播账号并确保账号可用。录制文件存放后,相关费用(含存储以及下行播放流量)按照点播平台计费方式收取,请参考对应文档。" }, "ModifyLivePlayAuthKey": { "params": [ { "name": "DomainName", "desc": "域名。" }, { "name": "Enable", "desc": "是否启用,0:关闭,1:启用。" }, { "name": "AuthKey", "desc": "鉴权key。" }, { "name": "AuthDelta", "desc": "有效时间,单位:秒。" }, { "name": "AuthBackKey", "desc": "鉴权backkey。" } ], "desc": "修改播放鉴权key" }, "DescribeLiveTranscodeTemplate": { "params": [ { "name": "TemplateId", "desc": "模板Id。" } ], "desc": "获取单个转码模板" }, "UnBindLiveDomainCert": { "params": [ { "name": "DomainName", "desc": "播放域名。" } ], "desc": "解绑域名证书" }, "DescribeLiveTranscodeDetailInfo": { "params": [ { "name": "DayTime", "desc": "起始时间,北京时间,\n格式:yyyymmdd。\n注意:当前只支持查询近30天内某天的详细数据。" }, { "name": "PushDomain", "desc": "推流域名。" }, { "name": "StreamName", "desc": "流名称。" }, { "name": "PageNum", "desc": "页数,默认1,\n不超过100页。" }, { "name": "PageSize", "desc": "每页个数,默认20,\n范围:[10,1000]。" } ], "desc": "支持查询某天的转码详细信息。\n注意:当前只支持查询近30天内某天的详细数据。" }, "DescribeLogDownloadList": { "params": [ { "name": "StartTime", "desc": "开始时间,北京时间。\n格式:yyyy-mm-dd HH:MM:SS。" }, { "name": "EndTime", "desc": "结束时间,北京时间。\n格式:yyyy-mm-dd HH:MM:SS。\n注意:结束时间 - 开始时间 <=7天。" }, { "name": "PlayDomains", "desc": "域名列表。" } ], "desc": "批量获取日志URL。" }, "DescribeLiveStreamOnlineInfo": { "params": [ { "name": "PageNum", "desc": "取得第几页。\n默认值:1。" }, { "name": "PageSize", "desc": "分页大小。\n最大值:100。\n取值范围:1~100 之前的任意整数。\n默认值:10。" }, { "name": "Status", "desc": "0:未开始推流 1:正在推流" }, { "name": "StreamName", "desc": "流名称。" } ], "desc": "查询在线推流信息列表" }, "DescribeLiveRecordRules": { "params": [], "desc": "获取录制规则列表" }, "DescribeLiveStreamPublishedList": { "params": [ { "name": "DomainName", "desc": "您的域名。" }, { "name": "EndTime", "desc": "结束时间。\nUTC 格式,例如:2016-06-30T19:00:00Z。\n不超过当前时间。" }, { "name": "StartTime", "desc": "起始时间。 \nUTC 格式,例如:2016-06-29T19:00:00Z。\n和当前时间相隔不超过7天。" }, { "name": "AppName", "desc": "直播流所属应用名称。" }, { "name": "PageNum", "desc": "取得第几页。\n默认值:1。" }, { "name": "PageSize", "desc": "分页大小。\n最大值:100。\n取值范围:1~100 之前的任意整数。\n默认值:10。" } ], "desc": "返回已经推过流的流列表" }, "DescribeLiveDomain": { "params": [ { "name": "DomainName", "desc": "域名。" } ], "desc": "查询直播域名信息" }, "CreateLiveCallbackRule": { "params": [ { "name": "DomainName", "desc": "推流域名。" }, { "name": "AppName", "desc": "推流路径。" }, { "name": "TemplateId", "desc": "模板ID。" } ], "desc": "创建回调规则,需要先调用[CreateLiveCallbackTemplate](/document/product/267/32637)接口创建回调模板,将返回的模板id绑定到域名/路径进行使用。\n<br>回调协议相关文档:[事件消息通知](/document/product/267/32744)。" }, "BindLiveDomainCert": { "params": [ { "name": "CertId", "desc": "证书Id。" }, { "name": "DomainName", "desc": "播放域名。" }, { "name": "Status", "desc": "状态,0: 关闭 1:打开。" } ], "desc": "域名绑定证书" }, "DescribeLiveCallbackRules": { "params": [], "desc": "获取回调规则列表" }, "DeleteLiveRecordRule": { "params": [ { "name": "DomainName", "desc": "推流域名。域名+AppName+StreamName唯一标识单个转码规则,如需删除需要强匹配,比如AppName为空也需要传空字符串进行强匹配" }, { "name": "AppName", "desc": "推流路径。域名+AppName+StreamName唯一标识单个转码规则,如需删除需要强匹配,比如AppName为空也需要传空字符串进行强匹配" }, { "name": "StreamName", "desc": "流名称。域名+AppName+StreamName唯一标识单个转码规则,如需删除需要强匹配,比如AppName为空也需要传空字符串进行强匹配" } ], "desc": "删除录制规则" }, "ForbidLiveStream": { "params": [ { "name": "AppName", "desc": "应用名称。" }, { "name": "DomainName", "desc": "您的加速域名。" }, { "name": "StreamName", "desc": "流名称。" }, { "name": "ResumeTime", "desc": "恢复流的时间。UTC 格式,例如:2018-11-29T19:00:00Z。\n注意:默认禁播90天,且最长支持禁播90天。" } ], "desc": "禁止某条流的推送,可以预设某个时刻将流恢复。" }, "AddLiveDomain": { "params": [ { "name": "DomainName", "desc": "域名名称" }, { "name": "DomainType", "desc": "域名类型。0-推流域名,1-播放域名" }, { "name": "PlayType", "desc": "拉流域名类型。1-国内;2-全球;3-境外" } ], "desc": "添加域名,一次只能提交一个域名。域名必须已备案。" }, "CreateLiveRecordRule": { "params": [ { "name": "DomainName", "desc": "推流域名。" }, { "name": "AppName", "desc": "推流路径。" }, { "name": "StreamName", "desc": "流名称。" }, { "name": "TemplateId", "desc": "模板Id。" } ], "desc": "创建录制规则,需要先调用[CreateLiveRecordTemplate](/document/product/267/32614)接口创建录制模板,将返回的模板id绑定到流使用。\n<br>录制相关文档:[直播录制](/document/product/267/32739)。" }, "DescribeLiveWatermark": { "params": [ { "name": "WatermarkId", "desc": "水印ID。" } ], "desc": "获取单个水印信息" }, "DescribeLiveTranscodeTemplates": { "params": [], "desc": "获取转码模板列表" }, "CreateLiveRecordTemplate": { "params": [ { "name": "TemplateName", "desc": "模板名。非空的字符串" }, { "name": "Description", "desc": "描述信息。" }, { "name": "FlvParam", "desc": "Flv录制参数,开启Flv录制时设置。" }, { "name": "HlsParam", "desc": "Hls录制参数,开启hls录制时设置。" }, { "name": "Mp4Param", "desc": "Mp4录制参数,开启Mp4录制时设置。" }, { "name": "AacParam", "desc": "Aac录制参数,开启Aac录制时设置。" } ], "desc": "创建录制模板,成功返回模板id后,需要调用[CreateLiveRecordRule](/document/product/267/32615)接口,将模板id绑定到流进行使用。\n<br>录制相关文档:[直播录制](/document/product/267/32739)。" }, "ForbidLiveDomain": { "params": [ { "name": "DomainName", "desc": "停用的直播域名" } ], "desc": "停用使用某个直播域名" }, "CreateLiveTranscodeRule": { "params": [ { "name": "DomainName", "desc": "推流域名。" }, { "name": "AppName", "desc": "推流路径。" }, { "name": "StreamName", "desc": "流名称。" }, { "name": "TemplateId", "desc": "指定已有的模板Id。" } ], "desc": "创建转码规则,需要先调用[CreateLiveTranscodeTemplate](/document/product/267/32646)接口创建转码模板,将返回的模板id绑定到流使用。\n<br>转码相关文档:[直播转封装及转码](/document/product/267/32736)。" }, "DescribeLiveWatermarkRules": { "params": [], "desc": "获取水印规则列表" }, "DeleteLiveRecord": { "params": [ { "name": "StreamName", "desc": "流名称。" }, { "name": "TaskId", "desc": "任务ID,全局唯一标识录制任务。" } ], "desc": "用于删除录制任务" }, "CreateLiveSnapshotRule": { "params": [ { "name": "DomainName", "desc": "推流域名。" }, { "name": "AppName", "desc": "推流路径。" }, { "name": "StreamName", "desc": "流名称。" }, { "name": "TemplateId", "desc": "模板Id。" } ], "desc": "创建截图规则,需要先调用[CreateLiveSnapshotTemplate](/document/product/267/32624)接口创建截图模板,然后将返回的模板id绑定到流进行使用。\n<br>截图相关文档:[直播截图](/document/product/267/32737)。" }, "DescribeLivePlayAuthKey": { "params": [ { "name": "DomainName", "desc": "域名。" } ], "desc": "查询播放鉴权key" }, "DescribeLiveStreamState": { "params": [ { "name": "AppName", "desc": "应用名称。" }, { "name": "DomainName", "desc": "您的推流域名。" }, { "name": "StreamName", "desc": "流名称。" } ], "desc": "返回直播中、无推流或者禁播等状态" }, "DeleteLiveRecordTemplate": { "params": [ { "name": "TemplateId", "desc": "模板ID。" } ], "desc": "删除录制模板" }, "CreateLiveTranscodeTemplate": { "params": [ { "name": "TemplateName", "desc": "模板名称,例:900 900p 仅支持字母和数字的组合。" }, { "name": "VideoBitrate", "desc": "视频码率。范围:100-8000。" }, { "name": "Vcodec", "desc": "视频编码:h264/h265,默认h264。\n注意:当前该参数未生效,待后续支持!" }, { "name": "Acodec", "desc": "音频编码:aac,默认原始音频格式。\n注意:当前该参数未生效,待后续支持!" }, { "name": "AudioBitrate", "desc": "音频码率:默认0。0-500。" }, { "name": "Description", "desc": "模板描述。" }, { "name": "Width", "desc": "宽,默认0。" }, { "name": "NeedVideo", "desc": "是否保留视频,0:否,1:是。默认1。\n注意:当前该参数未生效,待后续支持!" }, { "name": "NeedAudio", "desc": "是否保留音频,0:否,1:是。默认1。\n注意:当前该参数未生效,待后续支持!" }, { "name": "Height", "desc": "高,默认0。" }, { "name": "Fps", "desc": "帧率,默认0。" }, { "name": "Gop", "desc": "关键帧间隔,单位:秒。默认原始的间隔" }, { "name": "Rotate", "desc": "是否旋转,0:否,1:是。默认0。" }, { "name": "Profile", "desc": "编码质量:\nbaseline/main/high。默认baseline" }, { "name": "BitrateToOrig", "desc": "是否不超过原始码率,0:否,1:是。默认0。" }, { "name": "HeightToOrig", "desc": "是否不超过原始高,0:否,1:是。默认0。" }, { "name": "FpsToOrig", "desc": "是否不超过原始帧率,0:否,1:是。默认0。" } ], "desc": "创建转码模板,成功返回模板id后,需要调用[CreateLiveTranscodeRule](/document/product/267/32647)接口,将返回的模板id绑定到流使用。\n<br>转码相关文档:[直播转封装及转码](/document/product/267/32736)。" }, "DeleteLiveSnapshotRule": { "params": [ { "name": "DomainName", "desc": "推流域名。" }, { "name": "AppName", "desc": "推流路径。" }, { "name": "StreamName", "desc": "流名称。" } ], "desc": "删除截图规则" }, "EnableLiveDomain": { "params": [ { "name": "DomainName", "desc": "待启用的直播域名" } ], "desc": "启用状态为停用的直播域名" }, "CreatePullStreamConfig": { "params": [ { "name": "FromUrl", "desc": "源Url。" }, { "name": "ToUrl", "desc": "目的Url,目前限制该目标地址为腾讯域名。" }, { "name": "AreaId", "desc": "区域id,1-深圳,2-上海,3-天津,4-香港。" }, { "name": "IspId", "desc": "运营商id,1-电信,2-移动,3-联通,4-其他,AreaId为4的时候,IspId只能为其他。" }, { "name": "StartTime", "desc": "开始时间。\n使用UTC格式时间,\n例如:2019-01-08T10:00:00Z。" }, { "name": "EndTime", "desc": "结束时间,注意:\n1. 结束时间必须大于开始时间;\n2. 结束时间和开始时间必须大于当前时间;\n3. 结束时间 和 开始时间 间隔必须小于七天。\n使用UTC格式时间,\n例如:2019-01-08T10:00:00Z。" } ], "desc": "添加拉流配置,目前限制添加10条任务。" }, "DescribeLiveStreamPushInfoList": { "params": [ { "name": "PushDomain", "desc": "推流域名。" }, { "name": "AppName", "desc": "推流路径。" }, { "name": "PageNum", "desc": "页数,\n范围[1,10000],\n默认值:1。" }, { "name": "PageSize", "desc": "每页个数,\n范围:[1,1000],\n默认值: 200。" } ], "desc": "查询所有实时流的推流信息,包括客户端IP,服务端IP,帧率,码率,域名,开始推流时间。" }, "DeleteLiveSnapshotTemplate": { "params": [ { "name": "TemplateId", "desc": "模板Id。" } ], "desc": "删除截图模板" } }
#!/usr/bin/env python # coding: utf-8 class tokenargs(object): '''Wraps builtin list with checks for illegal characters in token arguments.''' # Disallow these characters inside token arguments illegal = '[]:' # Replace simple inputs with illegal characters with their legal equivalents replace = { "':'": '58', "'['": '91', "']'": '93' } def __init__(self, items=None): '''Construct a new list of token arguments.''' self.list = list() if items is not None: self.reset(items) def __setitem__(self, item, value): '''Set an item in the list.''' self.list[item] = self.sanitize(value) def __getitem__(self, item): '''Get an item from the list.''' result = self.list[item] if isinstance(result, list): return tokenargs(result) else: return result def __delitem__(self, item): '''Remove an item from the list.''' del self.list[item] def __str__(self): '''Get a string representation.''' return ':'.join(self.list) def __add__(self, items): '''Concatenate two lists of arguments.''' result = tokenargs(self.list) result.add(tokenargs(items)) return result def __radd__(self, items): '''Concatenate two lists of arguments.''' return tokenargs(tokenargs(items) + self.list) def __iadd__(self, item): '''Add an item or items to the end of the list.''' self.add(item) return self def __isub__(self, item): '''Remove some number of items from the end of the list.''' self.sub(item) return self def __contains__(self, item): '''Check if the list contains an item.''' try: item = self.sanitize(item) except: return False else: return item in self.list def __iter__(self): '''Iterate through items in the list.''' return self.list.__iter__() def __len__(self): '''Get the number of items in the list.''' return self.list.__len__() def __mul__(self, count): '''Concatenate the list with itself some number of times.''' return tokenargs(self.list * count) def __imul__(self, count): '''Concatenate the list with itself some number of times.''' self.list *= count return self def __eq__(self, other): '''Check equivalency with another list of arguments.''' return len(self.list) == len(other) and all(self.list[index] == str(item) for index, item in enumerate(other)) def copy(self): '''Make a copy of the argument list.''' return tokenargs(self.list) def reset(self, items): '''Reset list to contain specified items.''' if items is None: self.clear() elif isinstance(items, basestring): self.reset(items.split(':')) else: self.list[:] = self.sanitize(items) def set(self, index, item=None): ''' Set a single argument given an index or, if no index is given, set the argument at index 0. ''' if item is None: item = index index = 0 self.list[index] = self.sanitize(item) def clear(self): '''Remove all items from the list.''' del self.list[:] def sanitize(self, value, replace=True): ''' Internal: Utility method for sanitizing a string intended to be evaluated as an arugment for a token. ''' if isinstance(value, basestring): value = str(value) if replace and value in tokenargs.replace: value = tokenargs.replace[value] else: if any([char in value for char in tokenargs.illegal]): raise ValueError('Illegal character in argument %s.' % value) return value else: try: return (self.sanitize(item, replace) for item in value) except: return self.sanitize(str(value), replace) def append(self, item): '''Append a single item to the list.''' self.list.append(self.sanitize(item)) def extend(self, items): '''Append multiple items to the list.''' if isinstance(items, basestring): self.extend(items.split(':')) else: self.list.extend(self.sanitize(items)) def insert(self, index, item): '''Insert an item at some index.''' self.list.insert(index, self.sanitize(item)) def add(self, item, *args): '''Add an item or items to the end of the list.''' if isinstance(item, basestring): self.extend(item.split(':')) elif hasattr(item, '__iter__') or hasattr(item, '__getitem__'): self.extend(item) else: self.add(str(item)) if args: self.add(args) def remove(self, item): self.list.remove(self.sanitize(item)) def sub(self, item): '''Remove some number of items from the end of the list.''' try: self.list[:] = self.list[:-item] except: self.remove(item)
# # PySNMP MIB module SAF-IPRADIO (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/SAF-IPRADIO # Produced by pysmi-0.3.4 at Wed May 1 14:59:57 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, SingleValueConstraint, ValueSizeConstraint, ValueRangeConstraint, ConstraintsIntersection = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsUnion", "SingleValueConstraint", "ValueSizeConstraint", "ValueRangeConstraint", "ConstraintsIntersection") ifEntry, = mibBuilder.importSymbols("IF-MIB", "ifEntry") ModuleCompliance, NotificationGroup = mibBuilder.importSymbols("SNMPv2-CONF", "ModuleCompliance", "NotificationGroup") Counter32, Integer32, Gauge32, MibIdentifier, TimeTicks, IpAddress, Bits, Counter64, ObjectIdentity, iso, ModuleIdentity, MibScalar, MibTable, MibTableRow, MibTableColumn, NotificationType, Unsigned32, enterprises = mibBuilder.importSymbols("SNMPv2-SMI", "Counter32", "Integer32", "Gauge32", "MibIdentifier", "TimeTicks", "IpAddress", "Bits", "Counter64", "ObjectIdentity", "iso", "ModuleIdentity", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "NotificationType", "Unsigned32", "enterprises") DisplayString, TextualConvention, DateAndTime = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TextualConvention", "DateAndTime") saf = MibIdentifier((1, 3, 6, 1, 4, 1, 7571)) tehnika = MibIdentifier((1, 3, 6, 1, 4, 1, 7571, 100)) microwaveRadio = MibIdentifier((1, 3, 6, 1, 4, 1, 7571, 100, 1)) pointToPoint = MibIdentifier((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1)) safip = MibIdentifier((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5)) ipRadio = MibIdentifier((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1)) ipRadioCfg = MibIdentifier((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1)) ipRadioMgmt = MibIdentifier((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 2)) ipRadioStat = MibIdentifier((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3)) ipRadioCfgGeneral = MibIdentifier((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 1)) ipRadioCfgNetwork = MibIdentifier((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 2)) ipRadioStatEth = MibIdentifier((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 2)) modemStatistics = MibIdentifier((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 4)) product = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 1, 1), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 255))).setMaxAccess("readonly") if mibBuilder.loadTexts: product.setStatus('mandatory') if mibBuilder.loadTexts: product.setDescription('Name of the model.') description = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 1, 2), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 255))).setMaxAccess("readonly") if mibBuilder.loadTexts: description.setStatus('mandatory') if mibBuilder.loadTexts: description.setDescription('Description of the model.') radioName = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 1, 3), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 16))).setMaxAccess("readwrite") if mibBuilder.loadTexts: radioName.setStatus('mandatory') if mibBuilder.loadTexts: radioName.setDescription('(same as PROMPT>).') sysDateAndTime = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 1, 4), DateAndTime()).setMaxAccess("readwrite") if mibBuilder.loadTexts: sysDateAndTime.setStatus('mandatory') if mibBuilder.loadTexts: sysDateAndTime.setDescription('Current date and time set. For SET tenths of seconds ignored.') sysTemperature = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 1, 5), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: sysTemperature.setStatus('mandatory') if mibBuilder.loadTexts: sysTemperature.setDescription('Unit temperature in degrees by Celsius. NB - sw before 2009.03.18 shows in *10 degrees') license = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 1, 6), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 255))).setMaxAccess("readwrite") if mibBuilder.loadTexts: license.setStatus('mandatory') if mibBuilder.loadTexts: license.setDescription("To set license information. Read allways 'OK'.") licenseMask = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 1, 7), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: licenseMask.setStatus('mandatory') if mibBuilder.loadTexts: licenseMask.setDescription('Read license mask.') writeConfig = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 2, 1), Integer32()).setMaxAccess("writeonly") if mibBuilder.loadTexts: writeConfig.setStatus('mandatory') if mibBuilder.loadTexts: writeConfig.setDescription('Write Config') restartcpu = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 2, 2), Integer32()).setMaxAccess("writeonly") if mibBuilder.loadTexts: restartcpu.setStatus('mandatory') if mibBuilder.loadTexts: restartcpu.setDescription("Restart of Mng CPU. Values: 1 - 'cold' restart; 3 - sw") loopbacks = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 2, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 4, 5, 12))).clone(namedValues=NamedValues(("error", 1), ("off", 2), ("if", 4), ("modem", 5), ("multi", 12)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: loopbacks.setStatus('mandatory') if mibBuilder.loadTexts: loopbacks.setDescription("Set loopback for 1 minute. value error(1) is not writable. Status of loopbacks. Values: 1 - 'error' (not writable); 2 - 'off'; 3 - 'rf' (radio frequency loopback); N/A 2008.10.21 4 - 'if' (intermediate frequency loopback); 5 - 'modem' (modem loopback); 6 - 'far' (far end loopback); N/A 2008.10.21 7 - 'ethernet' (Ethernet loopback); N/A 2008.10.21 8 - 'e1t1-1' (E1/T1 channel 1 loopback); N/A from firmware 1.51 9 - 'e1t1-2' (E1/T1 channel 2 loopback); N/A from firmware 1.51 10 - 'e1t1-3' (E1/T1 channel 3 loopback); N/A from firmware 1.51 11 - 'e1t1-4' (E1/T1 channel 4 loopback); N/A from firmware 1.51 12 - 'multi' (E1/T1 multi - look channel tributary mask)") loopback_tributary_mask = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 2, 4), Integer32()).setLabel("loopback-tributary-mask").setMaxAccess("readonly") if mibBuilder.loadTexts: loopback_tributary_mask.setStatus('mandatory') if mibBuilder.loadTexts: loopback_tributary_mask.setDescription('Loopback mask for E1/T1 channels') localIp = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 2, 1), IpAddress()).setMaxAccess("readwrite") if mibBuilder.loadTexts: localIp.setStatus('mandatory') if mibBuilder.loadTexts: localIp.setDescription('IPv4 Ethernet address of the local unit in a number format(XXX.XXX.XXX.XXX)') localIpMask = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 2, 2), IpAddress()).setMaxAccess("readwrite") if mibBuilder.loadTexts: localIpMask.setStatus('mandatory') if mibBuilder.loadTexts: localIpMask.setDescription('IPv4 Ethernet mask of the local unit in a number format (XXX.XXX.XXX.XXX)') remoteIp = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 2, 3), IpAddress()).setMaxAccess("readwrite") if mibBuilder.loadTexts: remoteIp.setStatus('mandatory') if mibBuilder.loadTexts: remoteIp.setDescription('IPv4 Ethernet address of the remote unit in a number format (XXX.XXX.XXX.XXX).') radioTable = MibTable((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 1, 10), ) if mibBuilder.loadTexts: radioTable.setStatus('mandatory') if mibBuilder.loadTexts: radioTable.setDescription('Radio table.') radioEntry = MibTableRow((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 1, 10, 1), ).setIndexNames((0, "SAF-IPRADIO", "radioIndex")) if mibBuilder.loadTexts: radioEntry.setStatus('mandatory') if mibBuilder.loadTexts: radioEntry.setDescription('Entry containing objects in radio table.') radioIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 1, 10, 1, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("local", 1), ("remote", 2)))).setMaxAccess("readonly") if mibBuilder.loadTexts: radioIndex.setStatus('mandatory') if mibBuilder.loadTexts: radioIndex.setDescription("A unique value for each radio. Its value represents UNIT: 1 - for 'local'; 2 - for 'remote'") radioGenStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 1, 10, 1, 2), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: radioGenStatus.setStatus('mandatory') if mibBuilder.loadTexts: radioGenStatus.setDescription("A General status of each radio: 1 - 'OK'; 2 - 'error'") radioSide = MibTableColumn((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 1, 10, 1, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("high", 1), ("low", 2)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: radioSide.setStatus('mandatory') if mibBuilder.loadTexts: radioSide.setDescription('Side for duplex communication.') radioTxPower = MibTableColumn((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 1, 10, 1, 4), Integer32()).setMaxAccess("readwrite") if mibBuilder.loadTexts: radioTxPower.setStatus('mandatory') if mibBuilder.loadTexts: radioTxPower.setDescription('Tx power of radio transmitter in dBm.') radioRxLevel = MibTableColumn((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 1, 10, 1, 5), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: radioRxLevel.setStatus('mandatory') if mibBuilder.loadTexts: radioRxLevel.setDescription('Received signal level in dBm.') radioDuplexShift = MibTableColumn((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 1, 10, 1, 6), Integer32()).setMaxAccess("readwrite") if mibBuilder.loadTexts: radioDuplexShift.setStatus('mandatory') if mibBuilder.loadTexts: radioDuplexShift.setDescription('Utilized duplex shift in KHz.') radioLoopback = MibTableColumn((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 1, 10, 1, 7), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("on", 1), ("off", 2)))).setMaxAccess("readonly") if mibBuilder.loadTexts: radioLoopback.setStatus('mandatory') if mibBuilder.loadTexts: radioLoopback.setDescription('Radio loopback on/off. To set use loopback command.') radioTxMute = MibTableColumn((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 1, 10, 1, 8), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("on", 1), ("off", 2)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: radioTxMute.setStatus('mandatory') if mibBuilder.loadTexts: radioTxMute.setDescription("Status of 'Tx mute': 1 - Tx is muted; 2 - Tx is not muted.") radioTxFrequency = MibTableColumn((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 1, 10, 1, 9), Integer32()).setMaxAccess("readwrite") if mibBuilder.loadTexts: radioTxFrequency.setStatus('mandatory') if mibBuilder.loadTexts: radioTxFrequency.setDescription('Tx frequency in kHz.') radioRxFrequency = MibTableColumn((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 1, 10, 1, 10), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: radioRxFrequency.setStatus('mandatory') if mibBuilder.loadTexts: radioRxFrequency.setDescription('Rx frequency in kHz.') aTPCTable = MibTable((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 1, 11), ) if mibBuilder.loadTexts: aTPCTable.setStatus('mandatory') if mibBuilder.loadTexts: aTPCTable.setDescription('ATPC table') aTPCEntry = MibTableRow((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 1, 11, 1), ).setIndexNames((0, "SAF-IPRADIO", "atpcIndex")) if mibBuilder.loadTexts: aTPCEntry.setStatus('mandatory') if mibBuilder.loadTexts: aTPCEntry.setDescription('Entry containing objects in ATPC table.') atpcIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 1, 11, 1, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("local", 1), ("remote", 2)))).setMaxAccess("readonly") if mibBuilder.loadTexts: atpcIndex.setStatus('mandatory') if mibBuilder.loadTexts: atpcIndex.setDescription("Its value represents UNIT 1 for 'local'; 2 for 'remote'.") atpcEnabled = MibTableColumn((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 1, 11, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enable", 1), ("disable", 2)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: atpcEnabled.setStatus('mandatory') if mibBuilder.loadTexts: atpcEnabled.setDescription("ATPC status: 1 for 'on'; 2 for 'off'.") atpcTxPowerCorrection = MibTableColumn((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 1, 11, 1, 3), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: atpcTxPowerCorrection.setStatus('mandatory') if mibBuilder.loadTexts: atpcTxPowerCorrection.setDescription('ATPC Tx power correction in dBm.') modemTable = MibTable((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 1, 12), ) if mibBuilder.loadTexts: modemTable.setStatus('mandatory') if mibBuilder.loadTexts: modemTable.setDescription('CFIP modem table.') modemEntry = MibTableRow((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 1, 12, 1), ).setIndexNames((0, "SAF-IPRADIO", "modemIndex")) if mibBuilder.loadTexts: modemEntry.setStatus('mandatory') if mibBuilder.loadTexts: modemEntry.setDescription('Entry containing objects in modem table.') modemIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 1, 12, 1, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("local", 1), ("remote", 2)))).setMaxAccess("readonly") if mibBuilder.loadTexts: modemIndex.setStatus('mandatory') if mibBuilder.loadTexts: modemIndex.setDescription('Value represents UNIT: 1 for local; 2 for remote.') modemGeneralStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 1, 12, 1, 2), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: modemGeneralStatus.setStatus('mandatory') if mibBuilder.loadTexts: modemGeneralStatus.setDescription("A General status of each modem: 1 - 'OK'; 2 - 'error'") modemBandwith = MibTableColumn((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 1, 12, 1, 3), Integer32()).setMaxAccess("readwrite") if mibBuilder.loadTexts: modemBandwith.setStatus('mandatory') if mibBuilder.loadTexts: modemBandwith.setDescription('Modem bandwidth set in KHz.') modemE1T1Channels = MibTableColumn((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 1, 12, 1, 4), Integer32()).setMaxAccess("readwrite") if mibBuilder.loadTexts: modemE1T1Channels.setStatus('mandatory') if mibBuilder.loadTexts: modemE1T1Channels.setDescription('Number of E1 or T1 channels set.') modemModulation = MibTableColumn((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 1, 12, 1, 5), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 17, 18, 19, 20, 21, 22, 23, 25, 26, 27, 28, 29, 30, 31, 33, 34, 40, 41, 42, 49, 50, 57, 58))).clone(namedValues=NamedValues(("qpsk", 1), ("psk8", 2), ("qam16", 3), ("qam32", 4), ("qam64", 5), ("qam128", 6), ("qam256", 7), ("qpsklimited", 8), ("wqpsk", 9), ("wpsk8", 10), ("wqam16", 11), ("wqam32", 12), ("wqam64", 13), ("wqam128", 14), ("wqam256", 15), ("acmqpsk", 17), ("acmpsk8", 18), ("acmqam16", 19), ("acmqam32", 20), ("acmqam64", 21), ("acmqam128", 22), ("acmqam256", 23), ("acmwqpsk", 25), ("acmwpsk8", 26), ("acmwqam16", 27), ("acmwqam32", 28), ("acmwqam64", 29), ("acmwqam128", 30), ("acmwqam256", 31), ("qam4", 33), ("qam8", 34), ("qam4limited", 40), ("wqam4", 41), ("wqam8", 42), ("acmqam4", 49), ("acmqam8", 50), ("acmwqam4", 57), ("acmwqam8", 58)))).setMaxAccess("readonly") if mibBuilder.loadTexts: modemModulation.setStatus('mandatory') if mibBuilder.loadTexts: modemModulation.setDescription('Modem modulation set. Modulution values are following: QPSK - 1, 8PSK - 2, 16QAM - 3, 32QAM - 4, 64QAM - 5, 128QAM - 6, 256QAM - 7. The combination of wide band and ACM calculates as (modulation + 8*is_wide + 16*is_ACM). Note: not all of listed modulations supported by hardware. Plese check manual.') modemTotalCapacity = MibTableColumn((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 1, 12, 1, 6), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: modemTotalCapacity.setStatus('mandatory') if mibBuilder.loadTexts: modemTotalCapacity.setDescription('Total capacity set in Kbps.') modemEthernetCapacity = MibTableColumn((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 1, 12, 1, 7), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: modemEthernetCapacity.setStatus('mandatory') if mibBuilder.loadTexts: modemEthernetCapacity.setDescription('Ethernet capacity set in Kbps.') modemAcqStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 1, 12, 1, 8), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: modemAcqStatus.setStatus('mandatory') if mibBuilder.loadTexts: modemAcqStatus.setDescription(' ') modemLastAcqError = MibTableColumn((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 1, 12, 1, 9), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11))).clone(namedValues=NamedValues(("success", 1), ("erragc", 2), ("errtiming", 3), ("errfreqsweep", 4), ("errmse", 5), ("errbit", 6), ("errservice", 7), ("errblind", 8), ("errtimeout", 9), ("errstopped", 10), ("errfatal", 11)))).setMaxAccess("readonly") if mibBuilder.loadTexts: modemLastAcqError.setStatus('mandatory') if mibBuilder.loadTexts: modemLastAcqError.setDescription(' ') modemRadialMSE = MibTableColumn((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 1, 12, 1, 10), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: modemRadialMSE.setStatus('mandatory') if mibBuilder.loadTexts: modemRadialMSE.setDescription("Radial mean square error value *10 in dB. Radial MSE is a method for estimating the signal to noise ratio. ACM engine uses normalized MSE, which is the inverse of SNR. It is calculated by dividing the estimated MSE level with the energy of the received constellation. Radial MSE peak value threshold is dependent on modulation used and LDPC code rate. In case of QPSK it is -8 dB (-10.5 for 'wide'), 16APSK - -13 dB (-18 for 'wide') and 32APSK - -15.5 dB (-21.5 for 'wide'). If the value trespasses this threshold, BER at the output of LDPC decoder will reach the value of 1.0e-06.") modemInternalAGCgain = MibTableColumn((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 1, 12, 1, 11), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: modemInternalAGCgain.setStatus('mandatory') if mibBuilder.loadTexts: modemInternalAGCgain.setDescription(' dBm ') modemCarrierOffset = MibTableColumn((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 1, 12, 1, 12), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: modemCarrierOffset.setStatus('mandatory') if mibBuilder.loadTexts: modemCarrierOffset.setDescription('Carrier frequency offset in Hz.') modemSymbolRateTx = MibTableColumn((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 1, 12, 1, 13), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: modemSymbolRateTx.setStatus('mandatory') if mibBuilder.loadTexts: modemSymbolRateTx.setDescription(' kHz ') modemSymbolRateRx = MibTableColumn((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 1, 12, 1, 14), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: modemSymbolRateRx.setStatus('mandatory') if mibBuilder.loadTexts: modemSymbolRateRx.setDescription(' kHz ') modemLDPCdecoderStress = MibTableColumn((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 1, 12, 1, 15), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 255))).setMaxAccess("readonly") if mibBuilder.loadTexts: modemLDPCdecoderStress.setStatus('mandatory') if mibBuilder.loadTexts: modemLDPCdecoderStress.setDescription("The load of LDPC (low-density parity-check code) decoder. The LDPC is monitored for the number of errors being corrected on the input of LDPC decoder. LDPC stress value thresholds @ BER 1.0e-06: - for standard settings ~4.0e-02; - for 'wide' option ~ 1.0e-03. As long as LDPC stress value is under the specified thresholds, amount of errors (and BER itself) on the output of LDPC remains at zero level.") modemACMengine = MibTableColumn((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 1, 12, 1, 16), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("on", 1), ("off", 2)))).setMaxAccess("readonly") if mibBuilder.loadTexts: modemACMengine.setStatus('mandatory') if mibBuilder.loadTexts: modemACMengine.setDescription("Status of ACM engine. When 'on', value '1' is shown, when 'off' - value is '2'.") modemACMmodulationMin = MibTableColumn((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 1, 12, 1, 17), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 17, 18, 19, 20, 21, 22, 23, 25, 26, 27, 28, 29, 30, 31, 33, 34, 40, 41, 42, 49, 50, 57, 58))).clone(namedValues=NamedValues(("qpsk", 1), ("psk8", 2), ("qam16", 3), ("qam32", 4), ("qam64", 5), ("qam128", 6), ("qam256", 7), ("qpsklimited", 8), ("wqpsk", 9), ("wpsk8", 10), ("wqam16", 11), ("wqam32", 12), ("wqam64", 13), ("wqam128", 14), ("wqam256", 15), ("acmqpsk", 17), ("acmpsk8", 18), ("acmqam16", 19), ("acmqam32", 20), ("acmqam64", 21), ("acmqam128", 22), ("acmqam256", 23), ("acmwqpsk", 25), ("acmwpsk8", 26), ("acmwqam16", 27), ("acmwqam32", 28), ("acmwqam64", 29), ("acmwqam128", 30), ("acmwqam256", 31), ("qam4", 33), ("qam8", 34), ("qam4limited", 40), ("wqam4", 41), ("wqam8", 42), ("acmqam4", 49), ("acmqam8", 50), ("acmwqam4", 57), ("acmwqam8", 58)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: modemACMmodulationMin.setStatus('mandatory') if mibBuilder.loadTexts: modemACMmodulationMin.setDescription('Modem modulation set. Modulution values are following: QPSK - 1, 8PSK - 2, 16QAM - 3, 32QAM - 4, 64QAM - 5, 128QAM - 6, 256QAM - 7. The combination of wide band and ACM calculates as (modulation + 8*is_wide + 16*is_ACM). Note: not all of listed modulations supported by hardware. Plese check manual.') modemACMtotalCapacity = MibTableColumn((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 1, 12, 1, 18), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: modemACMtotalCapacity.setStatus('mandatory') if mibBuilder.loadTexts: modemACMtotalCapacity.setDescription('Total capacity in Kbps set by ACM.') modemACMethernetCapacity = MibTableColumn((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 1, 12, 1, 19), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: modemACMethernetCapacity.setStatus('mandatory') if mibBuilder.loadTexts: modemACMethernetCapacity.setDescription('Ethernet capacity in Kbps set by ACM.') modemStandard = MibTableColumn((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 1, 12, 1, 20), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("etsi", 1), ("ansi", 2)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: modemStandard.setStatus('mandatory') if mibBuilder.loadTexts: modemStandard.setDescription('Modem operational standard ETSI or ANSI') modemE1T1ChannelMask = MibTableColumn((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 1, 12, 1, 21), Integer32()).setMaxAccess("readwrite") if mibBuilder.loadTexts: modemE1T1ChannelMask.setStatus('mandatory') if mibBuilder.loadTexts: modemE1T1ChannelMask.setDescription('E1 or T1 channel mask 0x00 - 0x0f') modemACMmodulationMax = MibTableColumn((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 1, 12, 1, 22), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 17, 18, 19, 20, 21, 22, 23, 25, 26, 27, 28, 29, 30, 31, 33, 34, 40, 41, 42, 49, 50, 57, 58))).clone(namedValues=NamedValues(("qpsk", 1), ("psk8", 2), ("qam16", 3), ("qam32", 4), ("qam64", 5), ("qam128", 6), ("qam256", 7), ("qpsklimited", 8), ("wqpsk", 9), ("wpsk8", 10), ("wqam16", 11), ("wqam32", 12), ("wqam64", 13), ("wqam128", 14), ("wqam256", 15), ("acmqpsk", 17), ("acmpsk8", 18), ("acmqam16", 19), ("acmqam32", 20), ("acmqam64", 21), ("acmqam128", 22), ("acmqam256", 23), ("acmwqpsk", 25), ("acmwpsk8", 26), ("acmwqam16", 27), ("acmwqam32", 28), ("acmwqam64", 29), ("acmwqam128", 30), ("acmwqam256", 31), ("qam4", 33), ("qam8", 34), ("qam4limited", 40), ("wqam4", 41), ("wqam8", 42), ("acmqam4", 49), ("acmqam8", 50), ("acmwqam4", 57), ("acmwqam8", 58)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: modemACMmodulationMax.setStatus('mandatory') if mibBuilder.loadTexts: modemACMmodulationMax.setDescription('Modem modulation set. Modulution values are following: QPSK - 1, 8PSK - 2, 16QAM - 3, 32QAM - 4, 64QAM - 5, 128QAM - 6, 256QAM - 7. The combination of wide band and ACM calculates as (modulation + 8*is_wide + 16*is_ACM). Note: as PSK modulations are now physicaly deprecated, theese are replased with QAM, so for new QAM modulations there are modificatior +32. Note: not all of listed modulations supported by hardware. Plese check manual.') modemRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 1, 12, 1, 23), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 3, 4))).clone(namedValues=NamedValues(("active", 1), ("notReady", 3), ("undo", 4)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: modemRowStatus.setStatus('mandatory') if mibBuilder.loadTexts: modemRowStatus.setDescription('Row status - to update written data for modemBandwith, modemACMmodulationMin, modemACMmodulationMax, modemE1T1ChannelMask. ') vlansEnabled = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 1, 13), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2), ("reset", 3)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: vlansEnabled.setStatus('mandatory') if mibBuilder.loadTexts: vlansEnabled.setDescription('unit temperature *10 degrees Celsius') vlanTable = MibTable((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 1, 14), ) if mibBuilder.loadTexts: vlanTable.setStatus('mandatory') if mibBuilder.loadTexts: vlanTable.setDescription('Vlan table') vlanEntry = MibTableRow((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 1, 14, 1), ) ifEntry.registerAugmentions(("SAF-IPRADIO", "vlanEntry")) vlanEntry.setIndexNames(*ifEntry.getIndexNames()) if mibBuilder.loadTexts: vlanEntry.setStatus('mandatory') if mibBuilder.loadTexts: vlanEntry.setDescription('entry containing vlan objects') vlanNumber = MibTableColumn((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 1, 14, 1, 1), Integer32()).setMaxAccess("readwrite") if mibBuilder.loadTexts: vlanNumber.setStatus('mandatory') if mibBuilder.loadTexts: vlanNumber.setDescription('A unique value for each vlan. ') vlanPortType = MibTableColumn((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 1, 14, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("management", 1), ("none", 2), ("traffic", 3), ("endpoint", 4)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: vlanPortType.setStatus('mandatory') if mibBuilder.loadTexts: vlanPortType.setDescription('VLAN port type management, traffic or endpoint ') vlanPortmap = MibTableColumn((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 1, 14, 1, 3), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: vlanPortmap.setStatus('mandatory') if mibBuilder.loadTexts: vlanPortmap.setDescription('display port bindings bitfield 111(bin) ') vlanFid = MibTableColumn((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 1, 14, 1, 4), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: vlanFid.setStatus('optional') if mibBuilder.loadTexts: vlanFid.setDescription('a filtering identifier (assigned automagically)') vlanCfgStat = MibTableColumn((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 1, 14, 1, 5), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("enable", 1), ("disable", 2), ("clear", 3)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: vlanCfgStat.setStatus('mandatory') if mibBuilder.loadTexts: vlanCfgStat.setDescription('enable/disable vlan # or clear row data') vlanRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 1, 1, 14, 1, 6), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 3, 4))).clone(namedValues=NamedValues(("active", 1), ("notReady", 3), ("undo", 4)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: vlanRowStatus.setStatus('mandatory') if mibBuilder.loadTexts: vlanRowStatus.setDescription('Row status (execute configuration on active) Changing any table value sets this value into state notReady. To update row status write value active(1) into this variable.') ethRXTruncatedFrames = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 2, 1), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ethRXTruncatedFrames.setStatus('mandatory') if mibBuilder.loadTexts: ethRXTruncatedFrames.setDescription('Number of truncated received frames since unit start or statistics reset. ') ethRXLongEvents = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 2, 2), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ethRXLongEvents.setStatus('mandatory') if mibBuilder.loadTexts: ethRXLongEvents.setDescription('Number of frames having byte count greater than MAXIMUM FRAME SIZE parameter (1518, 1536 or 1916 bytes) since unit start or statistics reset.') ethRXVlanTagsDetected = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 2, 3), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ethRXVlanTagsDetected.setStatus('mandatory') if mibBuilder.loadTexts: ethRXVlanTagsDetected.setDescription('Number of VLAN Tags detected since unit start or statistics reset.') ethRXUnsupOpcodes = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 2, 4), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ethRXUnsupOpcodes.setStatus('mandatory') if mibBuilder.loadTexts: ethRXUnsupOpcodes.setDescription('Number of frames recognized as control frames but contained an Unknown Opcode since unit start or statistics reset.') ethRXPauseFrames = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 2, 5), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ethRXPauseFrames.setStatus('mandatory') if mibBuilder.loadTexts: ethRXPauseFrames.setDescription('Number of frames received as control frames with valid PAUSE opcodes since unit start or statistics reset.') ethRXControlFrames = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 2, 6), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ethRXControlFrames.setStatus('mandatory') if mibBuilder.loadTexts: ethRXControlFrames.setDescription('Number of frames received as control frames since unit start or statistics reset.') ethRXDribleNibbles = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 2, 7), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ethRXDribleNibbles.setStatus('mandatory') if mibBuilder.loadTexts: ethRXDribleNibbles.setDescription('Indicates that following the end of the packet additional 1 to 7 bits are received. A single nibble, named the dribble nibble, is formed but not sent to the system;') ethRXBroadcasts = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 2, 8), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ethRXBroadcasts.setStatus('mandatory') if mibBuilder.loadTexts: ethRXBroadcasts.setDescription('Number of packets, which destination address contained broadcast address, since unit start or statiistics reset.') ethRXMulticasts = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 2, 9), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ethRXMulticasts.setStatus('mandatory') if mibBuilder.loadTexts: ethRXMulticasts.setDescription('Number of packets, which destination address contained multicast address since unit start or statistics reset.') ethRXDones = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 2, 10), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ethRXDones.setStatus('mandatory') if mibBuilder.loadTexts: ethRXDones.setDescription('Reception of packets successfully completed. Number of completed packets since unit start or statistics reset.') ethRXOutOfRangeErrors = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 2, 11), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ethRXOutOfRangeErrors.setStatus('mandatory') if mibBuilder.loadTexts: ethRXOutOfRangeErrors.setDescription('Number of frames where Type/Length field larger than 1518 (Type Field) bytes since unit start or statistics reset.') ethRXLengthCheckerrorsErrors = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 2, 12), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ethRXLengthCheckerrorsErrors.setStatus('mandatory') if mibBuilder.loadTexts: ethRXLengthCheckerrorsErrors.setDescription('Number of frames where frame length field in the packet does not match the actual data byte length and is not a Type Field since unit start or statistics reset.') ethRXCRCErrors = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 2, 13), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ethRXCRCErrors.setStatus('mandatory') if mibBuilder.loadTexts: ethRXCRCErrors.setDescription('Number of frames where frame CRC do not match the internally generated CRC since unit start or statistics reset') ethRXCodeErrors = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 2, 14), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ethRXCodeErrors.setStatus('mandatory') if mibBuilder.loadTexts: ethRXCodeErrors.setDescription('Number of packets where one or more nibbles are signalled as errors during reception of the packet since unit start or statistics reset.') ethRXFalseCarrierErrors = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 2, 15), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ethRXFalseCarrierErrors.setStatus('mandatory') if mibBuilder.loadTexts: ethRXFalseCarrierErrors.setDescription('Indicates that following the last receive statistics vector, a false carrier was detected, noted and reported with this the next receive statistics. The false carrier is not associated with this packet. False carrier is activated on the receive channel that does not result in a packet receive attempt being made;') ethRXDvEvent = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 2, 16), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ethRXDvEvent.setStatus('mandatory') if mibBuilder.loadTexts: ethRXDvEvent.setDescription('Number of the last receive (Rx) events seen being too short to be valid packets since the last unit (re)start or purification of statistics.') ethRXPrevPktDropped = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 2, 17), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ethRXPrevPktDropped.setStatus('mandatory') if mibBuilder.loadTexts: ethRXPrevPktDropped.setDescription('Indicates that since the last receive (Rx), a packet is dropped (i.e. interframe gap too small).') ethRXByteCounterHi = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 2, 18), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ethRXByteCounterHi.setStatus('mandatory') if mibBuilder.loadTexts: ethRXByteCounterHi.setDescription('Total number of bytes received (Rx) on the wire since the last unit (re)start or purification of statistics, not counting collided bytes (bits 31:0).') ethRXByteCounterLow = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 2, 19), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ethRXByteCounterLow.setStatus('mandatory') if mibBuilder.loadTexts: ethRXByteCounterLow.setDescription('Total number of bytes received (Rx) on the wire since the last unit (re)start or purification of statistics, not counting collided bytes (bits 62:32).') ethTXVlanTags = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 2, 21), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ethTXVlanTags.setStatus('mandatory') if mibBuilder.loadTexts: ethTXVlanTags.setDescription('Number of VLAN tagged Tx packets since the last unit (re)start or purification of statistics. 32-bit counter.') ethTXBackpresEvents = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 2, 22), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ethTXBackpresEvents.setStatus('mandatory') if mibBuilder.loadTexts: ethTXBackpresEvents.setDescription('Number of times Tx carrier-sense-method backpressure was previously applied since the last unit (re)start or purification of statistics.') ethTXPauseFrames = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 2, 23), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ethTXPauseFrames.setStatus('mandatory') if mibBuilder.loadTexts: ethTXPauseFrames.setDescription('Number of frames transmitted (Tx) as control frames with valid PAUSE opcodes since the last unit (re)start or purification of statistics.') ethTXControlFrames = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 2, 24), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ethTXControlFrames.setStatus('mandatory') if mibBuilder.loadTexts: ethTXControlFrames.setDescription('Number of frames transmitted (Tx) as control frames since the last unit (re)start or purification of statistics.') ethTXWireByteCounterHi = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 2, 25), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ethTXWireByteCounterHi.setStatus('mandatory') if mibBuilder.loadTexts: ethTXWireByteCounterHi.setDescription('Total number of bytes transmitted (Tx) on the wire since the last unit (re)start or purification of statistics, including all bytes from collided attempts (bits 31:0).') ethTXWireByteCounterLow = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 2, 26), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ethTXWireByteCounterLow.setStatus('mandatory') if mibBuilder.loadTexts: ethTXWireByteCounterLow.setDescription('Total number of bytes transmitted (Tx) on the wire since the last unit (re)start or purification of statistics, including all bytes from collided attempts (bits 62:32).') ethTXUnderruns = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 2, 28), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ethTXUnderruns.setStatus('mandatory') if mibBuilder.loadTexts: ethTXUnderruns.setDescription('Number of underruns occured during frame transmission (Tx) since the last unit (re)start or purification of statistics.') ethTXGiants = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 2, 29), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ethTXGiants.setStatus('mandatory') if mibBuilder.loadTexts: ethTXGiants.setDescription('Number of Tx frames having byte count greater than the MAXIMUM FRAME SIZE parameter (1516, 1536 or 1916 bytes) since the last unit (re)start or purification of statistics.') ethTXLateCollisions = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 2, 30), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ethTXLateCollisions.setStatus('mandatory') if mibBuilder.loadTexts: ethTXLateCollisions.setDescription('Number of Tx collisions occurred beyond the collision window (512 bit times) since the last unit (re)start or purification of statistics.') ethTXMaxCollisions = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 2, 31), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ethTXMaxCollisions.setStatus('mandatory') if mibBuilder.loadTexts: ethTXMaxCollisions.setDescription('Number of Tx packets aborted after number of collisions exceeded the RETRANSMISSION MAXIMUM parameter since the last unit (re)start or purification of statistics.') ethTXExcessiveDefers = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 2, 32), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ethTXExcessiveDefers.setStatus('mandatory') if mibBuilder.loadTexts: ethTXExcessiveDefers.setDescription('Number of Tx packets deferred in excess of 6,071 nibble times in 100 Mbps mode, or 24,287 bit-times in 10 Mbps mode since the last unit (re)start or purification of statistics.') ethTXNonExcessiveDefers = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 2, 33), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ethTXNonExcessiveDefers.setStatus('mandatory') if mibBuilder.loadTexts: ethTXNonExcessiveDefers.setDescription('Number of Tx packets deferred for at least one attempt, but less than an excessive defer since the last unit (re)start or purification of statistics.') ethTXBroadcasts = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 2, 34), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ethTXBroadcasts.setStatus('mandatory') if mibBuilder.loadTexts: ethTXBroadcasts.setDescription('Number of Tx packets since the last unit (re)start or purification of statistics, which destination address contained broadcast address.') ethTXMulticasts = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 2, 35), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ethTXMulticasts.setStatus('mandatory') if mibBuilder.loadTexts: ethTXMulticasts.setDescription('Number of Tx packets since the last unit (re)start or purification of statistics, which destination address contained multicast address.') ethTXDones = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 2, 36), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ethTXDones.setStatus('mandatory') if mibBuilder.loadTexts: ethTXDones.setDescription('Number of packets successfully transmitted (Tx) since the last unit (re)start or purification of statistics.') ethTXLengthCheckErrors = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 2, 38), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ethTXLengthCheckErrors.setStatus('mandatory') if mibBuilder.loadTexts: ethTXLengthCheckErrors.setDescription('Number of Tx frames since the last unit (re)start or purification of statistics, where length field in the packet does not match the actual data byte length and is not a Type Field') ethTXCRCErrors = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 2, 39), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ethTXCRCErrors.setStatus('mandatory') if mibBuilder.loadTexts: ethTXCRCErrors.setDescription('Number of Tx frames since the last unit (re)start or purification of statistics, where CRC does not match the internally generated CRC.') ethTXCollisions = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 2, 40), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ethTXCollisions.setStatus('mandatory') if mibBuilder.loadTexts: ethTXCollisions.setDescription('Number of collisions the current packet incurred during transmission (Tx) attempts. Note: Bits 19 through 16 are the collision count on any successfully transmitted packet and as such will not show the possible maximum count of 16 collisions.') ethTXByteCounterHi = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 2, 41), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ethTXByteCounterHi.setStatus('mandatory') if mibBuilder.loadTexts: ethTXByteCounterHi.setDescription('Total count of bytes transmitted (Tx) on the wire not including collided bytes (bits 31:0) since the last unit (re)start or purification of statistics.') ethTXByteCounterLow = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 2, 42), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ethTXByteCounterLow.setStatus('mandatory') if mibBuilder.loadTexts: ethTXByteCounterLow.setDescription('Total count of bytes transmitted (Tx) on the wire not including collided bytes (bits 62:32) since the last unit (re)start or purification of statistics.') ethGFPFCSErrors = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 2, 44), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ethGFPFCSErrors.setStatus('mandatory') if mibBuilder.loadTexts: ethGFPFCSErrors.setDescription('Number of generic framing procedure (GFP) frames with CRC errors received by the de-encapsulation block since the last unit (re)start or purification of statistics.') ethGFPCHECErrors = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 2, 45), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ethGFPCHECErrors.setStatus('mandatory') if mibBuilder.loadTexts: ethGFPCHECErrors.setDescription('Number of generic framing procedure (GFP) frames with CHEC errors received by the de-encapsulation block since the last unit (re)start or purification of statistics.') ethGFPDropedFrames = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 2, 46), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ethGFPDropedFrames.setStatus('mandatory') if mibBuilder.loadTexts: ethGFPDropedFrames.setDescription('Number of generic framing procedure (GFP) frames that were dropped in the de-encapsulation block since the last unit (re)start or purification of statistics.') ethGFPDelineationErrors = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 2, 47), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ethGFPDelineationErrors.setStatus('mandatory') if mibBuilder.loadTexts: ethGFPDelineationErrors.setDescription("Number of 'lost of synchronization' events since the last unit (re)start or purification of statistics.") ethQOSRXQ1Frames = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 2, 48), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ethQOSRXQ1Frames.setStatus('mandatory') if mibBuilder.loadTexts: ethQOSRXQ1Frames.setDescription('Number of frames received on Q1 since the last unit (re)start or purification of statistics.') ethQOSRXQ1Dropped = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 2, 49), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ethQOSRXQ1Dropped.setStatus('mandatory') if mibBuilder.loadTexts: ethQOSRXQ1Dropped.setDescription('Number of frames dropped on Q1 since the last unit (re)start or purification of statistics.') ethQOSRXQ2Frames = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 2, 50), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ethQOSRXQ2Frames.setStatus('mandatory') if mibBuilder.loadTexts: ethQOSRXQ2Frames.setDescription('Number of frames received on Q2 since the last unit (re)start or purification of statistics.') ethQOSRXQ2Dropped = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 2, 51), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ethQOSRXQ2Dropped.setStatus('mandatory') if mibBuilder.loadTexts: ethQOSRXQ2Dropped.setDescription('Number of frames dropped on Q2 since the last unit (re)start or purification of statistics.') ethQOSTXFrames = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 2, 52), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ethQOSTXFrames.setStatus('mandatory') if mibBuilder.loadTexts: ethQOSTXFrames.setDescription('Number of frames passed through TX FIFO since the last unit (re)start or purification of statistics.') ethQOSTXDropped = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 2, 53), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ethQOSTXDropped.setStatus('mandatory') if mibBuilder.loadTexts: ethQOSTXDropped.setDescription('Number of frames dropped in TX FIFO since the last unit (re)start or purification of statistics.') e1t1StatTable = MibTable((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 3), ) if mibBuilder.loadTexts: e1t1StatTable.setStatus('mandatory') if mibBuilder.loadTexts: e1t1StatTable.setDescription('E1 (T1) status Table.') e1t1StatEntry = MibTableRow((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 3, 1), ) ifEntry.registerAugmentions(("SAF-IPRADIO", "e1t1StatEntry")) e1t1StatEntry.setIndexNames(*ifEntry.getIndexNames()) if mibBuilder.loadTexts: e1t1StatEntry.setStatus('mandatory') if mibBuilder.loadTexts: e1t1StatEntry.setDescription('Entry containing objects in E1 (T1) table') e1t1LOS = MibTableColumn((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 3, 1, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("on", 1), ("off", 2)))).setMaxAccess("readonly") if mibBuilder.loadTexts: e1t1LOS.setStatus('mandatory') if mibBuilder.loadTexts: e1t1LOS.setDescription('if signal loss present') e1t1AIS = MibTableColumn((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 3, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("on", 1), ("off", 2)))).setMaxAccess("readonly") if mibBuilder.loadTexts: e1t1AIS.setStatus('mandatory') if mibBuilder.loadTexts: e1t1AIS.setDescription('if AIS present') e1t1ChannelNr = MibTableColumn((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 3, 1, 3), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: e1t1ChannelNr.setStatus('mandatory') if mibBuilder.loadTexts: e1t1ChannelNr.setDescription('e1 channel number (it is not associated with interface number - ifEntry)') modemCountTime = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 4, 1), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: modemCountTime.setStatus('mandatory') if mibBuilder.loadTexts: modemCountTime.setDescription('Count time in seconds') modemErroredBlock = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 4, 2), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: modemErroredBlock.setStatus('mandatory') if mibBuilder.loadTexts: modemErroredBlock.setDescription('Errored block') modemErroredSecond = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 4, 3), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: modemErroredSecond.setStatus('mandatory') if mibBuilder.loadTexts: modemErroredSecond.setDescription('Errored second') modemSeverelyErroredSecond = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 4, 4), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: modemSeverelyErroredSecond.setStatus('mandatory') if mibBuilder.loadTexts: modemSeverelyErroredSecond.setDescription('Severely errored second') modemBackgroundBlockErrror = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 4, 5), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: modemBackgroundBlockErrror.setStatus('mandatory') if mibBuilder.loadTexts: modemBackgroundBlockErrror.setDescription('Background Block Error') modemTotalBlockNumber = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 4, 6), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: modemTotalBlockNumber.setStatus('mandatory') if mibBuilder.loadTexts: modemTotalBlockNumber.setDescription('Total Block Number') modemErroredSecondRatio = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 4, 7), DisplayString()).setMaxAccess("readonly") if mibBuilder.loadTexts: modemErroredSecondRatio.setStatus('mandatory') if mibBuilder.loadTexts: modemErroredSecondRatio.setDescription('Errorred Second Ratio') modemSeverelyErroredSecondRatio = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 4, 8), DisplayString()).setMaxAccess("readonly") if mibBuilder.loadTexts: modemSeverelyErroredSecondRatio.setStatus('mandatory') if mibBuilder.loadTexts: modemSeverelyErroredSecondRatio.setDescription('Severely Errorred Second Ratio') modemBackgroundBlockErrorRatio = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 4, 9), DisplayString()).setMaxAccess("readonly") if mibBuilder.loadTexts: modemBackgroundBlockErrorRatio.setStatus('mandatory') if mibBuilder.loadTexts: modemBackgroundBlockErrorRatio.setDescription('Background Block Error Ratio') modemUptime = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 4, 10), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: modemUptime.setStatus('mandatory') if mibBuilder.loadTexts: modemUptime.setDescription('Uptime (s)') modemUnavailtime = MibScalar((1, 3, 6, 1, 4, 1, 7571, 100, 1, 1, 5, 1, 3, 4, 11), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: modemUnavailtime.setStatus('mandatory') if mibBuilder.loadTexts: modemUnavailtime.setDescription('Unavailtime (s)') mibBuilder.exportSymbols("SAF-IPRADIO", ethTXByteCounterLow=ethTXByteCounterLow, aTPCEntry=aTPCEntry, radioRxFrequency=radioRxFrequency, ethGFPCHECErrors=ethGFPCHECErrors, e1t1LOS=e1t1LOS, vlanPortmap=vlanPortmap, vlanRowStatus=vlanRowStatus, modemTable=modemTable, ipRadioCfgNetwork=ipRadioCfgNetwork, radioTxFrequency=radioTxFrequency, vlanEntry=vlanEntry, radioName=radioName, modemInternalAGCgain=modemInternalAGCgain, modemACMtotalCapacity=modemACMtotalCapacity, sysTemperature=sysTemperature, safip=safip, ethRXDones=ethRXDones, ethRXCRCErrors=ethRXCRCErrors, ethRXDvEvent=ethRXDvEvent, ethRXPrevPktDropped=ethRXPrevPktDropped, radioTxMute=radioTxMute, ethTXMulticasts=ethTXMulticasts, modemLastAcqError=modemLastAcqError, ethQOSRXQ1Dropped=ethQOSRXQ1Dropped, ethTXNonExcessiveDefers=ethTXNonExcessiveDefers, modemIndex=modemIndex, ethQOSTXFrames=ethQOSTXFrames, modemBandwith=modemBandwith, radioDuplexShift=radioDuplexShift, vlanCfgStat=vlanCfgStat, ipRadioCfgGeneral=ipRadioCfgGeneral, ethQOSRXQ1Frames=ethQOSRXQ1Frames, radioEntry=radioEntry, vlansEnabled=vlansEnabled, ethTXBackpresEvents=ethTXBackpresEvents, ethTXCollisions=ethTXCollisions, ethRXLengthCheckerrorsErrors=ethRXLengthCheckerrorsErrors, product=product, ethRXFalseCarrierErrors=ethRXFalseCarrierErrors, radioSide=radioSide, saf=saf, modemACMmodulationMax=modemACMmodulationMax, ethTXControlFrames=ethTXControlFrames, restartcpu=restartcpu, e1t1StatEntry=e1t1StatEntry, vlanNumber=vlanNumber, vlanPortType=vlanPortType, modemSeverelyErroredSecond=modemSeverelyErroredSecond, localIp=localIp, ipRadioCfg=ipRadioCfg, ethRXByteCounterLow=ethRXByteCounterLow, modemTotalCapacity=modemTotalCapacity, radioRxLevel=radioRxLevel, atpcTxPowerCorrection=atpcTxPowerCorrection, loopback_tributary_mask=loopback_tributary_mask, localIpMask=localIpMask, modemEthernetCapacity=modemEthernetCapacity, modemBackgroundBlockErrror=modemBackgroundBlockErrror, ipRadioMgmt=ipRadioMgmt, ethTXLateCollisions=ethTXLateCollisions, ethRXControlFrames=ethRXControlFrames, tehnika=tehnika, ethRXVlanTagsDetected=ethRXVlanTagsDetected, modemUnavailtime=modemUnavailtime, e1t1StatTable=e1t1StatTable, modemCarrierOffset=modemCarrierOffset, modemSymbolRateRx=modemSymbolRateRx, ethTXGiants=ethTXGiants, description=description, ethRXOutOfRangeErrors=ethRXOutOfRangeErrors, vlanFid=vlanFid, radioTable=radioTable, ethRXUnsupOpcodes=ethRXUnsupOpcodes, e1t1ChannelNr=e1t1ChannelNr, ethTXByteCounterHi=ethTXByteCounterHi, modemUptime=modemUptime, ethTXWireByteCounterLow=ethTXWireByteCounterLow, aTPCTable=aTPCTable, atpcIndex=atpcIndex, ethTXVlanTags=ethTXVlanTags, ethRXTruncatedFrames=ethRXTruncatedFrames, pointToPoint=pointToPoint, remoteIp=remoteIp, vlanTable=vlanTable, ipRadio=ipRadio, sysDateAndTime=sysDateAndTime, modemRowStatus=modemRowStatus, writeConfig=writeConfig, ethRXBroadcasts=ethRXBroadcasts, ethRXMulticasts=ethRXMulticasts, ethRXDribleNibbles=ethRXDribleNibbles, ethTXDones=ethTXDones, ethRXPauseFrames=ethRXPauseFrames, modemSymbolRateTx=modemSymbolRateTx, loopbacks=loopbacks, radioGenStatus=radioGenStatus, modemLDPCdecoderStress=modemLDPCdecoderStress, modemStandard=modemStandard, licenseMask=licenseMask, ethGFPDelineationErrors=ethGFPDelineationErrors, ipRadioStat=ipRadioStat, e1t1AIS=e1t1AIS, modemErroredBlock=modemErroredBlock, modemAcqStatus=modemAcqStatus, modemGeneralStatus=modemGeneralStatus, modemSeverelyErroredSecondRatio=modemSeverelyErroredSecondRatio, modemACMethernetCapacity=modemACMethernetCapacity, modemErroredSecondRatio=modemErroredSecondRatio, modemACMmodulationMin=modemACMmodulationMin, ethRXCodeErrors=ethRXCodeErrors, modemBackgroundBlockErrorRatio=modemBackgroundBlockErrorRatio, ethTXWireByteCounterHi=ethTXWireByteCounterHi, ipRadioStatEth=ipRadioStatEth, modemCountTime=modemCountTime, ethTXLengthCheckErrors=ethTXLengthCheckErrors, modemStatistics=modemStatistics, ethTXBroadcasts=ethTXBroadcasts, modemTotalBlockNumber=modemTotalBlockNumber, microwaveRadio=microwaveRadio, radioIndex=radioIndex, ethTXUnderruns=ethTXUnderruns, modemE1T1ChannelMask=modemE1T1ChannelMask, modemACMengine=modemACMengine, modemEntry=modemEntry, ethRXLongEvents=ethRXLongEvents, ethTXMaxCollisions=ethTXMaxCollisions, ethQOSRXQ2Frames=ethQOSRXQ2Frames, ethTXExcessiveDefers=ethTXExcessiveDefers, ethTXCRCErrors=ethTXCRCErrors, ethRXByteCounterHi=ethRXByteCounterHi, modemE1T1Channels=modemE1T1Channels, ethQOSTXDropped=ethQOSTXDropped, ethGFPDropedFrames=ethGFPDropedFrames, radioTxPower=radioTxPower, modemModulation=modemModulation, modemErroredSecond=modemErroredSecond, license=license, atpcEnabled=atpcEnabled, ethQOSRXQ2Dropped=ethQOSRXQ2Dropped, ethGFPFCSErrors=ethGFPFCSErrors, radioLoopback=radioLoopback, ethTXPauseFrames=ethTXPauseFrames, modemRadialMSE=modemRadialMSE)
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. """ This module is designed to analysis data """
gopen = open('namecheck.txt' , 'w') for i in range(1,54): fopen = open('%d' % i, 'r') for z in range(100): rline = fopen.readline() if rline: rlist = rline.split('$') name = rlist[0].strip() clg = rlist[1].strip() nlist = name.split(' ') if len(nlist)==1: gopen.write('%s, %s \n' % (name,clg)) else: break fopen.close() gopen.close()
class RectCoordinates: def __init__(self, x, y, w, h): self.startX = int(x) self.startY = int(y) self.w = int(w) self.h = int(h) self.endY = int(y + h) self.endX = int(x + w) def get_frame(self, frame): return frame[self.startY:self.endY, self.startX:self.endX]
# Reading lines from file and putting from a list to a dict dna = dict() contents = [] for line in open('rosalind_gc.txt', 'r').readlines(): contents.append(line.strip('\n')) if line[0] == '>': header = line[1:].rstrip() dna[header] = '' else: dna[header] = dna.get(header) + line.rstrip() # Using the rstrip method above to remove text format fragments (like \n or \t) # and the list greather will receive our final result greather = ['', 0, ''] for key in dna: gc_qtd = 0 for i in range(len(dna.get(key))): if dna.get(key)[i] == 'G' or dna.get(key)[i] == 'C': gc_qtd += 1 gc_percent = 100*gc_qtd/(len(dna.get(key))) if gc_percent > greather[1]: greather[0] = key greather[1] = gc_percent greather[2] = dna.get(key) print(greather[0], '\n', greather[1])
class ExpiredInstrument(Exception): def __init__(self, instrument): expire_message = f"El instrumento expiró: {instrument.maturity_date}" super().__init__(expire_message)
#!/usr/bin/python # Filename: func_default.py def say(message='3',times=1): print (message * times) say(); say(times=11) say('Hello') say('World',5) say(2,4)
""" Project Euler Problem 45 ======================== Triangle, pentagonal, and hexagonal numbers are generated by the following formulae: Triangle T[n]=n(n+1)/2 1, 3, 6, 10, 15, ... Pentagonal P[n]=n(3n-1)/2 1, 5, 12, 22, 35, ... Hexagonal H[n]=n(2n-1) 1, 6, 15, 28, 45, ... It can be verified that T[285] = P[165] = H[143] = 40755. Find the next triangle number that is also pentagonal and hexagonal. """ class GeometryHelper(object): """ Helper class to calculate triangle, pentagonal or hexagonal numbers. We can use the brackets operator (TPH[X]) as well as the contains operator (X in TPH). """ def __init__(self): # Helper[0] == 0 to make our lifes easier, as the numbers start from 1 self.numbers = [0] def formulae(self, n): """Returns the n-th number (n>=1)""" return 0 def _build(self, last): next_item = len(self.numbers) self.numbers += [self.formulae(n) for n in range(next_item, last+1)] def _build_until_number(self, last_p): next_item = len(self.numbers) while self.numbers[-1] < last_p: self.numbers.append(self.formulae(next_item)) next_item += 1 def __contains__(self, p): self._build_until_number(p) return p in self.numbers def __getitem__(self, n): if n >= len(self.numbers): self._build(n) return self.numbers[n] class TriangleHelper(GeometryHelper): def formulae(self, n): """Returns the n-th triangle number (n>1)""" return (n*(n+1))//2 class PentagonalHelper(GeometryHelper): def formulae(self, n): """Returns the n-th triangle number (n>1)""" return (n*(3*n-1))//2 class HexagonalHelper(GeometryHelper): def formulae(self, n): """Returns the n-th triangle number (n>1)""" return n*(2*n-1) # Test T = TriangleHelper() P = PentagonalHelper() H = HexagonalHelper() assert [T[i] for i in range(1, 6)] == [1, 3, 6, 10, 15] assert [P[i] for i in range(1, 6)] == [1, 5, 12, 22, 35] assert [H[i] for i in range(1, 6)] == [1, 6, 15, 28, 45] assert 15 in T assert 16 not in T assert 35 in P assert 36 not in P assert 45 in H assert 46 not in H def main(): # Simply iterate over the triangle numbers and check if the result number is # also a pentagonal and hexagonal number # We already know that T[285] = P[165] = H[143] = 40755: assert T[285] == P[165] == H[143] == 40755 assert 40755 in T assert 40755 in P assert 40755 in H # So we can start from 286 n = 286 while True: t = T[n] if t in P and t in H: return t n += 1 if __name__ == '__main__': print(main())
# -*- coding: utf-8 -*- """ Created on Sun Aug 8 12:01:02 2021 @author: Easin """ in1 = input() #print(in1) count = 0 list1 = [] list2 = [] for values in range(len(in1)): if in1[values] >= 'a' and in1[values] <= 'z': list1.append(in1[values]) flag = True for elem in range(len(list1)): for val in range(elem,len(list1)-1): if list1[elem] == list1[val+1]: flag = False break if flag == True: count += 1 flag = True print(count)
def negate_condition(condition: callable): def _f(context): return not condition(context) return _f def dummy(context: dict) -> dict: return context class Transition: def __init__(self, next_state: object, condition: callable, callback: callable = dummy): self.next_state = next_state self.condition = condition self.callback = callback def check_condition(self, context): transition = self.condition(context) if not isinstance(transition, bool): raise RuntimeError(f"Wrong transition return type. " f"Next state: {self.next_state} " f"Returned: {transition} " f"Return type: {type(transition)} " f"Expected: Bool") return transition
# python3 def compute_min_number_of_refills(d, m, stops): assert 1 <= d <= 10 ** 5 assert 1 <= m <= 400 assert 1 <= len(stops) <= 300 assert 0 < stops[0] and all(stops[i] < stops[i + 1] for i in range(len(stops) - 1)) and stops[-1] < d count = 0 curr = 0 stops.insert(0, 0) stops.append(d) n = len(stops) - 2 while curr <= n: last = curr while curr <= n and stops[curr + 1] - stops[last] <= m: curr += 1 if curr == last: return -1 elif curr <= n: count += 1 return count if __name__ == '__main__': input_d = int(input()) input_m = int(input()) input_n = int(input()) input_stops = list(map(int, input().split())) assert len(input_stops) == input_n print(compute_min_number_of_refills(input_d, input_m, input_stops))
"""Decode ASCII-encoded messages""" def decode(coded): """Decode a string of ASCII codes""" return ''.join(map(chr, map(int, coded.split()))) if __name__ == '__main__': print(decode(''' 67 111 109 101 32 105 110 32 97 32 78 101 119 32 89 101 97 114 39 115 32 99 97 112 32 116 111 32 83 97 118 101 110 107 111 118 033 ''')) print(decode(''' 77 115 102 112 117 110 105 108 104 121 '''))
def applicant_selector(gpa,ps_score,ec_count): message = "This applicant should be rejected." if (gpa >= 3): if (ps_score >= 90): if (ec_count >= 3): message = "This applicant should be accepted." else: message = "This applicant should be given an in-person interview." return message
# lc551.py # LeetCode 551. Student Attendance Record I `E` # acc | 91% | 13' # A~0f27 class Solution: def checkRecord(self, s: str) -> bool: a = 0 l = 0 for c in s: if c == "L": l += 1 if l > 2: return False else: l = 0 if c == "A": a += 1 if a > 1: return False return True
inp = input() def palin(inp): if len(inp)==1: return True elif len(inp)==2: return inp[0]==inp[1] else: return inp[0]==inp[-1] and palin(inp[1:-1]) if palin(inp): print('PALINDROME') else: print('NOT PALINDROME')
def bazel_toolchains_repositories(): org_chromium_clang_mac() org_chromium_clang_linux_x64() org_chromium_sysroot_linux_x64() org_chromium_binutils_linux_x64() org_chromium_libcxx() org_chromium_libcxxabi() def org_chromium_clang_mac(): native.new_http_archive( name = 'org_chromium_clang_mac', build_file = str(Label('//build_files:org_chromium_clang_mac.BUILD')), sha256 = '4f0aca6ec66281be94c3045550ae15a73befa59c32396112abda0030ef22e9b6', urls = ['http://172.16.52.102/clang/mac/clang-318667-1.tgz'], ) def org_chromium_clang_linux_x64(): native.new_http_archive( name = 'org_chromium_clang_linux_x64', build_file = str(Label('//build_files:org_chromium_clang_linux_x64.BUILD')), sha256 = 'e63e5fe3ec8eee4779812cd16aae0ddaf1256d2e8e93cdd5914a3d3e01355dc1', urls = ['http://172.16.52.102/clang/linux/clang-318667-1.tgz'], ) def org_chromium_sysroot_linux_x64(): native.new_http_archive( name = 'org_chromium_sysroot_linux_x64', build_file = str(Label('//build_files:org_chromium_sysroot_linux_x64.BUILD')), sha256 = '84656a6df544ecef62169cfe3ab6e41bb4346a62d3ba2a045dc5a0a2ecea94a3', urls = ['http://172.16.52.102/clang/linux/debian_stretch_amd64_sysroot.tar.xz'], ) def org_chromium_binutils_linux_x64(): native.new_http_archive( name = 'org_chromium_binutils_linux_x64', build_file = str(Label('//build_files:org_chromium_binutils_linux_x64.BUILD')), sha256 = '24c3df44af5bd377c701ee31b9b704f2ea23456f20e63652c8235a10d7cf1be7', type = 'tar.bz2', urls = ['http://172.16.52.102/clang/linux/binutils.tar.bz2'], ) def org_chromium_libcxx(): native.new_http_archive( name = 'org_chromium_libcxx', build_file = str(Label('//build_files:org_chromium_libcxx.BUILD')), sha256 = '0d86a5ad81ada4a1c80e81a69ae99116d7d0452c85f414d01899500bc4c1eeb8', urls = ['http://172.16.52.102/clang/linux/libcxx-f56f1bba1ade4a408d403ff050d50e837bae47df.tar.gz'], ) def org_chromium_libcxxabi(): native.new_http_archive( name = 'org_chromium_libcxxabi', build_file = str(Label('//build_files:org_chromium_libcxxabi.BUILD')), sha256 = '27fb5d944665ad2985110916fffab079aa07bf13191286587516442d52efd235', urls = ['http://172.16.52.102/clang/linux/libcxxabi-05ba3281482304ae8de31123a594972a495da06d.tar.gz'], )
# This file contains the set of rules of basic # defining the constants DIGITS = '0123456789' # defining the token types TOKEN_INT = 'INT' TOKEN_FLOAT = 'FLOAT' TOKEN_PLUS = 'PLUS' TOKEN_MULTI = 'MUL' TOKEN_MINUS = 'MINUS' TOKEN_DIVIDE = 'DIV' TOKEN_LPAREN = 'LPAREN' # left parenthesis TOKEN_RPAREN = 'RPAREN' # right parenthesis # positions class class Position: def __init__(self, indx, line, column, file_name, file_txt): self.indx = indx self.line = line self.column = column self.file_name = file_name self.file_txt = file_txt def go_through(self, current_char): self.indx += 1 self.column += 1 if(current_char == '\n'): self.line += 1 self.column = 0 return self def copy(self): return Position(self.indx, self.line, self.column, self.file_name, self.file_txt) # error class class Error: def __init__(self, position_start, position_end, name, description): self.position_start = position_start self.position_end = position_end self.name = name # name of the error self.description = description # description for you to know how to fix it def error_message(self): message = f'{self.name}: {self.description}' message += f'File {self.position_start.file_name}, line {self.position_start.line + 1}' return message # class to define the illegal character error class IllegalCharError(Error): # usging inheritance here for better organization def __init__(self, position_start, position_end, description): super().__init__(position_start, position_end, 'Illegal Character', description) # defining the architecture of the token and how it's gonna be handled class Token: def __init__(self, the_type, value=None): # type is a reserved word, so make to not put exactly type here self.type = the_type self.value = value def __repr__(self): if self.value: return str(f'{self.type}:{self.value}') return f'{self.type}' # defining the lexer, they give meaning to the tokens through the programming language's set of rules class Lexer: def __init__(self, file_name, txt): self.file_name = file_name self.txt = txt self.position = Position(-1, 0, -1, file_name, txt) # we start at -1, because the advance function is gonna increment the index immediatly self.current_char = None self.next_char() # defining function to iterate through every character def next_char(self): self.position.go_through(self.current_char) self.current_char = self.txt[self.position.indx] if self.position.indx < len(self.txt) else None # defining function to create token based on the rules of basic def create_tokens(self): tokens = [] # list of tokens while self.current_char != None: if (self.current_char in '\t'): self.next_char() elif(self.current_char in DIGITS): tokens.append(self.create_num()) # giving identity to the arithmetic operators # from here elif(self.current_char == '+'): tokens.append(Token(TOKEN_PLUS)) self.next_char() elif(self.current_char == '-'): tokens.append(Token(TOKEN_MINUS)) self.next_char() elif(self.current_char == '*'): tokens.append(Token(TOKEN_MULTI)) self.next_char() elif(self.current_char == '/'): tokens.append(Token(TOKEN_DIVIDE)) self.next_char() elif(self.current_char == '('): tokens.append(Token(TOKEN_LPAREN)) self.next_char() elif(self.current_char == ')'): tokens.append(Token(TOKEN_RPAREN)) self.next_char() # to here elif(self.current_char == ' '): # making it possible to use spaces self.next_char() else: # Throwing error position_start = self.position.copy() illegal_char = self.current_char self.next_char() return [], IllegalCharError(position_start, self.position, "'" + illegal_char + "'") return tokens, None # set of rules to deal with numbers def create_num (self): num_string = '' has_dot = False # has_dot is to define the number as an integer or float while self.current_char != None and self.current_char in DIGITS + '.': if(self.current_char == '.'): if(has_dot): break has_dot = True num_string += '.' else: num_string += self.current_char self.next_char() if(not has_dot): return Token(TOKEN_INT, int(num_string)) else: return Token(TOKEN_FLOAT, float(num_string)) def run(file_name, txt): lexer = Lexer(file_name, txt) tokens, error = lexer.create_tokens() return tokens, error
""" Constants for the Desktop Processes integration. """ NAME = "Desktop Processes" DOMAIN = "desktop_processes" IGNORE = "ignore" PRIORITY = "priority" ATTR_CONFIG = "config" VERSION = "0.1.0" STARTUP_MESSAGE = f""" ------------------------------------------------------------------- {NAME} Version: {VERSION} This is a custom integration bitch! If you have any issues with this you need to open an issue here: ------------------------------------------------------------------- """
{ "targets": [{ "target_name": "ui", "include_dirs": ["<(module_root_dir)/src/includes", "<(module_root_dir)"], "sources": [ '<!@(node tools/list-sources.js)' ], "conditions": [ ["OS=='win'", { "libraries": [ "<(module_root_dir)/libui.lib" ] }], ["OS=='linux'", { "cflags": ["-fvisibility=hidden" ,"-std=gnu11"], 'ldflags': [ "-Wl,-rpath,'$$ORIGIN',-rpath,<(module_root_dir)", ], "libraries": [ "<(module_root_dir)/libui.so" ], 'include_dirs': [ '<!@(pkg-config gtk+-3.0 --cflags-only-I | sed s/-I//g)' ] }], ["OS=='mac'", { "xcode_settings": { "OTHER_LDFLAGS": [ "-fvisibility=hidden", "-L<(module_root_dir)", "-lui", "-rpath", "'@loader_path'", "-rpath", "<(module_root_dir)" ] } }], ] }, { "target_name": "copy_binary", "type":"none", "dependencies": [ "ui" ], "copies": [ { 'destination': '<(module_root_dir)', 'files': ['<(module_root_dir)/build/Release/ui.node'] } ] }] }
# programmers L4 : 도둑질 # solved by JY # DATE : 2021.03.12 # DP 사용 # dp[i] = 집 i번 째까지 털었을 때 최대 금액 # dp[0][] = 1번 집부터 털기 # dp[1][] = 2번 집부터 털기 # dp[][i] = max(dp[][i-2] + m[i-1], dp[][i-1]) def solution(money): dp = [[0]*(len(money) + 1) for _ in range(2)] dp[0][0], dp[0][1], dp[0][2] = 0, money[0], money[0] # 1번째 집부터 털었을 경우 for idx in range(3, len(money)): dp[0][idx] = max(dp[0][idx-2] + money[idx-1], dp[0][idx-1]) dp[1][0], dp[1][1], dp[1][2] = 0, 0, money[1] # 2번째 집부터 털었을 경우 for idx in range(3, len(money) + 1): dp[1][idx] = max(dp[1][idx-2] + money[idx-1], dp[1][idx-1]) return max(dp[0][-2], dp[1][-1]) # run test print(solution([1, 2, 3, 1]), 4)
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Feb 25 13:53:05 2017 @author: venusgrape In this problem, you'll create a program that guesses a secret number! The program works as follows: you (the user) thinks of an integer between 0 (inclusive) and 100 (not inclusive). The computer makes guesses, and you give it input - is its guess too high or too low? Using bisection search, the computer will guess the user's secret number! Here is a transcript of an example session: Please think of a number between 0 and 100! Is your secret number 50? Enter 'h' to indicate the guess is too high. Enter 'l' to indicate the guess is too low. Enter 'c' to indicate I guessed correctly. l Is your secret number 75? Enter 'h' to indicate the guess is too high. Enter 'l' to indicate the guess is too low. Enter 'c' to indicate I guessed correctly. l Is your secret number 87? Enter 'h' to indicate the guess is too high. Enter 'l' to indicate the guess is too low. Enter 'c' to indicate I guessed correctly. h Is your secret number 81? Enter 'h' to indicate the guess is too high. Enter 'l' to indicate the guess is too low. Enter 'c' to indicate I guessed correctly. l Is your secret number 84? Enter 'h' to indicate the guess is too high. Enter 'l' to indicate the guess is too low. Enter 'c' to indicate I guessed correctly. h Is your secret number 82? Enter 'h' to indicate the guess is too high. Enter 'l' to indicate the guess is too low. Enter 'c' to indicate I guessed correctly. l Is your secret number 83? Enter 'h' to indicate the guess is too high. Enter 'l' to indicate the guess is too low. Enter 'c' to indicate I guessed correctly. c Game over. Your secret number was: 83 Important Hint: Endpoints ** Your program should use bisection search. So think carefully what that means. What will the first guess always be? How should you calculate subsequent guesses? ** Your initial endpoints should be 0 and 100. Do not optimize your subsequent endpoints by making them be the halfway point plus or minus 1. Rather, just make them be the halfway point. Python Trick: Printing on the same line Note: your program should use input to obtain the user's input! Be sure to handle the case when the user's input is not one of h, l, or c. When the user enters something invalid, you should print out a message to the user explaining you did not understand their input. Then, you should re-ask the question, and prompt again for input. For example: Is your secret number 91? Enter 'h' to indicate the guess is too high. Enter 'l' to indicate the guess is too low. Enter 'c' to indicate I guessed correctly. y Sorry, I did not understand your input. Is your secret number 91? Enter 'h' to indicate the guess is too high. Enter 'l' to indicate the guess is too low. Enter 'c' to indicate I guessed correctly. c """ n = 100 epsilon = 0.01 low = 0 high = n ans = (low + high)/2.0 #print(ans) while ans**2 - n >= epsilon: print('Is your secret number', end = ' ') print(ans,end = ' ') print('?') letter = input("Enter 'h' to indicate the guess is too high. \ Enter 'l' to indicate the guess is too low. \ Enter 'c' to indicate I guessed correctly.") if letter == 'h': high = ans ans = (high + low)/2 elif letter == 'l': low = ans ans = (high + low)/2 elif letter == 'c': print('Game over, My answer is:',end = ' ') print(ans) break else: print("Sorry, I did not understand your input.")
""" Code From: https://github.com/laurentluce/python-algorithms/ The MIT License (MIT) Copyright (c) 2015 Laurent Luce 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. Aditional functionality added by CBRYCE for the book Learning Python for Forensics. """ def update(h, const, chunk_size, old_char, new_char): h = (h - int(old_char))/const h += (int(new_char) * (const ** (chunk_size-1))) return h def hash(s, const): """Calculate the hash value of a string using base. Example: 'abc' = 97 x base^2 + 98 x base^1 + 99 x base^0 @param s value to compute hash value for @param const int to use to compute hash value @return hash value """ v = 0 p = len(s)-1 for i in reversed(range(p+1)): v += int(s[i]) * (const ** p) p -= 1 return v
class Solution: # Sorting key function (Accepted), O(n log n) time, O(n) space def sortByBits(self, arr: List[int]) -> List[int]: def tup(n): return (bin(n).count('1'), n) return sorted(arr, key=tup) # One Liner (Top Voted), O(n log n) time, O(n) space def sortByBits(self, A): return sorted(A, key=lambda a: (bin(a).count('1'), a))
# # PySNMP MIB module STN-CHASSIS-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/STN-CHASSIS-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 21:03:23 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") ConstraintsUnion, SingleValueConstraint, ConstraintsIntersection, ValueRangeConstraint, ValueSizeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsUnion", "SingleValueConstraint", "ConstraintsIntersection", "ValueRangeConstraint", "ValueSizeConstraint") ObjectGroup, ModuleCompliance, NotificationGroup = mibBuilder.importSymbols("SNMPv2-CONF", "ObjectGroup", "ModuleCompliance", "NotificationGroup") iso, Gauge32, TimeTicks, Integer32, Counter64, MibIdentifier, MibScalar, MibTable, MibTableRow, MibTableColumn, Counter32, ObjectIdentity, Bits, IpAddress, Unsigned32, ModuleIdentity, NotificationType = mibBuilder.importSymbols("SNMPv2-SMI", "iso", "Gauge32", "TimeTicks", "Integer32", "Counter64", "MibIdentifier", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Counter32", "ObjectIdentity", "Bits", "IpAddress", "Unsigned32", "ModuleIdentity", "NotificationType") TextualConvention, DisplayString = mibBuilder.importSymbols("SNMPv2-TC", "TextualConvention", "DisplayString") stnNotification, stnSystems = mibBuilder.importSymbols("SPRING-TIDE-NETWORKS-SMI", "stnNotification", "stnSystems") StnHardwareSubModuleType, StnPowerStatus, StnEngineOperStatus, StnEngineAdminStatus, StnResourceStatus, StnModuleAdminStatus, StnModuleOperStatus, StnBatteryStatus, StnFlashStatus, StnHardwareModuleType, StnLedStatus = mibBuilder.importSymbols("SPRING-TIDE-NETWORKS-TC", "StnHardwareSubModuleType", "StnPowerStatus", "StnEngineOperStatus", "StnEngineAdminStatus", "StnResourceStatus", "StnModuleAdminStatus", "StnModuleOperStatus", "StnBatteryStatus", "StnFlashStatus", "StnHardwareModuleType", "StnLedStatus") stnChassis = ModuleIdentity((1, 3, 6, 1, 4, 1, 3551, 2, 1)) if mibBuilder.loadTexts: stnChassis.setLastUpdated('0002160000Z') if mibBuilder.loadTexts: stnChassis.setOrganization('Spring Tide Networks, Inc.') stnChassisObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1)) stnChassisMibConformance = MibIdentifier((1, 3, 6, 1, 4, 1, 3551, 2, 1, 2)) stnChassisVars = MibIdentifier((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 1)) stnModules = MibIdentifier((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 2)) stnLeds = MibIdentifier((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 3)) stnPower = MibIdentifier((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 4)) stnResource = MibIdentifier((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 5)) stnChassisTrapVars = MibIdentifier((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 100)) stnChassisSysType = MibScalar((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 1, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("other", 1), ("stn5000", 2)))).setMaxAccess("readonly") if mibBuilder.loadTexts: stnChassisSysType.setStatus('current') stnChassisSysDescr = MibScalar((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 1, 2), DisplayString()).setMaxAccess("readonly") if mibBuilder.loadTexts: stnChassisSysDescr.setStatus('current') stnChassisId = MibScalar((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 1, 3), DisplayString()).setMaxAccess("readonly") if mibBuilder.loadTexts: stnChassisId.setStatus('current') stnSlotTable = MibTable((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 2, 1), ) if mibBuilder.loadTexts: stnSlotTable.setStatus('current') stnSlotEntry = MibTableRow((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 2, 1, 1), ).setIndexNames((0, "STN-CHASSIS-MIB", "stnSlotIndex")) if mibBuilder.loadTexts: stnSlotEntry.setStatus('current') stnSlotIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 2, 1, 1, 1), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: stnSlotIndex.setStatus('current') stnModuleType = MibTableColumn((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 2, 1, 1, 2), StnHardwareModuleType()).setMaxAccess("readonly") if mibBuilder.loadTexts: stnModuleType.setStatus('current') stnModulePeer = MibTableColumn((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 2, 1, 1, 3), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: stnModulePeer.setStatus('current') stnModuleAdminStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 2, 1, 1, 4), StnModuleAdminStatus()).setMaxAccess("readonly") if mibBuilder.loadTexts: stnModuleAdminStatus.setStatus('current') stnModuleOperStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 2, 1, 1, 5), StnModuleOperStatus()).setMaxAccess("readonly") if mibBuilder.loadTexts: stnModuleOperStatus.setStatus('current') stnModuleDescr = MibTableColumn((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 2, 1, 1, 6), DisplayString()).setMaxAccess("readonly") if mibBuilder.loadTexts: stnModuleDescr.setStatus('current') stnModuleLed = MibTableColumn((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 2, 1, 1, 7), StnLedStatus()).setMaxAccess("readonly") if mibBuilder.loadTexts: stnModuleLed.setStatus('current') stnSubModules = MibTableColumn((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 2, 1, 1, 8), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: stnSubModules.setStatus('current') stnSubModuleTable = MibTable((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 2, 2), ) if mibBuilder.loadTexts: stnSubModuleTable.setStatus('current') stnSubModuleEntry = MibTableRow((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 2, 2, 1), ).setIndexNames((0, "STN-CHASSIS-MIB", "stnSubModuleSlot"), (0, "STN-CHASSIS-MIB", "stnSubModuleIndex")) if mibBuilder.loadTexts: stnSubModuleEntry.setStatus('current') stnSubModuleSlot = MibTableColumn((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 2, 2, 1, 1), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: stnSubModuleSlot.setStatus('current') stnSubModuleIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 2, 2, 1, 2), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: stnSubModuleIndex.setStatus('current') stnSubModuleType = MibTableColumn((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 2, 2, 1, 3), StnHardwareSubModuleType()).setMaxAccess("readonly") if mibBuilder.loadTexts: stnSubModuleType.setStatus('current') stnSubModulePeer = MibTableColumn((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 2, 2, 1, 4), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: stnSubModulePeer.setStatus('current') stnSubModuleAdminStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 2, 2, 1, 5), StnModuleAdminStatus()).setMaxAccess("readonly") if mibBuilder.loadTexts: stnSubModuleAdminStatus.setStatus('current') stnSubModuleOperStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 2, 2, 1, 6), StnModuleOperStatus()).setMaxAccess("readonly") if mibBuilder.loadTexts: stnSubModuleOperStatus.setStatus('current') stnSubModuleDescr = MibTableColumn((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 2, 2, 1, 7), DisplayString()).setMaxAccess("readonly") if mibBuilder.loadTexts: stnSubModuleDescr.setStatus('current') stnEngineTable = MibTable((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 2, 3), ) if mibBuilder.loadTexts: stnEngineTable.setStatus('current') stnEngineEntry = MibTableRow((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 2, 3, 1), ).setIndexNames((0, "STN-CHASSIS-MIB", "stnEngineIndex")) if mibBuilder.loadTexts: stnEngineEntry.setStatus('current') stnEngineIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 2, 3, 1, 1), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: stnEngineIndex.setStatus('current') stnEngineSlot = MibTableColumn((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 2, 3, 1, 2), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: stnEngineSlot.setStatus('current') stnEngineCpu = MibTableColumn((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 2, 3, 1, 3), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: stnEngineCpu.setStatus('current') stnEngineType = MibTableColumn((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 2, 3, 1, 4), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5))).clone(namedValues=NamedValues(("unknown", 1), ("swc", 2), ("rpe", 3), ("ecf", 4), ("ecf2", 5)))).setMaxAccess("readonly") if mibBuilder.loadTexts: stnEngineType.setStatus('current') stnEnginePeer = MibTableColumn((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 2, 3, 1, 5), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: stnEnginePeer.setStatus('current') stnEngineAdminStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 2, 3, 1, 6), StnEngineAdminStatus()).setMaxAccess("readonly") if mibBuilder.loadTexts: stnEngineAdminStatus.setStatus('current') stnEngineOperStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 2, 3, 1, 7), StnEngineOperStatus()).setMaxAccess("readonly") if mibBuilder.loadTexts: stnEngineOperStatus.setStatus('current') stnEngineDescr = MibTableColumn((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 2, 3, 1, 8), DisplayString()).setMaxAccess("readonly") if mibBuilder.loadTexts: stnEngineDescr.setStatus('current') stnLedFanTray = MibScalar((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 3, 1), StnLedStatus()).setMaxAccess("readonly") if mibBuilder.loadTexts: stnLedFanTray.setStatus('current') stnLedPowerA = MibScalar((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 3, 2), StnLedStatus()).setMaxAccess("readonly") if mibBuilder.loadTexts: stnLedPowerA.setStatus('current') stnLedPowerB = MibScalar((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 3, 3), StnLedStatus()).setMaxAccess("readonly") if mibBuilder.loadTexts: stnLedPowerB.setStatus('current') stnLedAlarm = MibScalar((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 3, 4), StnLedStatus()).setMaxAccess("readonly") if mibBuilder.loadTexts: stnLedAlarm.setStatus('current') stnFanTrayLedTable = MibTable((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 3, 5), ) if mibBuilder.loadTexts: stnFanTrayLedTable.setStatus('current') stnFanTrayLedEntry = MibTableRow((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 3, 5, 1), ).setIndexNames((0, "STN-CHASSIS-MIB", "stnFanTrayLedIndex")) if mibBuilder.loadTexts: stnFanTrayLedEntry.setStatus('current') stnFanTrayLedIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 3, 5, 1, 1), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: stnFanTrayLedIndex.setStatus('current') stnFanTrayLedSlotIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 3, 5, 1, 2), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: stnFanTrayLedSlotIndex.setStatus('current') stnFanTrayLedStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 3, 5, 1, 3), StnLedStatus()).setMaxAccess("readonly") if mibBuilder.loadTexts: stnFanTrayLedStatus.setStatus('current') stnPortLedTable = MibTable((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 3, 6), ) if mibBuilder.loadTexts: stnPortLedTable.setStatus('current') stnPortLedEntry = MibTableRow((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 3, 6, 1), ).setIndexNames((0, "STN-CHASSIS-MIB", "stnPortLedSlotIndex"), (0, "STN-CHASSIS-MIB", "stnPortLedPortIndex"), (0, "STN-CHASSIS-MIB", "stnPortLedIndex")) if mibBuilder.loadTexts: stnPortLedEntry.setStatus('current') stnPortLedSlotIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 3, 6, 1, 1), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: stnPortLedSlotIndex.setStatus('current') stnPortLedPortIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 3, 6, 1, 2), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: stnPortLedPortIndex.setStatus('current') stnPortLedIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 3, 6, 1, 3), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: stnPortLedIndex.setStatus('current') stnPortLedStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 3, 6, 1, 4), StnLedStatus()).setMaxAccess("readonly") if mibBuilder.loadTexts: stnPortLedStatus.setStatus('current') stnPortLedDescr = MibTableColumn((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 3, 6, 1, 5), DisplayString()).setMaxAccess("readonly") if mibBuilder.loadTexts: stnPortLedDescr.setStatus('current') stnPowerTable = MibTable((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 4, 1), ) if mibBuilder.loadTexts: stnPowerTable.setStatus('current') stnPowerEntry = MibTableRow((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 4, 1, 1), ).setIndexNames((0, "STN-CHASSIS-MIB", "stnPowerIndex")) if mibBuilder.loadTexts: stnPowerEntry.setStatus('current') stnPowerIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 4, 1, 1, 1), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: stnPowerIndex.setStatus('current') stnPowerStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 4, 1, 1, 2), StnPowerStatus()).setMaxAccess("readonly") if mibBuilder.loadTexts: stnPowerStatus.setStatus('current') stnPowerDescr = MibTableColumn((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 4, 1, 1, 3), DisplayString()).setMaxAccess("readonly") if mibBuilder.loadTexts: stnPowerDescr.setStatus('current') stnBatteryTable = MibTable((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 4, 2), ) if mibBuilder.loadTexts: stnBatteryTable.setStatus('current') stnBatteryEntry = MibTableRow((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 4, 2, 1), ).setIndexNames((0, "STN-CHASSIS-MIB", "stnBatterySlotIndex")) if mibBuilder.loadTexts: stnBatteryEntry.setStatus('current') stnBatterySlotIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 4, 2, 1, 1), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: stnBatterySlotIndex.setStatus('current') stnBatteryType = MibTableColumn((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 4, 2, 1, 2), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: stnBatteryType.setStatus('current') stnBatteryStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 4, 2, 1, 3), StnBatteryStatus()).setMaxAccess("readonly") if mibBuilder.loadTexts: stnBatteryStatus.setStatus('current') stnBatteryDescr = MibTableColumn((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 4, 2, 1, 4), DisplayString()).setMaxAccess("readonly") if mibBuilder.loadTexts: stnBatteryDescr.setStatus('current') stnCpuUtilizationTable = MibTable((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 5, 1), ) if mibBuilder.loadTexts: stnCpuUtilizationTable.setStatus('current') stnCpuUtilizationEntry = MibTableRow((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 5, 1, 1), ).setIndexNames((0, "STN-CHASSIS-MIB", "stnCpuUtilizationIndex")) if mibBuilder.loadTexts: stnCpuUtilizationEntry.setStatus('current') stnCpuUtilizationIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 5, 1, 1, 1), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: stnCpuUtilizationIndex.setStatus('current') stnCpuUtilizationCurrent = MibTableColumn((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 5, 1, 1, 2), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: stnCpuUtilizationCurrent.setStatus('current') stnCpuUtilization5Min = MibTableColumn((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 5, 1, 1, 3), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: stnCpuUtilization5Min.setStatus('current') stnCpuUtilization15Min = MibTableColumn((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 5, 1, 1, 4), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: stnCpuUtilization15Min.setStatus('current') stnCpuUtilization30Min = MibTableColumn((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 5, 1, 1, 5), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: stnCpuUtilization30Min.setStatus('current') stnCpuIpTable = MibTable((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 5, 2), ) if mibBuilder.loadTexts: stnCpuIpTable.setStatus('current') stnCpuIpEntry = MibTableRow((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 5, 2, 1), ).setIndexNames((0, "STN-CHASSIS-MIB", "stnCpuIpIndex")) if mibBuilder.loadTexts: stnCpuIpEntry.setStatus('current') stnCpuIpIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 5, 2, 1, 1), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: stnCpuIpIndex.setStatus('current') stnCpuIpRouteLimit = MibTableColumn((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 5, 2, 1, 2), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: stnCpuIpRouteLimit.setStatus('current') stnCpuIpRoutesInUse = MibTableColumn((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 5, 2, 1, 3), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: stnCpuIpRoutesInUse.setStatus('current') stnCpuIpRoutesBooked = MibTableColumn((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 5, 2, 1, 4), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: stnCpuIpRoutesBooked.setStatus('current') stnCpuIpFwdProcesses = MibTableColumn((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 5, 2, 1, 5), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: stnCpuIpFwdProcesses.setStatus('current') stnCpuIpRoutingProcesses = MibTableColumn((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 5, 2, 1, 6), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: stnCpuIpRoutingProcesses.setStatus('current') stnNotificationCfgChangeTime = MibScalar((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 100, 1), TimeTicks()).setMaxAccess("readonly") if mibBuilder.loadTexts: stnNotificationCfgChangeTime.setStatus('current') stnNotificationFlashStatus = MibScalar((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 100, 2), StnFlashStatus()).setMaxAccess("readonly") if mibBuilder.loadTexts: stnNotificationFlashStatus.setStatus('current') stnNotificationModuleTemperature = MibScalar((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 100, 3), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: stnNotificationModuleTemperature.setStatus('current') stnNotificationResourceStatus = MibScalar((1, 3, 6, 1, 4, 1, 3551, 2, 1, 1, 100, 4), StnResourceStatus()).setMaxAccess("readonly") if mibBuilder.loadTexts: stnNotificationResourceStatus.setStatus('current') stnRedundant = NotificationType((1, 3, 6, 1, 4, 1, 3551, 2, 100, 0, 1)).setObjects(("STN-CHASSIS-MIB", "stnSlotIndex"), ("STN-CHASSIS-MIB", "stnModuleType"), ("STN-CHASSIS-MIB", "stnModuleOperStatus")) if mibBuilder.loadTexts: stnRedundant.setStatus('current') stnNotRedundant = NotificationType((1, 3, 6, 1, 4, 1, 3551, 2, 100, 0, 2)).setObjects(("STN-CHASSIS-MIB", "stnSlotIndex"), ("STN-CHASSIS-MIB", "stnModuleType"), ("STN-CHASSIS-MIB", "stnModuleOperStatus")) if mibBuilder.loadTexts: stnNotRedundant.setStatus('current') stnModuleUp = NotificationType((1, 3, 6, 1, 4, 1, 3551, 2, 100, 0, 3)).setObjects(("STN-CHASSIS-MIB", "stnSlotIndex"), ("STN-CHASSIS-MIB", "stnModuleType"), ("STN-CHASSIS-MIB", "stnModuleOperStatus"), ("STN-CHASSIS-MIB", "stnModuleDescr"), ("STN-CHASSIS-MIB", "stnSubModules")) if mibBuilder.loadTexts: stnModuleUp.setStatus('current') stnModuleDown = NotificationType((1, 3, 6, 1, 4, 1, 3551, 2, 100, 0, 4)).setObjects(("STN-CHASSIS-MIB", "stnSlotIndex"), ("STN-CHASSIS-MIB", "stnModuleType"), ("STN-CHASSIS-MIB", "stnModuleOperStatus"), ("STN-CHASSIS-MIB", "stnModuleDescr"), ("STN-CHASSIS-MIB", "stnSubModules")) if mibBuilder.loadTexts: stnModuleDown.setStatus('current') stnSubModuleUp = NotificationType((1, 3, 6, 1, 4, 1, 3551, 2, 100, 0, 5)).setObjects(("STN-CHASSIS-MIB", "stnSubModuleSlot"), ("STN-CHASSIS-MIB", "stnSubModuleIndex"), ("STN-CHASSIS-MIB", "stnSubModuleType"), ("STN-CHASSIS-MIB", "stnSubModuleOperStatus"), ("STN-CHASSIS-MIB", "stnSubModuleDescr")) if mibBuilder.loadTexts: stnSubModuleUp.setStatus('current') stnSubModuleDown = NotificationType((1, 3, 6, 1, 4, 1, 3551, 2, 100, 0, 6)).setObjects(("STN-CHASSIS-MIB", "stnSubModuleSlot"), ("STN-CHASSIS-MIB", "stnSubModuleIndex"), ("STN-CHASSIS-MIB", "stnSubModuleType"), ("STN-CHASSIS-MIB", "stnSubModuleOperStatus"), ("STN-CHASSIS-MIB", "stnSubModuleDescr")) if mibBuilder.loadTexts: stnSubModuleDown.setStatus('current') stnEngineUp = NotificationType((1, 3, 6, 1, 4, 1, 3551, 2, 100, 0, 7)).setObjects(("STN-CHASSIS-MIB", "stnEngineIndex"), ("STN-CHASSIS-MIB", "stnEngineSlot"), ("STN-CHASSIS-MIB", "stnEngineCpu"), ("STN-CHASSIS-MIB", "stnEngineType"), ("STN-CHASSIS-MIB", "stnEngineOperStatus")) if mibBuilder.loadTexts: stnEngineUp.setStatus('current') stnEngineDown = NotificationType((1, 3, 6, 1, 4, 1, 3551, 2, 100, 0, 8)).setObjects(("STN-CHASSIS-MIB", "stnEngineIndex"), ("STN-CHASSIS-MIB", "stnEngineSlot"), ("STN-CHASSIS-MIB", "stnEngineCpu"), ("STN-CHASSIS-MIB", "stnEngineType"), ("STN-CHASSIS-MIB", "stnEngineOperStatus")) if mibBuilder.loadTexts: stnEngineDown.setStatus('current') stnBatteryLow = NotificationType((1, 3, 6, 1, 4, 1, 3551, 2, 100, 0, 9)).setObjects(("STN-CHASSIS-MIB", "stnBatterySlotIndex"), ("STN-CHASSIS-MIB", "stnBatteryType"), ("STN-CHASSIS-MIB", "stnBatteryStatus")) if mibBuilder.loadTexts: stnBatteryLow.setStatus('current') stnFlashFailure = NotificationType((1, 3, 6, 1, 4, 1, 3551, 2, 100, 0, 10)).setObjects(("STN-CHASSIS-MIB", "stnNotificationFlashStatus")) if mibBuilder.loadTexts: stnFlashFailure.setStatus('current') stnResourceFailure = NotificationType((1, 3, 6, 1, 4, 1, 3551, 2, 100, 0, 11)).setObjects(("STN-CHASSIS-MIB", "stnNotificationResourceStatus")) if mibBuilder.loadTexts: stnResourceFailure.setStatus('current') stnFailover = NotificationType((1, 3, 6, 1, 4, 1, 3551, 2, 100, 0, 12)).setObjects(("STN-CHASSIS-MIB", "stnSlotIndex"), ("STN-CHASSIS-MIB", "stnModuleType")) if mibBuilder.loadTexts: stnFailover.setStatus('current') stnCfgChange = NotificationType((1, 3, 6, 1, 4, 1, 3551, 2, 100, 0, 19)).setObjects(("STN-CHASSIS-MIB", "stnNotificationCfgChangeTime")) if mibBuilder.loadTexts: stnCfgChange.setStatus('current') stnPowerFailure = NotificationType((1, 3, 6, 1, 4, 1, 3551, 2, 100, 0, 55)).setObjects(("STN-CHASSIS-MIB", "stnPowerIndex"), ("STN-CHASSIS-MIB", "stnPowerStatus")) if mibBuilder.loadTexts: stnPowerFailure.setStatus('current') stnTemperatureFailure = NotificationType((1, 3, 6, 1, 4, 1, 3551, 2, 100, 0, 56)).setObjects(("STN-CHASSIS-MIB", "stnSlotIndex"), ("STN-CHASSIS-MIB", "stnModuleType"), ("STN-CHASSIS-MIB", "stnSubModuleType"), ("STN-CHASSIS-MIB", "stnNotificationModuleTemperature")) if mibBuilder.loadTexts: stnTemperatureFailure.setStatus('current') stnChassisMibCompliances = MibIdentifier((1, 3, 6, 1, 4, 1, 3551, 2, 1, 2, 1)) stnChassisMibGroups = MibIdentifier((1, 3, 6, 1, 4, 1, 3551, 2, 1, 2, 2)) stnChassisMibComplianceRev1 = ModuleCompliance((1, 3, 6, 1, 4, 1, 3551, 2, 1, 2, 1, 1)).setObjects(("STN-CHASSIS-MIB", "stnChassisMibGroup")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): stnChassisMibComplianceRev1 = stnChassisMibComplianceRev1.setStatus('current') stnChassisMibGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 3551, 2, 1, 2, 2, 1)).setObjects(("STN-CHASSIS-MIB", "stnChassisSysType"), ("STN-CHASSIS-MIB", "stnChassisSysDescr"), ("STN-CHASSIS-MIB", "stnChassisId"), ("STN-CHASSIS-MIB", "stnSlotIndex"), ("STN-CHASSIS-MIB", "stnModuleType"), ("STN-CHASSIS-MIB", "stnModulePeer"), ("STN-CHASSIS-MIB", "stnModuleAdminStatus"), ("STN-CHASSIS-MIB", "stnModuleOperStatus"), ("STN-CHASSIS-MIB", "stnModuleDescr"), ("STN-CHASSIS-MIB", "stnModuleLed"), ("STN-CHASSIS-MIB", "stnSubModules"), ("STN-CHASSIS-MIB", "stnSubModuleSlot"), ("STN-CHASSIS-MIB", "stnSubModuleIndex"), ("STN-CHASSIS-MIB", "stnSubModuleType"), ("STN-CHASSIS-MIB", "stnSubModulePeer"), ("STN-CHASSIS-MIB", "stnSubModuleAdminStatus"), ("STN-CHASSIS-MIB", "stnSubModuleOperStatus"), ("STN-CHASSIS-MIB", "stnSubModuleDescr"), ("STN-CHASSIS-MIB", "stnEngineIndex"), ("STN-CHASSIS-MIB", "stnEngineSlot"), ("STN-CHASSIS-MIB", "stnEngineCpu"), ("STN-CHASSIS-MIB", "stnEngineType"), ("STN-CHASSIS-MIB", "stnEnginePeer"), ("STN-CHASSIS-MIB", "stnEngineAdminStatus"), ("STN-CHASSIS-MIB", "stnEngineOperStatus"), ("STN-CHASSIS-MIB", "stnEngineDescr"), ("STN-CHASSIS-MIB", "stnLedFanTray"), ("STN-CHASSIS-MIB", "stnLedPowerA"), ("STN-CHASSIS-MIB", "stnLedPowerB"), ("STN-CHASSIS-MIB", "stnLedAlarm"), ("STN-CHASSIS-MIB", "stnFanTrayLedIndex"), ("STN-CHASSIS-MIB", "stnFanTrayLedSlotIndex"), ("STN-CHASSIS-MIB", "stnFanTrayLedStatus"), ("STN-CHASSIS-MIB", "stnPortLedSlotIndex"), ("STN-CHASSIS-MIB", "stnPortLedPortIndex"), ("STN-CHASSIS-MIB", "stnPortLedIndex"), ("STN-CHASSIS-MIB", "stnPortLedStatus"), ("STN-CHASSIS-MIB", "stnPortLedDescr"), ("STN-CHASSIS-MIB", "stnPowerIndex"), ("STN-CHASSIS-MIB", "stnPowerStatus"), ("STN-CHASSIS-MIB", "stnPowerDescr"), ("STN-CHASSIS-MIB", "stnBatterySlotIndex"), ("STN-CHASSIS-MIB", "stnBatteryType"), ("STN-CHASSIS-MIB", "stnBatteryStatus"), ("STN-CHASSIS-MIB", "stnBatteryDescr")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): stnChassisMibGroup = stnChassisMibGroup.setStatus('current') mibBuilder.exportSymbols("STN-CHASSIS-MIB", stnBatteryTable=stnBatteryTable, stnCpuUtilizationEntry=stnCpuUtilizationEntry, stnSubModuleSlot=stnSubModuleSlot, stnCfgChange=stnCfgChange, stnFanTrayLedEntry=stnFanTrayLedEntry, stnPortLedTable=stnPortLedTable, stnChassis=stnChassis, stnPowerStatus=stnPowerStatus, stnPowerFailure=stnPowerFailure, stnLeds=stnLeds, stnBatteryStatus=stnBatteryStatus, stnSlotIndex=stnSlotIndex, stnNotRedundant=stnNotRedundant, stnChassisTrapVars=stnChassisTrapVars, stnSubModuleDescr=stnSubModuleDescr, stnNotificationCfgChangeTime=stnNotificationCfgChangeTime, stnEngineDescr=stnEngineDescr, stnCpuIpRoutingProcesses=stnCpuIpRoutingProcesses, stnBatterySlotIndex=stnBatterySlotIndex, stnChassisSysDescr=stnChassisSysDescr, stnSubModuleAdminStatus=stnSubModuleAdminStatus, stnChassisVars=stnChassisVars, stnSubModuleEntry=stnSubModuleEntry, stnFanTrayLedTable=stnFanTrayLedTable, stnCpuUtilization5Min=stnCpuUtilization5Min, stnSubModules=stnSubModules, stnPowerIndex=stnPowerIndex, stnChassisSysType=stnChassisSysType, stnCpuUtilization15Min=stnCpuUtilization15Min, stnResourceFailure=stnResourceFailure, stnCpuIpRouteLimit=stnCpuIpRouteLimit, stnCpuIpRoutesInUse=stnCpuIpRoutesInUse, stnSubModuleType=stnSubModuleType, stnLedFanTray=stnLedFanTray, stnResource=stnResource, stnChassisMibGroups=stnChassisMibGroups, stnEngineEntry=stnEngineEntry, stnPortLedDescr=stnPortLedDescr, stnEngineDown=stnEngineDown, stnFanTrayLedSlotIndex=stnFanTrayLedSlotIndex, stnChassisObjects=stnChassisObjects, stnModules=stnModules, stnCpuUtilization30Min=stnCpuUtilization30Min, stnSlotEntry=stnSlotEntry, stnFanTrayLedStatus=stnFanTrayLedStatus, stnBatteryDescr=stnBatteryDescr, stnSubModuleUp=stnSubModuleUp, stnSubModulePeer=stnSubModulePeer, stnPortLedEntry=stnPortLedEntry, PYSNMP_MODULE_ID=stnChassis, stnSubModuleDown=stnSubModuleDown, stnCpuIpRoutesBooked=stnCpuIpRoutesBooked, stnRedundant=stnRedundant, stnEngineAdminStatus=stnEngineAdminStatus, stnEngineTable=stnEngineTable, stnChassisMibConformance=stnChassisMibConformance, stnEngineSlot=stnEngineSlot, stnBatteryType=stnBatteryType, stnLedPowerB=stnLedPowerB, stnCpuIpFwdProcesses=stnCpuIpFwdProcesses, stnPortLedIndex=stnPortLedIndex, stnCpuUtilizationCurrent=stnCpuUtilizationCurrent, stnFlashFailure=stnFlashFailure, stnChassisMibComplianceRev1=stnChassisMibComplianceRev1, stnModuleLed=stnModuleLed, stnPortLedStatus=stnPortLedStatus, stnChassisId=stnChassisId, stnCpuIpIndex=stnCpuIpIndex, stnModuleUp=stnModuleUp, stnFailover=stnFailover, stnCpuIpTable=stnCpuIpTable, stnSubModuleOperStatus=stnSubModuleOperStatus, stnEngineCpu=stnEngineCpu, stnEngineOperStatus=stnEngineOperStatus, stnEnginePeer=stnEnginePeer, stnBatteryEntry=stnBatteryEntry, stnNotificationResourceStatus=stnNotificationResourceStatus, stnNotificationFlashStatus=stnNotificationFlashStatus, stnSlotTable=stnSlotTable, stnSubModuleIndex=stnSubModuleIndex, stnModuleAdminStatus=stnModuleAdminStatus, stnBatteryLow=stnBatteryLow, stnModuleType=stnModuleType, stnEngineIndex=stnEngineIndex, stnModuleDescr=stnModuleDescr, stnPowerDescr=stnPowerDescr, stnSubModuleTable=stnSubModuleTable, stnModuleOperStatus=stnModuleOperStatus, stnCpuUtilizationTable=stnCpuUtilizationTable, stnPortLedPortIndex=stnPortLedPortIndex, stnChassisMibCompliances=stnChassisMibCompliances, stnModulePeer=stnModulePeer, stnEngineUp=stnEngineUp, stnPowerEntry=stnPowerEntry, stnModuleDown=stnModuleDown, stnNotificationModuleTemperature=stnNotificationModuleTemperature, stnLedPowerA=stnLedPowerA, stnChassisMibGroup=stnChassisMibGroup, stnCpuIpEntry=stnCpuIpEntry, stnPortLedSlotIndex=stnPortLedSlotIndex, stnFanTrayLedIndex=stnFanTrayLedIndex, stnCpuUtilizationIndex=stnCpuUtilizationIndex, stnPowerTable=stnPowerTable, stnPower=stnPower, stnEngineType=stnEngineType, stnLedAlarm=stnLedAlarm, stnTemperatureFailure=stnTemperatureFailure)
# Python returning values def withdraw_money(current_bal, amount): if(current_bal >= amount): current_bal -= amount return current_bal balance = withdraw_money(100, 20) if (balance >= 50): print(f"The balance is {balance}.") else: print("You need to make a deposit.")
class Queue: """An implementation of the Queue data strucutre.""" def __init__(self): self._items = [] def __repr__(self): return "pyDS.queue.Queue({})".format(self._items) def __str__(self): return str(self._items) def __len__(self): return len(self._items) def is_empty(self): """Check queue is empty. Returns: True if Queue is empty, False otherwise. """ return self._items == [] def enqueue(self, item): """Add item to Queue. Args: item: The item to be inserted. """ self._items.append(item) def dequeue(self): """Remove item from queue. Returns: The first item from the Queue. Raises IndexError if Queue empty. """ if not self.is_empty(): return self._items.pop(0) else: raise IndexError("Queue is empty") def front(self): """Return the first Queue item. Returns: The first item from the Queue. Raises IndexError if Queue empty. """ if not self.is_empty(): return self._items[0] else: return IndexError("Queue is empty") def rear(self): """Return the last Queue item. Returns: The last item from the Queue. Raises IndexError if Queue empty. """ if not self.is_empty(): return self._items[-1] else: return IndexError("Queue is empty")
# -*- coding: utf-8 -*- """ Created on Fri Sep 16 09:31:26 2016 @author: andre # edX MITx 6.00.1x # Introduction to Computer Science and Programming Using Python # Problem Set 2, problem 3 # Use bisection search to make the program faster # The following variables contain values as described below: # balance - the outstanding balance on the credit card # annualInterestRate - annual interest rate as a decimal # Monthly interest rate = (Annual interest rate) / 12.0 # Monthly payment lower bound = Balance / 12 # Monthly payment upper bound = (Balance x (1 + Monthly interest rate)12) / 12.0 # Problem Summary: Use bisection search to search for the smallest monthly payment # to the cent such that we can pay off the entire balance within a year. """ # Test Cases, comment out before submitting for grading #Test Case 1 balance = 320000 annualInterestRate = 0.2 monthly_interest_rate = (annualInterestRate / 12.0) payment_lower = (balance / 12) payment_upper = (balance * ((1 + monthly_interest_rate)**12)) / 12.0 original_balance = balance while balance != 0.00: # Set value for thePayment to midpoint of lower and upper payment = (payment_lower + payment_upper) / 2 # Reset balance each time through while loop balance = original_balance for i in range(1,13): balance = (balance - payment) * (1 + monthly_interest_rate) if balance > 0: payment_lower = payment elif balance < 0: payment_upper = payment balance = round(balance, 2) print("Lowest Payment:", round(payment,2))
print('=' * 12 + 'Desafio 43' + '=' * 12) peso = float(input('Informe sua massa (em kg): ')) altura = float(input('Digite sua altura (em m): ')) imc = peso / (altura ** 2) print(f'IMC: {imc:.1f}') if imc < 18.5: print('Categoria: ABAIXO DO PESO') elif imc < 25.0: print('Categoria: PESO IDEAL') elif imc < 30.0: print('Categoria: SOBREPESO') elif imc < 40.0: print('Categoria: OBESIDADE') else: print('Categoria: OBESIDADE MÓRBIDA')
while True: n = int(input("Height: ")) width = n if n > 0 and n <= 8: break for num_of_hashes in range(1, n + 1): num_of_spaces = n - num_of_hashes print(" " * num_of_spaces, end="") print("#" * num_of_hashes, end="") print(" ", end="") print("#" * num_of_hashes)
class Events: # REPL to USER EVENTS INP = 'inp' OUT = 'out' ERR = 'err' HTML = 'html' EXC = 'exc' PONG = 'pong' PATH = 'path' DONE = 'ended' STARTED = 'started' FORKED = 'forked' # REPL <-> USER EVENTS NOINT = 'noint' # USER to REPL EVENTS WRT = 'wrt' RUN = 'run' PING = 'ping' FORK = 'fork' def encode(event, data=''): return event + ' ' + data.replace('\n', '\\n') def decode(message): msg = message.split(' ', 1) if len(msg) == 1: return msg[0].rstrip(), '' event, data = msg return event, data.replace('\\n', '\n')
def test(): # Here we can either check objects created in the solution code, or the # string value of the solution, available as __solution__. A helper for # printing formatted messages is available as __msg__. See the testTemplate # in the meta.json for details. # If an assertion fails, the message will be displayed assert "junk_drawer" in __solution__, "Make sure you are naming your object 'junk_drawer'" assert "drawer_length" in __solution__, "Make sure you are naming your object 'drawer_length'" assert "cleaned_junk_drawer" in __solution__, "Make sure you are naming your object 'cleaned_junk_drawer'" assert "junk_set" in __solution__, "Make sure you are naming your object 'junk_set'" assert len( set(junk_drawer).intersection({3, 4, 7.3, True, 'pen', 'scrap paper'}) ) == 6, "Some items are missing from 'junk_drawer'. Did you add everything?" assert drawer_length == 6, "The length of 'junk_drawer' is incorrect. Did you add everthing?" assert len( cleaned_junk_drawer ) == 3, "The length of 'cleaned_junk_drawer' is incorrect. Are you slicing properly?" assert len( set(junk_set).intersection({4, 'pen', 'scrap paper'}) ) == 3, "Some items are missing from 'junk_set'. Are you slicing properly?" __msg__.good("Nice work, well done!")
# Runtime Average-case: Theta(n^2) # Runtime Best-case (already sorted): O(n) # Runtime Worst-case (reserve sorted): Theta(n^2) # In Place: Yes # Stable: Yes def insertion_sort(a): for j in range(1, len(a)): key = a[j] # start with element before and keep going back i = j - 1 while i >= 0 and key < a[i]: # keep shifting the elements to the right a[i+1] = a[i] i = i - 1 # place the current element in the right place # we need to add i + 1 because when we break the loop it would be after an extra i - 1 a[i+1] = key a = [4,6,8,9,3,5,1] insertion_sort(a) print(a)
nums = list() for i in range(0, 5): nums.append(int(input(f'Digite o valor da posição {i}: '))) maior = max(nums) menor = (min(nums)) print('-=-'*15) print(f'Você digitou os valores {nums}') print(f'O maior valor digitado foi {maior} nas posições ', end='') for i, v in enumerate(nums): if v == maior: print(f'{i}... ', end='') print() print(f'O menor valor digitado foi {menor} nas posições ', end='') for i, v in enumerate(nums): if v == menor: print(f'{i}... ', end='') print()
#!/usr/bin/env python # -*- coding: utf-8 -*- """The module contains a collection of useful algorithms written in python.""" __author__ = 'Md. Imrul Hassan' __email__ = 'mihassan@gmail.com' __version__ = '0.2.1'
# Definition for a undirected graph node # class UndirectedGraphNode: # def __init__(self, x): # self.label = x # self.neighbors = [] class Solution: # @param node, a undirected graph node # @return a undirected graph node def cloneGraph(self, node): if not node: return None res = UndirectedGraphNode(node.label) seen = {node.label: res} self.helper(node, res, seen) return res def helper(self, node, answer, seen): seen[answer.label] = answer for i in node.neighbors: if i.label not in seen: nex = UndirectedGraphNode(i.label) answer.neighbors.append(nex) self.helper(i, nex, seen) else: answer.neighbors.append(seen[i.label])
squares = [1, 4, 9, 16, 25] print(squares) print(squares[0]) #Get first value; remember index offset print(squares[-1]) #Get last value in sequence print(squares[2:4]) #Return slice of list squares.append(54) #Add new value print(squares) squares[3] = 88 #Insert new value print(squares)
numeros=[[], []] valor = 0 for c in range(1,8): valor= int(input(f' Digite o {c}º valor: ')) if valor % 2 == 0: numeros[0].append(valor) if valor % 2 == 1: numeros[1].append(valor) print(numeros) numeros[0].sort() numeros[1].sort() print(f' Os valores pares digitados foram {numeros[0]}.') print(f' Os valores impares digitados foram {numeros[1]}.')
# ### Problem 3 # Given 2 lists of claim numbers, write the code to merge the 2 lists provided to produce a new list by alternating values between the 2 lists. Once the merge has been completed, print the new list of claim numbers (DO NOT just print the array variable!) # ``` # # Start with these lists # list_of_claim_nums_1 = [2, 4, 6, 8, 10] # list_of_claim_nums_2 = [1, 3, 5, 7, 9] # ``` # Example Output: # ``` # The newly created list contains: 2 1 4 3 6 5 8 7 10 9 # ``` # Starting variables nums1 = [2, 4, 6, 8, 10] nums2 = [1, 3, 5, 7, 9] numall=[] # adding to Array for x in range(0,len(nums1)): numall.append(nums1[x]) numall.append(nums2[x]) # Printing Array print(numall)
class OffsetMissingInIndex(Exception): pass class CouldNotFindOffset(Exception): pass class LogSizeExceeded(Exception): pass
# Copyright 2017 The Forseti Security Authors. All rights reserved. # # 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. """Test data for Service Management GCP api responses.""" FAKE_PROJECT_ID = "project1" LIST_CONSUMER_SERVICES_PAGE1 = """ { "services": [ { "serviceName": "bigquery-json.googleapis.com", "producerProjectId": "google.com:ultra-current-88221" }, { "serviceName": "cloudbilling.googleapis.com", "producerProjectId": "cloud-billing-api" }, { "serviceName": "apikeys.googleapis.com", "producerProjectId": "google.com:steel-binder-818" }, { "serviceName": "appengineflex.googleapis.com", "producerProjectId": "google.com:gae-api-prod" }, { "serviceName": "admin.googleapis.com", "producerProjectId": "google.com:api-project-73174915157" }, { "serviceName": "cloudapis.googleapis.com", "producerProjectId": "google.com:cloudapis-producer" } ], "nextPageToken": "123" } """ LIST_CONSUMER_SERVICES_PAGE2 = """ { "services": [ { "serviceName": "containerregistry.googleapis.com", "producerProjectId": "containerregistry" }, { "serviceName": "cloudtrace.googleapis.com", "producerProjectId": "cloud-trace-api-producer" }, { "serviceName": "container.googleapis.com", "producerProjectId": "google.com:cloud-kubernetes-devrel" }, { "serviceName": "containeranalysis.googleapis.com", "producerProjectId": "container-analysis" }, { "serviceName": "dataproc-control.googleapis.com", "producerProjectId": "cloud-dataproc-producer" }, { "serviceName": "clouddebugger.googleapis.com", "producerProjectId": "google.com:cloud-debugger-producer" }, { "serviceName": "compute.googleapis.com", "producerProjectId": "google.com:api-project-539346026206" }, { "serviceName": "cloudbuild.googleapis.com", "producerProjectId": "argo-api-producer" } ], "nextPageToken": "456" } """ LIST_CONSUMER_SERVICES_PAGE3 = """ { "services": [ { "serviceName": "deploymentmanager.googleapis.com", "producerProjectId": "google.com:api-project-596022999904" }, { "serviceName": "pubsub.googleapis.com", "producerProjectId": "cloud-pubsub-billing" }, { "serviceName": "dataproc.googleapis.com", "producerProjectId": "cloud-dataproc-producer" }, { "serviceName": "monitoring.googleapis.com", "producerProjectId": "google.com:gcm-api-admin" }, { "serviceName": "dns.googleapis.com", "producerProjectId": "cloud-dns-service-config" }, { "serviceName": "logging.googleapis.com", "producerProjectId": "metal-incline-93520" }, { "serviceName": "datastore.googleapis.com", "producerProjectId": "cloud-datastore-api" }, { "serviceName": "replicapool.googleapis.com", "producerProjectId": "google.com:api-project-861046436738" }, { "serviceName": "replicapoolupdater.googleapis.com", "producerProjectId": "google.com:prod-default-producer-project" }, { "serviceName": "iam.googleapis.com", "producerProjectId": "iam-whitelisting-project" } ], "nextPageToken": "789" } """ LIST_CONSUMER_SERVICES_PAGE4 = """ { "services": [ { "serviceName": "servicemanagement.googleapis.com", "producerProjectId": "google.com:steel-binder-818" }, { "serviceName": "storage-api.googleapis.com", "producerProjectId": "cloud-storage-producer" }, { "serviceName": "storage.googleapis.com", "producerProjectId": "cloud-storage-producer" }, { "serviceName": "resourceviews.googleapis.com", "producerProjectId": "google.com:prod-default-producer-project" }, { "serviceName": "sql-component.googleapis.com", "producerProjectId": "google.com:prod-default-producer-project" }, { "serviceName": "storage-component.googleapis.com", "producerProjectId": "google.com:prod-default-producer-project" } ] } """ LIST_CONSUMER_SERVICES_RESPONSES = [ LIST_CONSUMER_SERVICES_PAGE1, LIST_CONSUMER_SERVICES_PAGE2, LIST_CONSUMER_SERVICES_PAGE3, LIST_CONSUMER_SERVICES_PAGE4 ] EXPECTED_SERVICES_COUNT = 30 PERMISSION_DENIED = """ { "error": { "code": 403, "message": "Project 'project1' not found or permission denied.", "status": "PERMISSION_DENIED" } } """
print("Welcome to the F.A.T C.A.T program, this program encrypts messages using the reverse cipher method") #Prints whats in the parenteses sentence = input("What do you want to encrypt? ") #Declares a varible and stores what the user inputs final = "" i = len(sentence) -1 while(i != -1): final+= sentence[i]; i -= 1 print(final)
def sum_series(generator, n): return sum(generator(i) for i in range(n)) def series(generator, n): return [generator(i) for i in range(n)] def search_bordered_sum_series(generator_fabric, n, left_x, right_x, border, epsilon=0.01**5): left_y = sum_series(generator_fabric(left_x), n) right_y = sum_series(generator_fabric(right_x), n) if not (left_y < border < right_y): raise NotImplementedError while True: if right_y - left_y < epsilon: break if right_x - left_x < epsilon: break new_x = (left_x + right_x) / 2 new_y = sum_series(generator_fabric(new_x), n) if new_y < border: left_x = new_x left_y = new_y continue if border < new_y: right_x = new_x right_y = new_y continue raise NotImplementedError return series(generator_fabric(left_x), n) class ExponentialSeriesGenerator: __slots__ = ('base', 'left_x', 'right_x') def __init__(self, base, left_x=0, right_x=2**8): self.base = base self.left_x = left_x self.right_x = right_x def generator_fabric(self, k): def generator(i): return self.base * k ** i return generator def series(self, n, border): return search_bordered_sum_series(generator_fabric=self.generator_fabric, n=n, left_x=self.left_x, right_x=self.right_x, border=border) def time_series_to_values(time_series, start_speed, end_speed, rounder): total_time = sum(time_series) speed_delta = (end_speed - start_speed) / total_time values = [] prev_time = 0 prev_experience = 0 for time in time_series: next_time = prev_time + time next_experience = next_time * (start_speed + (start_speed + next_time * speed_delta)) / 2 values.append(next_experience - prev_experience) prev_time = next_time prev_experience = next_experience return [rounder(value) for value in values]
computation_config = { 'Variable': 'GV1', 'From': ['WB API'], 'files': ['GV1_WB.csv'], 'function': lambda df, var: df.groupby(['ISO']).transform(lambda x: x.rolling(5, 1).mean()),#.mean(axis=1), 'sub_variables': [ 'Adjusted net savings, including particulate emission damage (% of GNI)', ], 'Description': lambda var: f"{var[0]} 5 years rolling average " }
# DomirScire class Animal: def __init__(self, color, number_of_legs): self.species = self.__class__.__name__ self.color = color self.number_of_legs = number_of_legs def __repr__(self): return f'{self.color} {self.species}, {self.number_of_legs} legs' class Wolf(Animal): def __init__(self, color): super().__init__(color, 4) class Sheep(Animal): def __init__(self, color): super().__init__(color, 4) class Snake(Animal): def __init__(self, color): super().__init__(color, 0) class Parrot(Animal): def __init__(self, color): super().__init__(color, 2) if __name__ == "__main__": wolf = Wolf('Black') sheep = Sheep('White') snake = Snake('Brown') parrot = Parrot('Green') print(wolf) print(sheep) print(snake) print(parrot)
TRAIN = False USERS = { 'yuncam':'aBc1to3' }
##function 'return_list' goes here def return_list(the_string): new_list = [] the_string = the_string.replace(" ",",") the_string = the_string.split(",") if len(the_string) == 1: return the_string[0] else: for x in range(len(the_string)): new_list.append(the_string[x]) return new_list def main(): the_string = input("Enter the string: ") result = return_list(the_string) print(result) main()
""" [E] Given an array, find the average of all contiguous subarrays of size 'K 'in it. Array: [1, 3, 2, 6, -1, 4, 1, 8, 2], K=5 Output: [2.2, 2.8, 2.4, 3.6, 2.8] """ # Brute Force Approach: Time: O(n * k) space: O(1) def find_averages_of_subarrays(K, arr): result = [] for i in range(len(arr)-K+1): # find sum of next 'K' elements _sum = 0.0 for j in range(i, i+K): _sum += arr[j] result.append(_sum/K) # calculate average return result def main(): result = find_averages_of_subarrays(5, [1, 3, 2, 6, -1, 4, 1, 8, 2]) print("Averages of subarrays of size K: " + str(result)) main() # a better approach # Time: O(n) Space: O(1) def find_averages_of_subarrays(K, arr): result = [] windowSum, windowStart = 0.0, 0 for windowEnd in range(len(arr)): windowSum += arr[windowEnd] # add the next element # slide the window, we don't need to slide if we've not hit the required window size of 'k' if windowEnd >= K - 1: result.append(windowSum / K) # calculate the average windowSum -= arr[windowStart] # subtract the element going out windowStart += 1 # slide the window ahead return result def main(): result = find_averages_of_subarrays(5, [1, 3, 2, 6, -1, 4, 1, 8, 2]) print("Averages of subarrays of size K: " + str(result)) main()
# Maximum Vacation Days # Rules: # 1. You can only travel among N cities, represented by indexes from 0 to N-1. # Initially, you are in the city indexed 0 on Monday. # 2. The cities are connected by flights. The flights are represented as a N*N matrix (not necessary symmetrical), # called flights representing the airline status from the city i to the city j. # If there is no flight from the city i to the city j, flights[i][j] = 0; Otherwise, flights[i][j] = 1. # Also, flights[i][i] = 0 for all i. # 3. You totally have K weeks (each week has 7 days) to travel. # You can only take flights at most once per day and can only take flights on each week's Monday morning. # Since flight time is so short, we don't consider the impact of flight time. # 4. For each city, you can only have restricted vacation days in different weeks, given an N*K matrix called days representing this relationship. # For the value of days[i][j], it represents the maximum days you could take vacation in the city i in the week j. # You're given the flights matrix and days matrix, and you need to output the maximum vacation days you could take during K weeks. # # Note: # 1 <= N, K <= 100 # if you fly from the city A to the city B and take the vacation on that day, # the deduction towards vacation days will count towards the vacation days of city B in that week. # # Example: # flights = [[0,1,1],[1,0,1],[1,1,0]], days = [[1,3,1],[6,0,3],[3,3,3]] => 6 + 3 + 3 = 12 # flights = [[0,0,0],[0,0,0],[0,0,0]], days = [[1,1,1],[7,7,7],[7,7,7]] => 1 + 1 + 1 = 3 # flights = [[0,1,1],[1,0,1],[1,1,0]], days = [[7,0,0],[0,7,0],[0,0,7]] => 7 + 7 + 7 = 21 class Solution(object): def maxVacationDays(self, flights, days): """ dp[i][j]: max number of vacation days taken at the end of week j in city i dp[i][j] = -inf no flights to city i = days[i][0] j == 0 and flights[0][i] == 1 = max(dp[k][j - 1] + days[i][j]) j > 0, 0 <= k < N """ N, K = len(days), len(days[0]) dp = [[float('-inf')] * K for _ in range(N)] # haven't been able to reach yet max_days = 0 # base cases # mind that one can stay at the same city for the upcoming week for i in range(N): if i == 0 or flights[0][i] == 1: dp[i][0] = days[i][0] for j in range(1, K): for i in range(N): # dst city for k in range(N): # src city if k == i or flights[k][i] == 1: dp[i][j] = max(dp[i][j], dp[k][j - 1] + days[i][j]) max_days = max(max_days, dp[i][j]) return max_days # O(k * n^2) time, O(n^2) space (can be reduced to O(n)space)
class Option: OPTION_ENABLE = 256 OPTION_TX_ABORT = 1024 OPTION_HIGH_PRIORITY = 2048
#BFS or Breadth First Search is a traversal algorithm for a tree or graph, where we start from the root node(for a tree) #And visit all the nodes level by level from left to right. It requires us to keep track of the chiildren of each node we visit #In a queue, so that after traversal through a level is complete, our algorithm knows which node to visit next. #Time complexity is O(n) but the space complexity can become a problem in some cases. #To implement BFS, we'll need a Binary Search Tree, which we have already coded. So we'll use that. class Node(): def __init__(self, data): self.data = data self.left = None self.right = None class BST(): def __init__(self): self.root = None self.number_of_nodes = 0 #For the insert method, we check if the root node is None, then we make the root node point to the new node #Otherwise, we create a temporary pointer which points to the root node at first. #Then we compare the data of the new node to the data of the node pointed by the temporary node. #If it is greater then first we check if the right child of the temporary node exists, if it does, then we update the temporary node to its right child #Otherwise we make the new node the right child of the temporary node #And if the new node data is less than the temporary node data, we follow the same procedure as above this time with the left child. #The complexity is O(log N) in avg case and O(n) in worst case. def insert(self, data): new_node = Node(data) if self.root == None: self.root = new_node self.number_of_nodes += 1 return else: current_node = self.root while(current_node.left != new_node) and (current_node.right != new_node): if new_node.data > current_node.data: if current_node.right == None: current_node.right = new_node else: current_node = current_node.right elif new_node.data < current_node.data: if current_node.left == None: current_node.left = new_node else: current_node = current_node.left self.number_of_nodes += 1 return #Now we will implement the lookup method. #It will follow similar logic as to the insert method to reach the correct position. #Only instead of inserting a new node we will return "Found" if the node pointed by the temporary node contains the same value we are looking for def search(self,data): if self.root == None: return "Tree Is Empty" else: current_node = self.root while True: if current_node == None: return "Not Found" if current_node.data == data: return "Found" elif current_node.data > data: current_node = current_node.left elif current_node.data < data: current_node = current_node.right #Finally comes the very complicated remove method. #This one is too complicated for me to explain while writing. So I'll just write the code down with some comments #explaining which conditions are being checked def remove(self, data): if self.root == None: #Tree is empty return "Tree Is Empty" current_node = self.root parent_node = None while current_node!=None: #Traversing the tree to reach the desired node or the end of the tree if current_node.data > data: parent_node = current_node current_node = current_node.left elif current_node.data < data: parent_node = current_node current_node = current_node.right else: #Match is found. Different cases to be checked #Node has left child only if current_node.right == None: if parent_node == None: self.root = current_node.left return else: if parent_node.data > current_node.data: parent_node.left = current_node.left return else: parent_node.right = current_node.left return #Node has right child only elif current_node.left == None: if parent_node == None: self.root = current_node.right return else: if parent_node.data > current_node.data: parent_node.left = current_node.right return else: parent_node.right = current_node.left return #Node has neither left nor right child elif current_node.left == None and current_node.right == None: if parent_node == None: #Node to be deleted is root current_node = None return if parent_node.data > current_node.data: parent_node.left = None return else: parent_node.right = None return #Node has both left and right child elif current_node.left != None and current_node.right != None: del_node = current_node.right del_node_parent = current_node.right while del_node.left != None: #Loop to reach the leftmost node of the right subtree of the current node del_node_parent = del_node del_node = del_node.left current_node.data = del_node.data #The value to be replaced is copied if del_node == del_node_parent: #If the node to be deleted is the exact right child of the current node current_node.right = del_node.right return if del_node.right == None: #If the leftmost node of the right subtree of the current node has no right subtree del_node_parent.left = None return else: #If it has a right subtree, we simply link it to the parent of the del_node del_node_parent.left = del_node.right return return "Not Found" #Now we implement the BFS method. def BFS(self): current_node = self.root #We start with the root node BFS_result = [] #This will store the result of the BFS queue = [] #Queue to keep track of the children of each node queue.append(current_node) #We add the root to the queue first while len(queue) > 0: current_node = queue.pop(0) #We extract the first element of the queue and make it the current node BFS_result.append(current_node.data) #We push the data of the current node to the result list as we are currently visiting the current node if current_node.left: #If left child of the current node exists, we append it to the queue queue.append(current_node.left) if current_node.right: #Similarly, if right child exists, we append it to the queue queue.append(current_node.right) return BFS_result #Finally, we will implement the Recursive version of the BFS. def Recursive_BFS(self, queue, BFS_list): if len(queue) == 0: return BFS_list current_node = queue.pop(0) BFS_list.append(current_node.data) if current_node.left: queue.append(current_node.left) if current_node.right: queue.append(current_node.right) return self.Recursive_BFS(queue, BFS_list) my_bst = BST() my_bst.insert(5) my_bst.insert(3) my_bst.insert(7) my_bst.insert(1) my_bst.insert(13) my_bst.insert(65) my_bst.insert(0) my_bst.insert(10) ''' 5 3 7 1 13 0 10 65 ''' #The BFS Traversal for this tree should be : [5,3,7,1,13,0,10,65] print(my_bst.BFS()) #[5, 3, 7, 1, 13, 0, 10, 65] print(my_bst.Recursive_BFS([my_bst.root],[])) #We need to pass the root node as an array and an empty array for the result #[5, 3, 7, 1, 13, 0, 10, 65]
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def getTargetCopy(self, original: TreeNode, cloned: TreeNode, target: TreeNode) -> TreeNode: curr_level = [cloned] while curr_level: next_level = [] for node in curr_level: if node.val == target.val: return node if node.left: next_level.append(node.left) if node.right: next_level.append(node.right) curr_level = next_level return None
def add(x, y): """add two numbers""" return x + y def subtract(x, y): """subtrct one number from another""" return y - x def mult(x, y): """multiply two numbers""" return x * y
# Demo Python Tuples ''' Create Tuple With One Item To create a tuple with only one item, you have add a comma after the item, unless Python will not recognize the variable as a tuple. ''' # One item tuple, remember the commma: thistuple = ("apple",) print(type(thistuple)) #NOT a tuple thistuple = ("apple") print(type(thistuple))
# Copyright 2017 The LUCI Authors. All rights reserved. # Use of this source code is governed under the Apache License, Version 2.0 # that can be found in the LICENSE file. DEPS = [ 'properties', 'step', 'url', ] def RunSteps(api): api.url.validate_url(api.properties['url_to_validate']) def GenTests(api): yield (api.test('basic') + api.properties(url_to_validate='https://example.com')) yield (api.test('no_scheme') + api.properties(url_to_validate='example.com') + api.expect_exception('ValueError')) yield (api.test('invalid_scheme') + api.properties(url_to_validate='ftp://example.com') + api.expect_exception('ValueError')) yield (api.test('no_host') + api.properties(url_to_validate='https://') + api.expect_exception('ValueError'))
lista = () lista1 = list() tuplas = [] tuplas1 = tuple() dicionario = {} dicionario1 = dict() dados = {'nome': 'Pedro', 'idade': 25} print(dados['nome']) print(dados['idade']) print(f'O {dados["nome"]} tem {dados["idade"]} anos') dados['nome'] = 'Leandro' #altera o elemento print(dados) dados['sexo'] = 'M' #adiciona o elemento print(dados) del dados['idade'] print(dados) print() filme = {'titulo': 'Star Wars', 'ano': 1977, 'diretor': 'George Lucas' } print(filme) print(filme.values()) #mostra os valores dos dados print(filme.keys()) #mostra o titulo dos dados print(filme.items()) #mostra o titulo e os valores print() for k in filme.keys(): print(f'As chaves são {k}') print() for v in filme.values(): print(f'Os valores são {v}') print() for k, v in filme.items(): print(f'O {k} é {v}') print() print('dicionario dentro de listaaaaaaaa') brasil = [] estado1 = {'uf': 'Rio de Janeiro', 'sigla': 'RJ'} estado2 = {'uf': 'São Paulo', 'sigla': 'SP'} brasil.append(estado1) brasil.append(estado2) print(brasil) print(brasil[0]) print(brasil[0]['uf']) estado = dict() pais = list() for c in range(0, 3): estado['uf'] = str(input('Unidade Federativa: ')) estado['sigla'] = str(input('Sigla: ')) pais.append(estado.copy()) print() for e in pais: print(f'O estado é {e}') print() for e in pais: for v in e.values(): print(f'{v}', end=' ') print() print() for e in pais: for keys, values in e.items(): print(f'O campo {keys} tem valor {values}')
''' @Date : 2017-12-07 11:18 @Author: yangyang Deng @Email : yangydeng@163.com @Describe: 将使用在 align 中的参数封装到一个类里。 ''' class argvs: # 输入图片的位置 image_path = '' output_dir = '' # 人名 class_name = 'dyy' image_size = 182 margin = 44 gpu_memory_fraction = 1 detect_multiple_faces = False random_order = False
class Option(object): """A Class implementing some sort of field interface""" def __init__(self, name, label, type, description=None, category='general', required=False, choices=None, default=None, field_options=None): kwargs = locals() kwargs.pop('self') for attr, value in kwargs.items(): setattr(self, attr, value)
#!/usr/bin/env python def plain_merge(array_a: list, array_b: list) -> list: pointer_a, pointer_b = 0, 0 length_a, length_b = len(array_a), len(array_b) result = [] while pointer_a < length_a and pointer_b < length_b: if array_a[pointer_a] <= array_b[pointer_b]: result.append(array_a[pointer_a]) pointer_a += 1 else: result.append(array_b[pointer_b]) pointer_b += 1 if pointer_a != length_a: result += array_a[pointer_a:] elif pointer_b != length_b: result += array_b[pointer_b:] return result
sexo = str(input('Digite o sexo [M/F]: ')).strip().upper()[0] while sexo.upper() not in 'MF': sexo = str(input('Valor inválido. Digite novamente: ')).upper() print('sexo {} registrado com sucesso.'.format(sexo))
# does this even work? class InvalidToken(Exception, object): """Raise an invalid token """ def __init__(self, message, payload): super(InvalidToken, self).__init__(message, payload) self.message = message self.payload = payload
""" Stat objects make life a little easier """ class CoreStat(): """ Core stats are what go up and down to modify the character """ def __init__(self, points=0): points = int(points) if points < 0: points = 0 self._points = points self._current = self.base self._derived = DerivedStat(self.base) @property def base(self): """ Force use of setter/getter """ return self._points + 1 @property def current(self): """ current getter """ return self._current @current.setter def current(self, value): """ current setter """ self._current = value if self._current < 0: self._current = 0 @property def derived(self): """ Grab the derived stat """ return self._derived def set_derived(self, factor, offset): """ Set's the multiplication factor for the derived stat """ self.derived._base = self.base new_factor = self._derived.factor = factor new_offset = self._derived.offset = offset self.derived.restore() return new_factor, new_offset def upgrade(self, points=1): """ Increases the core stat by upgrading it """ points = int(points) if points < 1: points = 1 # Update the core stat self._points += points self.restore() # Update the derived stat self.derived._base = self.base self.derived.restore() return True def restart(self): """ Removes all upgrades on this stat """ old_points = self._points # Update the core stat self._points = 0 self.restore() # Update the derived stat self.derived._base = self.base self.derived.restore() # Return what was removed for keeping track of stat restarts return old_points def restore(self): """ Restores the current value back to baseline """ self.current = self._points + 1 def __getstate__(self): """ Serialize core stat """ return { "points": self._points, "derived_factor": self._derived.factor, "derived_offset": self._derived.offset } def __setstate__(self, state): """ Deserialize core stat """ # Update the core stat self._points = state["points"] self.restore() # Update the derived stat factor = state["derived_factor"] offset = state["derived_offset"] self.set_derived(factor, offset) self.derived.restore() class DerivedStat(): """ Derived stats are based off core stats, and change when their core changes """ def __init__(self, base, factor=1.0, offset=0): self._factor = factor self._offset = offset self._base = base self._current = self.base @property def base(self): """ Programmatically calculates the base value """ return (self._base * self._factor) + self._offset @property def current(self): """ Update than grab the current value """ return self._current @current.setter def current(self, value): """ Sets the current value """ self._current = int(value) if self._current < 0: self._current = 0 @property def factor(self): """ Get the multiplication factor """ return self._factor @factor.setter def factor(self, value): """ Set the multiplication factor """ value = int(value) if value < 1: value = 1 self._factor = value return value @property def offset(self): """ Get the offset """ return self._offset @offset.setter def offset(self, value): """ Set the addition offset """ value = int(value) if value < 0: value = 0 self._offset = value return value def restore(self): """ Restores the current value back to the given amount """ self._current = self.base
""" weather.exceptions ------------------ Exceptions for weather django app """ class CityDoesNotExistsException(Exception): def __init__(self, message: str = None, *args, **kwargs): if message is None: message = "The queried city object doesn exists" Exception.__init__(self, message, *args, **kwargs) class APIRequestException(Exception): def __init__(self, message: str = None, *args, **kwargs): if message is None: message = "The call to the API didn't return 200" Exception.__init__(self, message, *args, **kwargs)
x={"a","b","c"} y=(1,2,3) z=[4,5,2] print(type(x)); print(type(y)); print(type(z)); x.add("d") print(x) z.append(5) print(y) print(z) for i in x: print (i) if 5 in z: print("yes") x.remove("b") print(x) z.remove(4) print(z) z.insert(1,7) print(z) z.extend(y) print(z) print(z.count(2)) del y print(y)
#mostra o valor de uma compra em uma loja de acordo com a quantidade de itens print("Lojas quase dois Tabela de preços") for x in range(1,51): valor=x*1.99 print(str(x)+" Itens = R$ "+str(valor))
'''The Caesar cipher is a type of substitution cipher in which each alphabet in the plaintext or messages is shifted by a number of places down the alphabet. For example,with a shift of 1, P would be replaced by Q, Q would become R, and so on. To pass an encrypted message from one person to another, it is first necessary that both parties have the ‘Key’ for the cipher, so that the sender may encrypt and the receiver may decrypt it. Key is the number of OFFSET to shift the cipher alphabet. Key can have basic shifts from 1 to 25 positions as there are 26 total alphabets. As we are designing custom Caesar Cipher, in addition to alphabets, we are considering numeric digits from 0 to 9. Digits can also be shifted by key places. For Example, if a given plain text contains any digit with values 5 and keyy =2, then 5 will be replaced by 7, “-”(minus sign) will remain as it is. Key value less than 0 should result into “INVALID INPUT” Example 1: Enter your PlainText: All the best Enter the Key: 1 The encrypted Text is: Bmm uif Cftu Write a function CustomCaesarCipher(int key, String message) which will accept plaintext and key as input parameters and returns its cipher text as output.''' def CustomCaesarCipher(key, message): l = list(message) #converted string to list for iteration result = "" #string to store final encrypted message # Two lists created one for iterating numbers and second for alphabets numbers = [0,1,2,3,4,5,6,7,8,9] alphabets = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"] #Loop through each character for i in range(0,len(l)): #First case:If string contains numbers if l[i].isdigit(): temp = int(l[i]) + key result += str(numbers[temp]) #Second case:If string contains alphabets elif l[i].isalpha(): #Two cases for alphabets: Capital letters and small letters if l[i].isupper(): l[i] = l[i].lower() #because we only have lowercase alphabets in our list temp = int(alphabets.index(l[i])) + key result += alphabets[temp].upper() else: temp = int(alphabets.index(l[i])) + key result += alphabets[temp] #Third case:If string contains characters other than alphabets and numbers else: result += l[i] print(result) #driver code msg = input("Enter your Plain Text: ") key = int(input("Enter the Key: ")) if key<0: print("INVALID INPUT") else: CustomCaesarCipher(key,msg)
first = ord('A') last = ord('Z') for i in range(first, last + 1): for j in range(last, first - 1, -1): if j <= i: print(chr(i), end=' ') else: print('', end=' ') print()
coordinates_01EE00 = ((123, 116), (123, 124), (123, 127), (123, 128), (123, 136), (123, 137), (124, 115), (124, 117), (124, 119), (124, 120), (124, 121), (124, 122), (124, 130), (124, 134), (124, 135), (124, 138), (125, 114), (125, 116), (125, 124), (125, 125), (125, 126), (125, 127), (125, 128), (125, 131), (125, 132), (125, 136), (125, 138), (126, 114), (126, 116), (126, 117), (126, 118), (126, 119), (126, 120), (126, 121), (126, 122), (126, 123), (126, 124), (126, 125), (126, 126), (126, 127), (126, 128), (126, 129), (126, 130), (126, 133), (126, 134), (126, 135), (126, 137), (127, 115), (127, 117), (127, 118), (127, 119), (127, 120), (127, 121), (127, 122), (127, 123), (127, 124), (127, 125), (127, 126), (127, 127), (127, 128), (127, 129), (127, 130), (127, 131), (127, 132), (127, 133), (127, 134), (127, 135), (127, 137), (128, 115), (128, 117), (128, 118), (128, 119), (128, 120), (128, 121), (128, 122), (128, 123), (128, 124), (128, 125), (128, 126), (128, 127), (128, 128), (128, 129), (128, 130), (128, 131), (128, 132), (128, 133), (128, 134), (128, 136), (129, 115), (129, 117), (129, 118), (129, 119), (129, 120), (129, 121), (129, 122), (129, 123), (129, 124), (129, 125), (129, 126), (129, 127), (129, 128), (129, 129), (129, 130), (129, 131), (129, 132), (129, 133), (129, 134), (129, 136), (130, 115), (130, 117), (130, 118), (130, 119), (130, 120), (130, 121), (130, 122), (130, 123), (130, 124), (130, 125), (130, 126), (130, 127), (130, 128), (130, 129), (130, 130), (130, 131), (130, 132), (130, 133), (130, 135), (131, 116), (131, 118), (131, 119), (131, 120), (131, 121), (131, 122), (131, 123), (131, 124), (131, 125), (131, 126), (131, 127), (131, 128), (131, 129), (131, 130), (131, 131), (131, 132), (131, 134), (132, 117), (132, 119), (132, 120), (132, 121), (132, 122), (132, 123), (132, 124), (132, 125), (132, 126), (132, 127), (132, 128), (132, 129), (132, 130), (132, 131), (132, 133), (133, 118), (133, 120), (133, 121), (133, 122), (133, 123), (133, 124), (133, 125), (133, 126), (133, 127), (133, 128), (133, 129), (133, 130), (133, 132), (134, 119), (134, 121), (134, 122), (134, 123), (134, 126), (134, 127), (134, 128), (134, 129), (134, 131), (135, 120), (135, 122), (135, 123), (135, 125), (135, 126), (135, 127), (135, 128), (135, 130), (136, 120), (136, 123), (136, 126), (136, 129), (137, 119), (137, 121), (137, 123), (137, 126), (137, 128), (138, 119), (138, 122), (138, 126), (138, 128), (139, 119), (139, 122), (139, 126), (140, 120), (140, 122), (140, 126), (140, 127), ) coordinates_00EE00 = ((107, 122), (108, 122), (108, 124), (109, 122), (109, 125), (110, 114), (110, 122), (110, 124), (110, 126), (111, 113), (111, 122), (111, 124), (111, 125), (111, 127), (112, 112), (112, 115), (112, 123), (112, 127), (113, 112), (113, 114), (113, 118), (113, 124), (113, 127), (114, 118), (115, 116), (115, 117), ) coordinates_E0E1E1 = ()
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Oct 19 17:46:22 2021 @author: rezanmoustafa """ # Endret fra 8b til 9 class Sporsmaal: def __init__(self, sporsmaal, svar, valg=[]): self.sporsmaal=sporsmaal self.svar=svar self.valg=valg def HentSporsmaal(self): print(self.sporsmaal) for i in range(len(self.valg)): print(i, self.valg[i]) # Deloppgave 9e) def korrekt_svar_tekst(self): return self.valg[self.svar] # Deloppgave 9d) def les_filen(sporsmaalsfil): sporsmaalene = [] file = open('sporsmaalsfil.txt','r') for line in file: line = line.strip().split(':') sporsmaal = line[0]; svar = int(line[1]) lst = [] for val in line[2].split(","): lst.append(val) sporsmaalene.append(Sporsmaal(sporsmaal,svar,lst)) file.close() return sporsmaalene # Deloppgave 9f) if __name__=="__main__": sporsmaalene = les_filen("sporsmaalsfil.txt") spiller1Score = 0 spiller2Score = 0 for i in range(len(sporsmaalene)): sporsmaalene[i].HentSporsmaal() spiller1 = int(input('\nSpiller 1: ')) spiller2 = int(input('Spiller 2: ')) print("\nRiktig svar: ",sporsmaalene[i].korrekt_svar_tekst()) if spiller1 == sporsmaalene[i].svar: spiller1Score += 1 if spiller2 == sporsmaalene[i].svar: spiller2Score += 1 print() print("\nSpiller 1 har ",spiller1Score,' av ',len(sporsmaalene)) print("Spiller 2 har ",spiller2Score,' av ',len(sporsmaalene)) if spiller1Score > spiller2Score: print("\nSpiller 1 er vinneren!!!") elif spiller2Score > spiller1Score: print("\nSpiller 2 er vinneren!!!") else: print("\nDet ble uavgjort!!!")
# -*- coding: utf-8 -*- Consent_form_Out = { # From Operator_CR to UI "source": { "service_id": "String", "rs_id": "String", "dataset": [ { "dataset_id": "String", "title": "String", "description": "String", "keyword": [], "publisher": "String", "distribution": { "distribution_id": "String", "access_url": "String" }, "component_specification_label": "String", "selected": True } ] }, "sink": { "service_id": "String", "dataset": [ { "datase_id": "String", "title": "String", "description": "String", "keyword": [], "publisher": "String", "purposes": [ { "title": "All your cats are belong to us", "selected": True, "required": True }, { "title": "Something random", "selected": True, "required": True } ] } ] } }
class Ionic: """Ionic radius class. Stores: charge, spin, coordination""" def __init__(self, charge=0, coordination="", radius=0.0): self.charge = charge self.coordination = coordination self.radius = radius def set_radius(self, value: float): self.radius = value class Atom_Data: """Atom data class. Stores Radius: covalent; Color: tuple, RGBA values""" def __init__(self, radius: float, vanDerWaals=0.00, color=(0.5,0.5,0.5, 1), ionicData=[Ionic()]): # Gray is the default color if none is specified self.radius = radius #covalent radius self.vanDerWaals = vanDerWaals #default is set temprarilly as 0.00 is radius is not reported self.color = color #RGBA values: default is gray self.ionicData = ionicData def get_radius(self): """ returns: <float> atom's covalent radius """ return self.radius def get_color(self): """ returns: <tuple size 4> rgba values for color """ return self.color def get_vanDerWaals(self): """ returns: vanDerWaals radius for element. """ return self.vanDerWaals def get_ionicData(self): return self.ionicData IonicRadii = { #element symbols, their covalent radii & their RGBA color values "Ac": [Ionic(3,"VI",1.12)], "Al": [Ionic(3,"IV",0.39),Ionic(3,"V",0.48),Ionic(3,"VI",0.535)], "Am": [Ionic(2,"VII",1.21),Ionic(2,"VIII",1.26),Ionic(2,"IX",1.31),Ionic(3,"VI",0.975),Ionic(3,"VIII",1.09), Ionic(4,"VI",0.85),Ionic(4,"VIII",0.95)], "Sb": [Ionic(3,"IVPY",0.76),Ionic(3,"V",0.8),Ionic(3,"VI",0.76),Ionic(5,"VI",0.6)], "Ar": [Ionic()], "As": [Ionic(3,"VI",0.58),Ionic(5,"IV",0.335),Ionic(5,"VI",0.46)], "At": [Ionic(7,"VI",0.62)], "Ba": [Ionic(2,"VI",1.35),Ionic(2,"VII",1.38),Ionic(2,"VIII",1.42),Ionic(2,"IX",1.47),Ionic(2,"X",1.52),Ionic(2,"XI",1.57), Ionic(2,"XII",1.61)], "Bk": [Ionic(3,"VI",0.96),Ionic(4,"VI",0.83),Ionic(4,"VIII",0.93)], "Be": [Ionic(2,"III",0.16),Ionic(2,"IV",0.27),Ionic(2,"VI",0.45)], "Bi": [Ionic(3,"V",0.96),Ionic(3,"VI",1.03),Ionic(3,"VIII",1.17),Ionic(5,"VI",0.76)], "Bh": [Ionic()], "B": [Ionic(3,"III",0.01),Ionic(3,"IV",0.11),Ionic(3,"VI",0.27)], "Br": [Ionic(-1,"VI",1.96),Ionic(3,"IVSQ",0.59),Ionic(5,"IIIPY",0.31),Ionic(7,"IV",0.25),Ionic(7,"VI",0.39)], "Cd": [Ionic(2,"IV",0.78),Ionic(2,"V",0.87),Ionic(2,"VI",0.95),Ionic(2,"VII",1.03),Ionic(2,"VIII",1.1),Ionic(2,"XII",1.31)], "Ca": [Ionic(2,"VI",1),Ionic(2,"VII",1.06),Ionic(2,"VIII",1.12),Ionic(2,"IX",1.18),Ionic(2,"X",1.23),Ionic(2,"XII",1.34)], "Cf": [Ionic(3,"VI",0.95),Ionic(4,"VI",0.821),Ionic(4,"VIII",0.92)], "C": [Ionic(4,"III",0.08),Ionic(4,"IV",0.15),Ionic(4,"VI",0.16)], "Ce": [Ionic(3,"VI",1.01),Ionic(3,"VII",1.07),Ionic(3,"VIII",1.143),Ionic(3,"IX",1.196),Ionic(3,"X",1.25),Ionic(3,"XII",1.34), Ionic(4,"VI",0.87),Ionic(4,"VIII",0.97),Ionic(4,"X",1.07),Ionic(4,"XII",1.14)], "Cs": [Ionic(1,"VI",1.67),Ionic(1,"VIII",1.74),Ionic(1,"IX",1.78),Ionic(1,"X",1.81),Ionic(1,"XI",1.85),Ionic(1,"XII",1.88)], "Cl": [Ionic(-1,"VI",1.81),Ionic(5,"IIIPY",0.12),Ionic(7,"IV",0.08),Ionic(7,"VI",0.27)], "Cr": [Ionic(2,"VI-ls",0.73),Ionic(2,"0-hs",0.8),Ionic(3,"VI",0.615),Ionic(4,"IV",0.41),Ionic(4,"VI",0.55), Ionic(5,"IV",0.345),Ionic(5,"VI",0.49),Ionic(5,"VIII",0.57),Ionic(6,"IV",0.26),Ionic(6,"VI",0.44)], "Co": [Ionic(2,"IV-hs",0.58),Ionic(2,"V",0.67),Ionic(2,"VI-ls",0.65),Ionic(2,"0-hs",0.745),Ionic(2,"VIII",0.9), Ionic(3,"VI-ls",0.545),Ionic(3,"0-hs",0.61),Ionic(4,"IV",0.4),Ionic(4,"VI-hs",0.53)], "Cn": [Ionic()], "Cu": [Ionic(1,"II",0.46),Ionic(1,"IV",0.6),Ionic(1,"VI",0.77),Ionic(2,"IV",0.57),Ionic(2,"IVSQ",0.57),Ionic(2,"V",0.65), Ionic(2,"VI",0.73),Ionic(3,"VI-ls",0.54)], "Cm": [Ionic(3,"VI",0.97),Ionic(4,"VI",0.85),Ionic(4,"VIII",0.95)], "Ds": [Ionic()], "Db": [Ionic()], "Dy": [Ionic(2,"VI",1.07),Ionic(2,"VII",1.13),Ionic(2,"VIII",1.19),Ionic(3,"VI",0.912),Ionic(3,"VII",0.97),Ionic(3,"VIII",1.027), Ionic(3,"IX",1.083)], "Es": [Ionic()], "Er": [Ionic(3,"VI",0.89),Ionic(3,"VII",0.945),Ionic(3,"VIII",1.004),Ionic(3,"IX",1.062)], "Eu": [Ionic(2,"VI",1.17),Ionic(2,"VII",1.2),Ionic(2,"VIII",1.25),Ionic(2,"IX",1.3),Ionic(2,"X",1.35),Ionic(3,"VI",0.947), Ionic(3,"VII",1.01),Ionic(3,"VIII",1.066),Ionic(3,"IX",1.12)], "Fm": [Ionic()], "Fl": [Ionic()], "F": [Ionic(-1,"II",1.285),Ionic(-1,"III",1.3),Ionic(-1,"IV",1.31),Ionic(-1,"VI",1.33),Ionic(7,"VI",0.08)], "Fr": [Ionic(1,"VI",1.8)], "Gd": [Ionic(3,"VI",0.938),Ionic(3,"VII",1),Ionic(3,"VIII",1.053),Ionic(3,"IX",1.107)], "Ga": [Ionic(3,"IV",0.47),Ionic(3,"V",0.55),Ionic(3,"VI",0.62)], "Ge": [Ionic(2,"VI",0.73),Ionic(4,"IV",0.39),Ionic(4,"VI",0.53)], "Au": [Ionic(1,"VI",1.37),Ionic(3,"IVSQ",0.68),Ionic(3,"VI",0.85),Ionic(5,"VI",0.57)], "Hf": [Ionic(4,"IV",0.58),Ionic(4,"VI",0.71),Ionic(4,"VII",0.76),Ionic(4,"VIII",0.83)], "Hs": [Ionic()], "He": [Ionic()], "Ho": [Ionic(3,"VI",0.901),Ionic(3,"VIII",1.015),Ionic(3,"IX",1.072),Ionic(3,"X",1.12)], "H": [Ionic(1,"I",0.38),Ionic(1,"II",0.18)], "In": [Ionic(3,"IV",0.62),Ionic(3,"VI",0.8),Ionic(3,"VIII",0.92)], "I": [Ionic(-1,"VI",2.2),Ionic(5,"IIIPY",0.44),Ionic(5,"VI",0.95),Ionic(7,"IV",0.42),Ionic(7,"VI",0.53)], "Ir": [Ionic(3,"VI",0.68),Ionic(4,"VI",0.625),Ionic(5,"VI",0.57)], "Fe": [Ionic(2,"IV-hs",0.63),Ionic(2,"IVSQ-hs",0.64),Ionic(2,"VI-ls",0.61),Ionic(2,"0-hs",0.78), Ionic(2,"VIII-hs",0.92),Ionic(3,"IV-hs",0.49),Ionic(3,"V",0.58),Ionic(3,"VI-ls",0.55), Ionic(3,"0-hs",0.645),Ionic(3,"VIII-hs",0.78),Ionic(4,"VI",0.585),Ionic(6,"IV",0.25)], "Kr": [Ionic()], "La": [Ionic(3,"VI",1.032),Ionic(3,"VII",1.1),Ionic(3,"VIII",1.16),Ionic(3,"IX",1.216),Ionic(3,"X",1.27),Ionic(3,"XII",1.36)], "Lr": [Ionic()], "Pb": [Ionic(2,"IVPY",0.98),Ionic(2,"VI",1.19),Ionic(2,"VII",1.23),Ionic(2,"VIII",1.29),Ionic(2,"IX",1.35), Ionic(2,"X",1.4),Ionic(2,"XI",1.45),Ionic(2,"XII",1.49),Ionic(4,"IV",0.65),Ionic(4,"V",0.73),Ionic(4,"VI",0.775), Ionic(4,"VIII",0.94)], "Li": [Ionic(1,"IV",0.59),Ionic(1,"VI",0.76),Ionic(1,"VIII",0.92)], "Lv": [Ionic()], "Lu": [Ionic(3,"VI",0.861),Ionic(3,"VIII",0.977),Ionic(3,"IX",1.032)], "Mg": [Ionic(2,"IV",0.57),Ionic(2,"V",0.66),Ionic(2,"VI",0.72),Ionic(2,"VIII",0.89)], "Mn": [Ionic(2,"IV-hs",0.66),Ionic(2,"V-hs",0.75),Ionic(2,"VI-hs",0.83),Ionic(2,"0-ls",0.67), Ionic(2,"VII-hs",0.9),Ionic(2,"VIII",0.96),Ionic(3,"V",0.58),Ionic(3,"VI-ls",0.58),Ionic(3,"0-hs",0.645), Ionic(4,"IV",0.39),Ionic(4,"VI",0.53),Ionic(5,"IV",0.33),Ionic(6,"IV",0.255),Ionic(7,"IV",0.25),Ionic(7,"VI",0.46)], "Mt": [Ionic()], "Md": [Ionic()], "Hg": [Ionic(1,"III",0.97),Ionic(1,"VI",1.19),Ionic(2,"II",0.69),Ionic(2,"IV",0.96),Ionic(2,"VI",1.02),Ionic(2,"VIII",1.14)], "Mo": [Ionic(3,"VI",0.69),Ionic(4,"VI",0.65),Ionic(5,"IV",0.46),Ionic(5,"VI",0.61),Ionic(6,"IV",0.41),Ionic(6,"V",0.5), Ionic(6,"VI",0.59),Ionic(6,"VII",0.73)], "Mc": [Ionic()], "Nd": [Ionic(2,"VIII",1.29),Ionic(2,"IX",1.35),Ionic(3,"VI",0.983),Ionic(3,"VIII",1.109),Ionic(3,"IX",1.163),Ionic(3,"XII",1.27)], "Ne": [Ionic()], "Np": [Ionic(2,"VI",1.1),Ionic(3,"VI",1.01),Ionic(4,"VI",0.87),Ionic(4,"VIII",0.98),Ionic(5,"VI",0.75), Ionic(6,"VI",0.72),Ionic(7,"VI",0.71)], "Ni": [Ionic(2,"IV",0.55),Ionic(2,"IVSQ",0.49),Ionic(2,"V",0.63),Ionic(2,"VI",0.69),Ionic(3,"VI-ls",0.56), Ionic(3,"0-hs",0.6),Ionic(4,"VI-ls",0.48)], "Nh": [Ionic()], "Nb": [Ionic(3,"VI",0.72),Ionic(4,"VI",0.68),Ionic(4,"VIII",0.79),Ionic(5,"IV",0.48),Ionic(5,"VI",0.64), Ionic(5,"VII",0.69),Ionic(5,"VIII",0.74)], "N": [Ionic(-3,"IV",1.46),Ionic(3,"VI",0.16),Ionic(5,"III",0.104),Ionic(5,"VI",0.13)], "No": [Ionic(2,"VI",1.1)], "Og": [Ionic()], "Os": [Ionic(4,"VI",0.63),Ionic(5,"VI",0.575),Ionic(6,"V",0.49),Ionic(6,"VI",0.545),Ionic(7,"VI",0.525),Ionic(8,"IV",0.39)], "O": [Ionic(-2,"II",1.35),Ionic(-2,"III",1.36),Ionic(-2,"IV",1.38),Ionic(-2,"VI",1.4),Ionic(-2,"VIII",1.42)], "Pd": [Ionic(1,"II",0.59),Ionic(2,"IVSQ",0.64),Ionic(2,"VI",0.86),Ionic(3,"VI",0.76),Ionic(4,"VI",0.615)], "P": [Ionic(3,"VI",0.44),Ionic(5,"IV",0.17),Ionic(5,"V",0.29),Ionic(5,"VI",0.38)], "Pt": [Ionic(2,"IVSQ",0.6),Ionic(2,"VI",0.8),Ionic(4,"VI",0.625),Ionic(5,"VI",0.57)], "Pu": [Ionic(3,"VI",1),Ionic(4,"VI",0.86),Ionic(4,"VIII",0.96),Ionic(5,"VI",0.74),Ionic(6,"VI",0.71)], "Po": [Ionic(4,"VI",0.94),Ionic(4,"VIII",1.08),Ionic(6,"VI",0.67)], "K": [Ionic(1,"IV",1.37),Ionic(1,"VI",1.38),Ionic(1,"VII",1.46),Ionic(1,"VIII",1.51),Ionic(1,"IX",1.55), Ionic(1,"X",1.59),Ionic(1,"XII",1.64)], "Pr": [Ionic(3,"VI",0.99),Ionic(3,"VIII",1.126),Ionic(3,"IX",1.179),Ionic(4,"VI",0.85),Ionic(4,"VIII",0.96)], "Pm": [Ionic(3,"VI",0.97),Ionic(3,"VIII",1.093),Ionic(3,"IX",1.144)], "Pa": [Ionic(3,"VI",1.04),Ionic(4,"VI",0.9),Ionic(4,"VIII",1.01),Ionic(5,"VI",0.78),Ionic(5,"VIII",0.91),Ionic(5,"IX",0.95)], "Ra": [Ionic(2,"VIII",1.48),Ionic(2,"XII",1.7)], "Rn": [Ionic()], "Re": [Ionic(4,"VI",0.63),Ionic(5,"VI",0.58),Ionic(6,"VI",0.55),Ionic(7,"IV",0.38),Ionic(7,"VI",0.53)], "Rh": [Ionic(3,"VI",0.665),Ionic(4,"VI",0.6),Ionic(5,"VI",0.55)], "Rg": [Ionic()], "Rb": [Ionic(1,"VI",1.52),Ionic(1,"VII",1.56),Ionic(1,"VIII",1.61),Ionic(1,"IX",1.63),Ionic(1,"X",1.66), Ionic(1,"XI",1.69),Ionic(1,"XII",1.72),Ionic(1,"XIV",1.83)], "Ru": [Ionic(3,"VI",0.68),Ionic(4,"VI",0.62),Ionic(5,"VI",0.565),Ionic(7,"IV",0.38),Ionic(8,"IV",0.36)], "Rf": [Ionic()], "Sm": [Ionic(2,"VII",1.22),Ionic(2,"VIII",1.27),Ionic(2,"IX",1.32),Ionic(3,"VI",0.958),Ionic(3,"VII",1.02), Ionic(3,"VIII",1.079),Ionic(3,"IX",1.132),Ionic(3,"XII",1.24)], "Sc": [Ionic(3,"VI",0.745),Ionic(3,"VIII",0.87)], "Sg": [Ionic()], "Se": [Ionic(-2,"VI",1.98),Ionic(4,"VI",0.5),Ionic(6,"IV",0.28),Ionic(6,"VI",0.42)], "Si": [Ionic(4,"IV",0.26),Ionic(4,"VI",0.4)], "Ag": [Ionic(1,"II",0.67),Ionic(1,"IV",1),Ionic(1,"IVSQ",1.02),Ionic(1,"V",1.09),Ionic(1,"VI",1.15),Ionic(1,"VII",1.22), Ionic(1,"VIII",1.28),Ionic(2,"IVSQ",0.79),Ionic(2,"VI",0.94),Ionic(3,"IVSQ",0.67),Ionic(3,"VI",0.75)], "Na": [Ionic(1,"IV",0.99),Ionic(1,"V",1),Ionic(1,"VI",1.02),Ionic(1,"VII",1.12),Ionic(1,"VIII",1.18),Ionic(1,"IX",1.24), Ionic(1,"XII",1.39)], "Sr": [Ionic(2,"VI",1.18),Ionic(2,"VII",1.21),Ionic(2,"VIII",1.26),Ionic(2,"IX",1.31),Ionic(2,"X",1.36),Ionic(2,"XII",1.44)], "S": [Ionic(-2,"VI",1.84),Ionic(4,"VI",0.37),Ionic(6,"IV",0.12),Ionic(6,"VI",0.29)], "Ta": [Ionic(3,"VI",0.72),Ionic(4,"VI",0.68),Ionic(5,"VI",0.64),Ionic(5,"VII",0.69),Ionic(5,"VIII",0.74)], "Tc": [Ionic(4,"VI",0.645),Ionic(5,"VI",0.6),Ionic(7,"IV",0.37),Ionic(7,"VI",0.56)], "Te": [Ionic(-2,"VI",2.21),Ionic(4,"III",0.52),Ionic(4,"IV",0.66),Ionic(4,"VI",0.97),Ionic(6,"IV",0.43),Ionic(6,"VI",0.56)], "Ts": [Ionic()], "Tb": [Ionic(3,"VI",0.923),Ionic(3,"VII",0.98),Ionic(3,"VIII",1.04),Ionic(3,"IX",1.095),Ionic(4,"VI",0.76),Ionic(4,"VIII",0.88)], "Tl": [Ionic(1,"VI",1.5),Ionic(1,"VIII",1.59),Ionic(1,"XII",1.7),Ionic(3,"IV",0.75),Ionic(3,"VI",0.885),Ionic(3,"VIII",0.98)], "Th": [Ionic(4,"VI",0.94),Ionic(4,"VIII",1.05),Ionic(4,"IX",1.09),Ionic(4,"X",1.13),Ionic(4,"XI",1.18),Ionic(4,"XII",1.21)], "Tm": [Ionic(2,"VI",1.03),Ionic(2,"VII",1.09),Ionic(3,"VI",0.88),Ionic(3,"VIII",0.994),Ionic(3,"IX",1.052)], "Sn": [Ionic(4,"IV",0.55),Ionic(4,"V",0.62),Ionic(4,"VI",0.69),Ionic(4,"VII",0.75),Ionic(4,"VIII",0.81)], "Ti": [Ionic(2,"VI",0.86),Ionic(3,"VI",0.67),Ionic(4,"IV",0.42),Ionic(4,"V",0.51),Ionic(4,"VI",0.605),Ionic(4,"VIII",0.74)], "W": [Ionic(4,"VI",0.66),Ionic(5,"VI",0.62),Ionic(6,"IV",0.42),Ionic(6,"V",0.51),Ionic(6,"VI",0.6)], "U": [Ionic(3,"VI",1.025),Ionic(4,"VI",0.89),Ionic(4,"VII",0.95),Ionic(4,"VIII",1),Ionic(4,"IX",1.05),Ionic(4,"XII",1.17), Ionic(5,"VI",0.76),Ionic(5,"VII",0.84),Ionic(6,"II",0.45),Ionic(6,"IV",0.52),Ionic(6,"VI",0.73),Ionic(6,"VII",0.81), Ionic(6,"VIII",0.86)], "V": [Ionic(2,"VI",0.79),Ionic(3,"VI",0.64),Ionic(4,"V",0.53),Ionic(4,"VI",0.58),Ionic(4,"VIII",0.72),Ionic(5,"IV",0.355), Ionic(5,"V",0.46),Ionic(5,"VI",0.54)], "Xe": [Ionic(8,"IV",0.4),Ionic(8,"VI",0.48)], "Yb": [Ionic(2,"VI",1.02),Ionic(2,"VII",1.08),Ionic(2,"VIII",1.14),Ionic(3,"VI",0.868),Ionic(3,"VII",0.925),Ionic(3,"VIII",0.985), Ionic(3,"IX",1.042)], "Y": [Ionic(3,"VI",0.9),Ionic(3,"VII",0.96),Ionic(3,"VIII",1.019),Ionic(3,"IX",1.075)], "Zn": [Ionic(2,"IV",0.6),Ionic(2,"V",0.68),Ionic(2,"VI",0.74),Ionic(2,"VIII",0.9)], "Zr": [Ionic(4,"IV",0.59),Ionic(4,"V",0.66),Ionic(4,"VI",0.72),Ionic(4,"VII",0.78),Ionic(4,"VIII",0.84),Ionic(4,"IX",0.89)], } # Atom data: radii measured in Angstroms, taken from the reference below: # "Atomic Radii of the Elements," in CRC Handbook of Chemistry and Physics, 101st Edition # (Internet Version 2020), John R. Rumble, ed., CRC Press/Taylor & Francis, Boca Raton, FL # Elements arranged alphabetically, except for 'Dummy' which is a placeholder for non-elements Dummy = Atom_Data(radius=0.01, color=(1.0, 0.65, 1.0, 1)) Actinium = Atom_Data(2.01, 2.47, ionicData=IonicRadii["Ac"]) Aluminum = Atom_Data(1.24, 1.84, ionicData=IonicRadii["Al"]) Americium = Atom_Data(1.73, 2.44, ionicData=IonicRadii["Am"]) Antimony = Atom_Data(1.40, 2.06, ionicData=IonicRadii["Sb"]) Argon = Atom_Data(1.01, 1.88, ionicData=IonicRadii["Ar"]) Arsenic = Atom_Data(1.20, 1.85, ionicData=IonicRadii["As"]) Astatine = Atom_Data(1.48, 2.02, (0.99, 0.28, 0.11, 1), ionicData=IonicRadii["At"]) Barium = Atom_Data(2.06, 2.68, ionicData=IonicRadii["Ba"]) Berkelium = Atom_Data(1.68, 2.44, ionicData=IonicRadii["Bk"]) Beryllium = Atom_Data(0.99, 1.53, (0.13, 0.96, 0.55, 1), ionicData=IonicRadii["Be"]) Bismuth = Atom_Data(1.50, 2.07, (0.53, 0.84, 0.55, 1), ionicData=IonicRadii["Bi"]) Bohrium = Atom_Data(1.41, ionicData=IonicRadii["Bh"]) Boron = Atom_Data(0.84, 1.92, (1.00, 0.70, 0.70, 1), ionicData=IonicRadii["B"]) Bromine = Atom_Data(1.17, 1.85, (0.76, 0.00, 0.14, 1), ionicData=IonicRadii["Br"]) Cadmium = Atom_Data(1.40, 2.18, ionicData=IonicRadii["Cd"]) Calcium = Atom_Data(1.74, 2.31, (0.94, 0.00, 0.36, 1), ionicData=IonicRadii["Ca"]) Californium = Atom_Data(1.68, 2.45, ionicData=IonicRadii["Cf"]) Carbon = Atom_Data(0.75, 1.70, (0.10, 0.10, 0.10, 1), ionicData=IonicRadii["Ac"]) Cerium = Atom_Data(1.84, 2.42, ionicData=IonicRadii["Ce"]) Cesium = Atom_Data(2.38, 3.43, ionicData=IonicRadii["Cs"]) Chlorine = Atom_Data(1.00, 1.75, (0.00, 0.94, 0.26, 1), ionicData=IonicRadii["Cl"]) Chromium = Atom_Data(1.30, 2.06, ionicData=IonicRadii["Cr"]) Cobalt = Atom_Data(1.18, 2.00, (0.00, 0.39, 0.94, 1), ionicData=IonicRadii["Co"]) Copernicium = Atom_Data(1.22, ionicData=IonicRadii["Cn"]) Copper = Atom_Data(1.22, 1.96, (0.00, 0.94, 0.75, 1), ionicData=IonicRadii["Cu"]) Curium = Atom_Data(1.68, 2.45, ionicData=IonicRadii["Cm"]) Darmstadtium = Atom_Data(1.28, ionicData=IonicRadii["Ds"]) Dubnium = Atom_Data(1.49, ionicData=IonicRadii["Db"]) Dysprosium = Atom_Data(1.80, 2.31, ionicData=IonicRadii["Dy"]) Einsteinium = Atom_Data(1.65, 2.45, ionicData=IonicRadii["Es"]) Erbium = Atom_Data(1.77, 2.29, ionicData=IonicRadii["Er"]) Europium = Atom_Data(1.83, 2.35, (1.00, 0.18, 0.39, 1), ionicData=IonicRadii["Eu"]) Fermium = Atom_Data(1.67, 2.45, ionicData=IonicRadii["Fm"]) Flerovium = Atom_Data(1.43, ionicData=IonicRadii["Fl"]) Fluorine = Atom_Data(0.60, 1.47, (0.00, 0.90, 0.00, 1), ionicData=IonicRadii["F"]) Francium = Atom_Data(2.42, 3.48, ionicData=IonicRadii["Fr"]) Gadolinium = Atom_Data(1.82, 2.34, ionicData=IonicRadii["Gd"]) Gallium = Atom_Data(1.23, 1.87, ionicData=IonicRadii["Ga"]) Germanium = Atom_Data(1.20, 2.11, ionicData=IonicRadii["Ge"]) Gold = Atom_Data(1.30, 2.14, (0.99, 0.95, 0.11, 1), ionicData=IonicRadii["Au"]) Hafnium = Atom_Data(1.64, 2.23, ionicData=IonicRadii["Hf"]) Hassium = Atom_Data(1.34, ionicData=IonicRadii["Hs"]) Helium = Atom_Data(0.37, 1.40, ionicData=IonicRadii["He"]) Holmium = Atom_Data(1.79, 2.30, ionicData=IonicRadii["Ho"]) Hydrogen = Atom_Data(0.32, 1.10, (0.80, 0.80, 0.80, 1), ionicData=IonicRadii["H"]) Indium = Atom_Data(1.42, 1.93, ionicData=IonicRadii["In"]) Iodine = Atom_Data(1.36, 1.98, (0.49, 0.03, 0.73, 1), ionicData=IonicRadii["I"]) Iridium = Atom_Data(1.32, 2.13, ionicData=IonicRadii["Ir"]) Iron = Atom_Data(1.24, 2.04, (0.47, 0.05, 0.13, 1), ionicData=IonicRadii["Fe"]) Krypton = Atom_Data(1.16, 2.02, ionicData=IonicRadii["Kr"]) Lanthanum = Atom_Data(1.94, 2.43, ionicData=IonicRadii["La"]) Lawrencium = Atom_Data(1.61, 2.46, ionicData=IonicRadii["Lr"]) Lead = Atom_Data(1.45, 2.02, (0.06, 0.06, 0.06, 1), ionicData=IonicRadii["Pb"]) Lithium = Atom_Data(1.30, 1.82, (0.96, 0.13, 0.76, 1), ionicData=IonicRadii["Li"]) Livermorium = Atom_Data(1.75, ionicData=IonicRadii["Lv"]) Lutetium = Atom_Data(1.74, 2.24, ionicData=IonicRadii["Lu"]) Magnesium = Atom_Data(1.40, 1.73, (0.90, 0.90, 0.90, 1), ionicData=IonicRadii["Mg"]) Manganese = Atom_Data(1.29, 2.05, (0.94, 0.00, 0.80, 1), ionicData=IonicRadii["Mn"]) Meitnerium = Atom_Data(1.29, ionicData=IonicRadii["Mt"]) Mendelevium = Atom_Data(1.73, 2.46, ionicData=IonicRadii["Md"]) Mercury = Atom_Data(1.32, 2.23, ionicData=IonicRadii["Hg"]) Molybdenum = Atom_Data(1.46, 2.17, ionicData=IonicRadii["Mo"]) Moscovium = Atom_Data(1.62, ionicData=IonicRadii["Mc"]) Neodymium = Atom_Data(1.88, 2.39, ionicData=IonicRadii["Nd"]) Neon = Atom_Data(0.62, 1.54, ionicData=IonicRadii["Ne"]) Neptunium = Atom_Data(1.80, 2.39, ionicData=IonicRadii["Np"]) Nickel = Atom_Data(1.17, 1.97, ionicData=IonicRadii["Ni"]) Nihonium = Atom_Data(1.36, ionicData=IonicRadii["Nh"]) Niobium = Atom_Data(1.56, 2.18, ionicData=IonicRadii["Nb"]) Nitrogen = Atom_Data(0.71, 1.55, (0.00, 0.00, 0.90, 1), ionicData=IonicRadii["N"]) Nobelium = Atom_Data(1.76, 2.46, ionicData=IonicRadii["No"]) Oganesson = Atom_Data(1.57, ionicData=IonicRadii["Og"]) Osmium = Atom_Data(1.36, 2.16, ionicData=IonicRadii["Os"]) Oxygen = Atom_Data(0.64, 1.52, (0.90, 0.00, 0.00 ,1), ionicData=IonicRadii["O"]) Palladium = Atom_Data(1.30, 2.10, ionicData=IonicRadii["Pd"]) Phosphorus = Atom_Data(1.09, 1.80, (0.85, 0.00, 0.95, 1), ionicData=IonicRadii["P"]) Platinum = Atom_Data(1.30, 2.13, ionicData=IonicRadii["Pt"]) Plutonium = Atom_Data(1.80, 2.43, (1.00, 0.80, 0.00, 1), ionicData=IonicRadii["Pu"]) Polonium = Atom_Data(1.42, 1.97, (0.53, 1.00, 0.32, 1), ionicData=IonicRadii["Po"]) Potassium = Atom_Data(2.00, 2.75, (0.60, 0.00, 0.94, 1), ionicData=IonicRadii["K"]) Praseodymium = Atom_Data(1.90, 2.40, ionicData=IonicRadii["Pr"]) Promethium = Atom_Data(1.86, 2.38, ionicData=IonicRadii["Pm"]) Protactinium = Atom_Data(1.84, 2.43, ionicData=IonicRadii["Pa"]) Radium = Atom_Data(2.11, 2.83, ionicData=IonicRadii["Ra"]) Radon = Atom_Data(1.46, 2.20, (0.57, 0.99, 0.10, 1), ionicData=IonicRadii["Rn"]) Rhenium = Atom_Data(1.41, ionicData=IonicRadii["Re"]) Rhodium = Atom_Data(1.34, 2.10, ionicData=IonicRadii["Rh"]) Roentgenium = Atom_Data(1.21, ionicData=IonicRadii["Rg"]) Rubidium = Atom_Data(2.15, 3.03, ionicData=IonicRadii["Rb"]) Ruthenium = Atom_Data(1.36, 2.13, ionicData=IonicRadii["Ru"]) Rutherfordium = Atom_Data(1.57, ionicData=IonicRadii["Rf"]) Samarium = Atom_Data(1.85, 2.36, ionicData=IonicRadii["Sm"]) Scandium = Atom_Data(1.59, 2.15, (0.94, 0.70, 0.00, 1), ionicData=IonicRadii["Sc"]) Seaborgium = Atom_Data(1.43, ionicData=IonicRadii["Sg"]) Selenium = Atom_Data(1.18, 1.90, ionicData=IonicRadii["Se"]) Silicon = Atom_Data(1.14, 2.10, (0.95, 1.00, 0.48, 1), ionicData=IonicRadii["Si"]) Silver = Atom_Data(1.36, 2.11, (0.83, 0.83, 0.83, 1), ionicData=IonicRadii["Ag"]) Sodium = Atom_Data(1.60, 2.27, (0.00, 0.50, 0.76, 1), ionicData=IonicRadii["Na"]) Strontium = Atom_Data(1.90, 2.49, ionicData=IonicRadii["Sr"]) Sulfur = Atom_Data(1.04, 1.80, (0.94, 0.94, 0.00, 1), ionicData=IonicRadii["S"]) Tantalum = Atom_Data(1.58, 2.22, ionicData=IonicRadii["Ta"]) Technetium = Atom_Data(1.38, 2.16, ionicData=IonicRadii["Tc"]) Tellurium = Atom_Data(1.37, 2.06, ionicData=IonicRadii["Te"]) Tennessine = Atom_Data(1.65, ionicData=IonicRadii["Ts"]) Terbium = Atom_Data(1.81, 2.33, ionicData=IonicRadii["Tb"]) Thallium = Atom_Data(1.44, 1.96, ionicData=IonicRadii["Tl"]) Thorium = Atom_Data(1.90, 2.45, ionicData=IonicRadii["Th"]) Thulium = Atom_Data(1.77, 2.27, ionicData=IonicRadii["Tm"]) Tin = Atom_Data(1.40, 2.17, ionicData=IonicRadii["Sn"]) Titanium = Atom_Data(1.48, 2.11, ionicData=IonicRadii["Ti"]) Tungsten = Atom_Data(1.50, 2.18, ionicData=IonicRadii["W"]) Uranium = Atom_Data(1.83, 2.41, (0.53, 1.00, 0.32, 1), ionicData=IonicRadii["U"]) Vanadium = Atom_Data(1.44, 2.07, ionicData=IonicRadii["V"]) Xenon = Atom_Data(1.36, 2.16, ionicData=IonicRadii["Xe"]) Ytterbium = Atom_Data(1.78, 2.26, ionicData=IonicRadii["Yb"]) Yttrium = Atom_Data(1.76, 2.32, ionicData=IonicRadii["Y"]) Zinc = Atom_Data(1.20, 2.01, ionicData=IonicRadii["Zn"]) Zirconium = Atom_Data(1.64, 2.23, ionicData=IonicRadii["Zr"]) Elements = { #element symbols, their covalent radii & their RGBA color values "Xx": Dummy, "Ac": Actinium, "Al": Aluminum, "Am": Americium, "Sb": Antimony, "Ar": Argon, "As": Arsenic, "At": Astatine, "Ba": Barium, "Bk": Berkelium, "Be": Beryllium, "Bi": Bismuth, "Bh": Bohrium, "B": Boron, "Br": Bromine, "Cd": Cadmium, "Ca": Calcium, "Cf": Californium, "C": Carbon, "Ce": Cerium, "Cs": Cesium, "Cl": Chlorine, "Cr": Chromium, "Co": Cobalt, "Cn": Copernicium, "Cu": Copper, "Cm": Curium, "Ds": Darmstadtium, "Db": Dubnium, "Dy": Dysprosium, "Es": Einsteinium, "Er": Erbium, "Eu": Europium, "Fm": Fermium, "Fl": Flerovium, "F": Fluorine, "Fr": Francium, "Gd": Gadolinium, "Ga": Gallium, "Ge": Germanium, "Au": Gold, "Hf": Hafnium, "Hs": Hassium, "He": Helium, "Ho": Holmium, "H": Hydrogen, "In": Indium, "I": Iodine, "Ir": Iridium, "Fe": Iron, "Kr": Krypton, "La": Lanthanum, "Lr": Lawrencium, "Pb": Lead, "Li": Lithium, "Lv": Livermorium, "Lu": Lutetium, "Mg": Magnesium, "Mn": Manganese, "Mt": Meitnerium, "Md": Mendelevium, "Hg": Mercury, "Mo": Molybdenum, "Mc": Moscovium, "Nd": Neodymium, "Ne": Neon, "Np": Neptunium, "Ni": Nickel, "Nh": Nihonium, "Nb": Niobium, "N": Nitrogen, "No": Nobelium, "Og": Oganesson, "Os": Osmium, "O": Oxygen, "Pd": Palladium, "P": Phosphorus, "Pt": Platinum, "Pu": Plutonium, "Po": Polonium, "K": Potassium, "Pr": Praseodymium, "Pm": Promethium, "Pa": Protactinium, "Ra": Radium, "Rn": Radon, "Re": Rhenium, "Rh": Rhodium, "Rg": Roentgenium, "Rb": Rubidium, "Ru": Ruthenium, "Rf": Rutherfordium, "Sm": Samarium, "Sc": Scandium, "Sg": Seaborgium, "Se": Selenium, "Si": Silicon, "Ag": Silver, "Na": Sodium, "Sr": Strontium, "S": Sulfur, "Ta": Tantalum, "Tc": Technetium, "Te": Tellurium, "Ts": Tennessine, "Tb": Terbium, "Tl": Thallium, "Th": Thorium, "Tm": Thulium, "Sn": Tin, "Ti": Titanium, "W": Tungsten, "U": Uranium, "V": Vanadium, "Xe": Xenon, "Yb": Ytterbium, "Y": Yttrium, "Zn": Zinc, "Zr": Zirconium, }
class Adapter(object): def __init__(self): self.interfaces = []
with open("10.in") as file: lines = file.readlines() lines = [line.rstrip() for line in lines] # Part 1 luc = {"(": ")", ")": "(", "[": "]", "]": "[", "{": "}", "}": "{", "<": ">", ">": "<"} lup = {")": 3, "]": 57, "}": 1197, ">": 25137} score = 0 for line in lines: stack = [] for i in range(0, len(line)): if line[i] in ["(", "[", "{", "<"]: stack.append(line[i]) elif len(stack) > 0 and luc[line[i]] == stack[len(stack)-1]: stack.pop(len(stack)-1) else: score += lup[line[i]] break print(score) # Part 2 lup = {")": 1, "]": 2, "}": 3, ">": 4} scores = [] for line in lines: stack = [] score = 0 for i in range(0, len(line)): if line[i] in ["(", "[", "{", "<"]: stack.append(line[i]) elif len(stack) > 0 and luc[line[i]] == stack[len(stack)-1]: stack.pop(len(stack)-1) else: break if i == len(line)-1: for i in range(len(stack)-1, -1, -1): score = score * 5 + lup[luc[stack[i]]] scores.append(score) scores.sort() print(scores[int((len(scores) - 1)/2)])
__all__ = [ 'config_enums', 'feed_enums', 'file_enums' ]
#Flag #Use a flag that stores on the nodes to know if we visited or not. #time: O(N). #space: O(N), for each node we use O(1) and there are N nodes. class Solution(object): def detectCycle(self, head): curr = head while curr: if hasattr(curr, 'visited') and curr.visited: return curr curr.visited = True curr = curr.next return None #HashSet #Use a hash-set to store the visited nodes #time: O(N). #space: O(N). class Solution(object): def detectCycle(self, head): visited = set() curr = head while curr: if curr in visited: return curr visited.add(curr) curr = curr.next return None
class Solution: def binarySearchableNumbers(self, nums: List[int]) -> int: maximums = [nums[0]] # from the left minimums = [0] * len(nums) # from the right min_n = nums[-1] result = 0 for n in nums[1::]: maximums.append(max(maximums[-1], n)) for idx in range(len(nums)-1, -1, -1): min_n = min(min_n, nums[idx]) minimums[idx] = min_n if nums[idx] == maximums[idx] and nums[idx] == minimums[idx]: result += 1 return result
''' 快速排序 ''' # 1、描述 ''' 快速排序是由东尼·霍尔所发展的一种排序算法。 快速排序使用分治法(Divide and conquer)策略来把一个串行(list)分为两个子串行(sub-lists),其是一种分而治之思想在排序算法上的典型应用。 通过一趟排序将要排序的数据分割成独立的两部分,其中一部分的所有数据都比另外一部分的所有数据都要小, 然后再按此方法对这两部分数据分别进行快速排序,整个排序过程可以递归进行,以此达到整个数据标出有序数列。 ''' # 2、算法步骤 ''' (1)从数列中挑出一个元素,称为 “基准”(pivot); (2)重新排序数列,所有元素比基准值小的摆放在基准前面,所有元素比基准值大的摆在基准的后面(相同的数可以到任一边)。 在这个分区退出之后,该基准就处于数列的中间位置。这个称为分区(partition)操作; (3)递归地(recursive)把小于基准值元素的子数列和大于基准值元素的子数列排序,直至迭代(iteration)完成,即完成排序。 ''' # 3、代码实现 def quick_sort(arr): return q_sort(arr, 0, len(arr) - 1) # 返回待排序列最小下标值 left 和最大下标值 right def q_sort(arr, left, right): if left < right: pivot = q_partition(arr, left, right) # 获取待排序列一个分组标准,并对其进行分组 q_sort(arr, left, pivot - 1) q_sort(arr, pivot + 1, right) return arr def q_partition(arr, left, right): pivot = left while left < right: while left < right and arr[right] >= arr[pivot]: right -= 1 arr[left] = arr[right] while left < right and arr[left] <= arr[pivot]: left += 1 arr[right] = arr[left] arr[right] = arr[pivot] return left # 4、示例 arr = [10, 23, 6, 8, 2, 16, 0, 9] print(quick_sort(arr)) # 输出结果为 [0, 2, 6, 8, 9, 10, 16, 23]
# def candies(s): # worst case = three passes of 's', len, max, sum # length = len(s) # if length <= 1: # return -1 # return max(s) * length - sum(s) def candies(seq): length = 0 maximum = 0 total = 0 for i, a in enumerate(seq): try: current = int(a) except TypeError: return -1 length += 1 total += current if current > maximum: maximum = current return maximum * length - total if length > 1 else -1
def convert2meter(s, input_unit="in"): ''' Function to convert inches, feet and cubic feet to meters and cubic meters ''' if input_unit == "in": return s*0.0254 elif input_unit == "ft": return s*0.3048 elif input_unit == "cft": return s*0.0283168 else: print("Error: Input unit is unknown.") ## Apply function measurement_unit = {"Girth":"in", "Height":"ft", "Volume":"cft"} trees = trees_raw.copy() for feature in ["Girth", "Height", "Volume"]: trees[feature] = trees_raw[feature].apply(lambda x: convert2meter(s=x, input_unit=measurement_unit.get(feature)))
# reference : https://wikidocs.net/16074 class Language: default_language = "English" def __init__(self): self.show = '나의 언어는 ' + self.default_language @classmethod def class_my_language(cls): return cls() @staticmethod def static_my_language(): return Language() def print_language(self): print(self.show) class KoreanLanguage(Language): default_language = "한국어" a = KoreanLanguage.static_my_language() b = KoreanLanguage.class_my_language() a.print_language() b.print_language() """ 실행결과 >>> 나의 언어는 English 나의 언어는 한국어 """
# [Stone Colusses] It Ain't Natural CHIEF_TATOMO = 2081000 sm.setSpeakerID(CHIEF_TATOMO) sm.sendNext("Well, you don't look like you just spoke to an ancient nature spirit, but I suppose we'll know soon enough. " "Are you ready for a little adventure?\r\n\r\n" "#bYou know it! How do I get to the Stone Colossus?") sm.sendSay("Ah, humans. No patience, and not enough hair. " "I would advise you to seek out the Halflinger expedition that has already traveled to the area. " "They could help you.\r\n\r\n" "#bThese are Halflinger explorers?") response = sm.sendAskYesNo("Don't act so surprised! " "Our people are peaceful home-bodies for the most part, but the blood of the explorer can show up where you least expect it. " "What kind of chief would I be if I held them back?\r\n" "If you'd like, I can send you to their camp right away.") if response: sm.sendNext("That's the spirit. Do an old-timer a favour and check on my villagers for me.") sm.completeQuest(parentID) sm.warp(240090000) # Stone Colossus Exploration Site else: sm.sendNext("Oh.. Okay.. I mean.. I thought you were all about adventures.. I guess I was wrong..\r\n\r\n" "This is so sad.\r\n" "Alexa, play Despacito 5!")
#!/usr/bin/env python # -*- coding: utf-8 -*- # ====================================================================== # # gensbo - a GENeral Simulation Based Optimizer # # 一个基于仿真的优化器 # # ====================================================================== # # author : Mingtao Li # date : 2019.03.26 # contributors : Xiaohai Zhang # email : mingtao.li@gmail.com # url : https://www.mingtaoli.cn # # ====================================================================== """ utilities """ def listattributes(self): print("\n") print('Attributes List of: ' + repr(self.__dict__['name']) + ' - ' + self.__class__.__name__ + ' Instance\n') self_keys = sorted(self.__dict__) for key in self_keys: if key != 'name': print(str(key) + ' : ' + repr(self.__dict__[key])) # end # end print('\n') def subclasses(cls, just_leaf=False): sc = cls.__subclasses__() ssc = [g for s in sc for g in subclasses(s, just_leaf)] return [s for s in sc if not just_leaf or not s.__subclasses__()] + ssc def subclass_where(cls, **kwargs): k, v = next(iter(kwargs.items())) for s in subclasses(cls): if hasattr(s, k) and getattr(s, k) == v: return s raise KeyError("No subclasses of {0} with cls.{1} == '{2}'".format( cls.__name__, k, v))
# a = [1,2,2,3,4,5] # # print(list(set(a))) # def correct_list(a): # return(list(set(a))) # print(correct_list(a)) a = [1,2,2,3,4,5] def correct_list(a): s = [] for i in a: if i not in s: s.append(i) return(s) print(correct_list(a))
# coding: UTF-8 print(r''' 【程序19】题目:打印出如下图案(菱形) 7 * 8: * *** ****** ******** ****** *** * * 4s 1 *** 3s 3 ****** 1s 5 ******** 0s 8 ****** 1s 5 *** 2s 3 * 3s 1 7 * 9: * *** ******* ********* ******* *** * 程序分析:先把图形分成两部分来看待,前四行一个规律,后三行一个规律,利用双重 for循环,第一层控制行,第二层控制列。 ''') row_num = 7 row_diff = 1 column_num = 8 col_diff = 2 def intval(sum_num): z = 0 if sum_num % 2 == 1: z = 1 return int(sum_num / 2) + z for l in range(0, row_num + 1): space_num = 1 star_num = 1 space_num = (intval(row_num) - l) * row_diff star_num = (l + 1) * 2 - 1 print(' '*space_num + '*'*star_num)
''' Title: %s Given: %s Return %s Sample Dataset: %s Sample Output: %s ''' def compute(): pass if __name__ == "__main__": pass
def read_color(input_func): """ Reads input color and lower cases it """ user_supplied_color = input_func() return user_supplied_color.casefold() def is_quit(user_supplied_color): return 'quit' == user_supplied_color def print_colors(): """ In the while loop ask the user to enter a color, lowercase it and store it in a variable. Next check: - if 'quit' was entered for color, print 'bye' and break. - if the color is not in VALID_COLORS, print 'Not a valid color' and continue. - otherwise print the color in lower case. """ pass
class Solution(object): def findSubstring(self, s, words): """ :type s: str :type words: List[str] :rtype: List[int] """ ret = []; wl = len(words[0]) wordsused = [] for i in range (0, len(s) - len(words) * wl + 1): test = s[i:i+wl] if test in words: for j in range(0, len(words) * wl, wl): curr = s[i+j:i+j+wl] if curr in words: words.remove(curr) wordsused.append(curr); else: break if len(words) == 0: ret.append(i) words = wordsused wordsused = [] else: for w in wordsused: words.append(w) wordsused = [] return ret;
# encoding: utf-8 ################################################## # This script shows an example of a header section. This sections is a group of commented lines (lines starting with # the "#" character) that describes general features of the script such as the type of licence (defined by the # developer), authors, credits, versions among others ################################################## # ################################################## # Author: Soroush Garivani # Copyright: Copyright 2019, IAAC # Credits: [Institute for Advanced Architecture of Catalonia - IAAC, Advanced Architecture group] # License: Apache License Version 2.0 # Version: 1.0.0 # Maintainer: Soroush Garivani # Email: soroush.garivani@iaac.net # Status: development ################################################## # End of header section # tuples print("tuples are very similar to lists") print("the are defined by ()") my_tuple = (1, 2, 3) print(my_tuple) data_type = type(my_tuple) print(data_type, '\n') print("tuples can have different data types as items") my_tuple = ('One', 'Two', 3) print(my_tuple, '\n') print("you can use indexing and slicing for tuples") print(my_tuple[0]) print(my_tuple[-1]) print(my_tuple[0:2], '\n') # print ("the difference between tuples and lists is that tuples are 'immutable'. This means once they are assigned they cannot be reassigned.") # my_list = [1,2,3,4] # my_tuple = (1,2,3,4) # my_list[0] = 'ONE' # print (my_list) # my_tuple[0] = 'ONE' # print (my_tuple) # # tuples are useful when you want to make sure your elements will not change during the program
string = input('Digite a palavra:') stringSemEspacos = string.replace(' ', '') stringTodaMinuscula = stringSemEspacos.lower() stringInvertida = stringTodaMinuscula[::-1] if stringInvertida == stringTodaMinuscula: print("É um palíndromo.") else: print("Não é um palíndromo.")
#经典的约瑟夫环问题,不容错过 #by leetcode.cn/u/ak-bot #2022-5-4 def josephsring_recursive(n,k): ''' 约瑟夫环(递归解法) 时间复杂度:O(n) n个人围成一圈,从0开始编码。 从第一个人(0号)开始计数,杀死第k个人,然后从下一个人开始计数,问谁能活到最后? 输入: n:人数 k:杀死第k个人 返回: ans:活到最后的那个人 ''' #分析: #如果只有一个人,那直接返回0就可以了 #如果是两个人,如果k是奇数,那0号先挂;如果是偶数,1号先挂 #(这个时候我们发现k-1对n的余数(k-1)%n就是第一个挂掉的人,是否可以考虑递归?) #(等等……如果第i个人挂掉了,就会从i+1开始计数,可是我们的题目要求是从第一个人开始计数啊) #(如果递归的话,如果将从第i+1开始计数的问题转化为从第一个人开始计数的问题呢?) #(因为是一个环,假如从第1个人开始计数的结果是ans) #(将ans做一个魔法处理:(ans+i+1)%n是不是就得到从第i+1开始计数的结果了?) #(不对……还有一个问题:因为在n个人中,第i个人已经挂掉了,编号不再连续,变成了……,i-1,i+1,……) #(那么计算出的n-1个人的结果,怎样才能映射到这个不连续的序列上呢?) # 假设n=6,k=4 # 原序列是:0 1 2 3 4 5 # 计算第一个挂掉的人:i = (k-1)%n = (4-1)%6 = 3 # 序列变成了A:0 1 2 4 5(下一个人从i+1=4开始计数) # 假如最终结果是ans # 由于需要递归,我们考虑n1=n-1=5,k=4的情形: # 原序列是A1:0 1 2 3 4 # 假如最终活下来的人是ans1 # 我们需要通过ans1来计算ans # 建立ans1到ans的映射: # 0 -> 4 # 1 -> 5 # 2 -> 0 # 3 -> 1 # 4 -> 2 # 尝试用公式来描述这个映射: # ans = (ans1 + i)%n1 # 映射为: # 0 -> 3(少了1) # 1 -> 4(少了1) # 2 -> 0 # 3 -> 1 # 4 -> 2 # 调整为: # ans = (ans1 + i)%n1 # if ans >= i: # ans += 1 if n == 1: return 0 i = (k-1)%n ans1 = josephsring_recursive(n-1,k) ans = (ans1+i) % (n-1) if ans >= i: ans += 1 return ans def josephsring_non_recursive(n,k): ''' 约瑟夫环(非递归解法) 由于递归解法可能会栈溢出 考虑非递归的解法 ''' #分析: #按照经验,递归解法应该都能转化为非递归 #在递归的过程中n逐渐缩小为1,计算出n=1的结果后,再推广到n=2的值,逐渐放大直到计算出最后的结果 #(等等,这个不就是动态规划么?) #删除递归中,缩小n到1的过程,直接以1为起点来计算结果,不断推广到下一个结果 ans = 0 for n1 in range(2,n+1): i = (k-1)%n1 ans = (ans+i) % (n1-1) if ans >= i: ans += 1 return ans if __name__ == '__main__': n,k = map(int,input().split()) #ans = josephsring_recursive(n,k) #print(ans) ans = josephsring_non_recursive(n,k) print(ans)
# función que verifica la elección del usuario con respecto # al menú principal def get_choice(text = None): """ gets users choice from a numbered list """ try: choice = int(input(text if text else "Choose something...\n")) return choice except Exception as error: print("Please don't be a douche, input a valid number.") return 0
# # Note. # # Root directory: Visual studio code workspace root. # block_input_file = "./ascii-floor-map-to-csv/data/block-map.txt" table_input_file = "./ascii-floor-map-to-csv/data/table-number-map.txt" output_file_name = "./ascii-floor-map-to-csv/auto-generated/floor-map.csv" try: bl_file = open(block_input_file) try: ta_file = open(table_input_file) try: out_file = open(output_file_name, 'w', encoding='utf-8') # Column name, No space. out_file.write("ID,X,Y,BLOCK\n") id_column = [] x_column = [] y_column = [] block_column = [] bl_lines = bl_file.readlines() for y, line in enumerate(bl_lines): for x, block in enumerate(line): if block != '.' and block != '\n': x_column.append(x) y_column.append(y) block_column.append(block) ta_lines = ta_file.readlines() for row in ta_lines: cols = row.split(",") for x, number_text in enumerate(cols): num = int(number_text) if num != 0: id_column.append(num) # 机の個数をベースで。 print("len(id_column ):{}".format(len(id_column))) print("len(x_column ):{}".format(len(x_column))) print("len(y_column ):{}".format(len(y_column))) print("len(block_column):{}".format(len(block_column))) for i, block in enumerate(block_column): # print("i:{}".format(i)) out_file.write("{},{},{},{}\n".format( id_column[i], x_column[i], y_column[i], block)) except Exception as e: print(e) finally: out_file.close() except Exception as e: print(e) finally: ta_file.close() except Exception as e: print(e) finally: bl_file.close() print("Info : Finished.")
def result(text): count=0 for i in range(len(metin)): if(ord(metin[i])>=65 and ord(metin[i])<=90): count=count+1 return count
#Pegando o nome completo nome = input('Digite seu nome completo: ') #transformando nomeUp = nome.upper() nomeLow = nome.lower() #Nome sem espaços #Dividindo divNome = nome.split() #print(divNome) #Pegando primeiro nome firstNome = divNome[0] tamFirstNome = len(firstNome) #print(firstNome) #Juntando nomeJunt = ''.join(divNome) #print(nomeJunt) tamNomeJunt = len(nomeJunt) #mostrando print('Seu nome em maiusculo é {}'.format(nomeUp)) print('Seu nome em minusculo é {}'.format(nomeLow)) print('Seu nome *sem espaços* tem {} de tamanho'.format(tamNomeJunt)) print('Seu primeiro nome {} tem exato {} de tamanho'.format(firstNome, tamFirstNome)) ''' Nesses programas (22 - 27) é focado no tratamento de strings Primeiro a variavel nome recebe uma string do usuário Em seguida temos a variavel nomeUp que usa a função upper() para deixar tudo em caixa Alta Depois nomeLow que usa a função lower() para fazer o contrário Para fazer o resto das verificações, usamos a divNome que usa o split() que separa os nomes pelo espaço deixando-os em uma lista Para pegar o primeiro nome usa a função firstNome que usa o indice [0] que é usado nas listas para achar o primeiro valor Em seguida a variavel tamFirstNome uma a função len() que pega o tamanho da string Para juntar os nomes usamos a variavel nomeJunt que usa a função join() que vai juntar a lista os separando apenas pelo '' (ou seja sem espaços) E a variavel tamNomeJunt usa o len() para saber o valor do nome completo sem espaços Por fim cada verificação é printada no print e mostrada ao usuário '''
def genTest(): print('Block of code before first yield statement') yield 1 print('Block of code after first yield statement and before second yield statement') yield 2 print('Block of code after all yield statements') # foo = genTest returns <function gen at 0x101faf400> foo = genTest() # returns <generator object gen at 0x101f9f408> print(foo.__next__()) print() print(foo.__next__()) print('\n') for f in foo: print(f) # **OUTPUT** # Block of code before first yield statement # 1 # Block of code after first yield statement and before second yield statement # 2 # # # Block of code after all yield statements
class PropertyReference: def __init__(self, var_name, property_name): self.var_name = var_name self.property_name = property_name def __str__(self): return f'{self.var_name}.{self.property_name}' def code_gen_string(self): return str(self) class FunctionCallArgument: def __init__(self, arg_type, value): self.arg_type = arg_type self.value = value def __str__(self): return f'{self.arg_type}: {self.value}' def code_gen_string(self): if isinstance(self.value, str) or isinstance(self.value, int) or isinstance(self.value, float): return f'{self.value}' return self.value.code_gen_string() class FunctionCall: def __init__(self, name, args, result): self.name = name self.args = args self.result = result def __str__(self): return_str = '' args = ', '.join(map(str, self.args)) return f'{return_str}{self.name}({args})' def code_gen_string(self): args = ', '.join(map(lambda x: x.code_gen_string(), self.args)) return f'{self.name}({args})' class AssignVariable: def __init__(self, var_name, var_type, value): self.var_name = var_name self.var_type = var_type self.value = value def __str__(self): val = self.value if isinstance(val, list): val = ', '.join(map(str, self.value)) return f'{self.var_type}: {self.var_name} = {val}' def code_gen_string(self): if isinstance(self.value, list): val = f"[{', '.join(map(lambda x: x.code_gen_string(), self.value))}]" elif isinstance(self.value, str): val = self.value else: val = self.value.code_gen_string() return f'{self.var_name} = {val}' class ModifyString: def __init__(self, insert_mode, int_val, str_val, obj): self.insert_mode = insert_mode self.int_val = int_val self.str_val = str_val self.obj = obj def __str__(self): return f'modify_string_59({self.insert_mode}, {self.int_val}, {self.str_val}, {self.obj})' def code_gen_string(self): return str(self) class BinaryIntermediate: def __init__(self, op, left, right): self.op = op self.left = left self.right = right def __str__(self): return f'{self.left} {self.op} {self.right}' def code_gen_string(self): return f'{self.left.code_gen_string()} {self.op} {self.right.code_gen_string()}' class UnaryIntermediate: def __init__(self, operator, operand): self.operator = operator self.operand = operand def __str__(self): return f'{self.operator} {self.operand}' def code_gen_string(self): return f'{self.operator} {self.operand.code_gen_string()}' class EndControlStatement: def __init__(self, control_statement): self.control_statement = control_statement def __str__(self): return f'end{self.control_statement}' def code_gen_string(self): return str(self) class BreakStatement: def __str__(self): return 'break' def code_gen_string(self): return str(self) class LoopOpenStatement: def __init__(self, cond): self.cond = cond def __str__(self): return f'loop while( {self.cond} )' def code_gen_string(self): return f'repeat while ( {self.cond.code_gen_string()} )' class LoopEndStatement(EndControlStatement): def __init__(self): super().__init__('repeat') class LoopCounterIncrement: def __init__(self, var): self.var = var def __str__(self): return f'increment( {self.var.name} )' def code_gen_string(self): return f'{self.var.name}++' class IfEndStatement(EndControlStatement): def __init__(self): super().__init__('if') class IfControlStatement: def __init__(self, expr): self.expr = expr def __str__(self): return f'if( {self.expr} )' def code_gen_string(self): return f'if ({self.expr.code_gen_string()})' class ElseifControlStatement: def __init__(self, expr): self.expr = expr def __str__(self): return f'elseif( {self.expr} )' def code_gen_string(self): return f'elseif ({self.expr.code_gen_string()})' class ElseControlStatement: def __str__(self): return 'else' def code_gen_string(self): return str(self) class SwitchOpenStatement: def __init__(self, cond): self.cond = cond def __str__(self): return f'switch ( {self.cond} ):' def code_gen_string(self): if isinstance(self.cond, str): val = self.cond else: val = self.cond.code_gen_string() return f'switch ({val})' class SwitchCaseStatement: def __init__(self, case_opt): self.case_opt = case_opt def __str__(self): return f'case {self.case_opt.code_gen_string()}:' def code_gen_string(self): return str(self) class SwitchEndStatement(EndControlStatement): def __init__(self): super().__init__('switch') class SwitchBreakStatement(BreakStatement): pass class ReturnStatement: def __str__(self): return 'return' def code_gen_string(self): return str(self) class GotoStatement: def __init__(self, label): self.label = label def __str__(self): return f'goto {self.label}' def code_gen_string(self): return str(self)
##Retrieve region of sequences delimited by a forward and reverse pattern #v0.0.1 f = [ [x.split('\n')[0], ''.join(x.split('\n')[1:])] for x in open('gg-13-8-99.fasta', 'r').read().rstrip('\n').split('>') ][1:] fw = ['AGAGTTTGATCMTGGCTCAG'] rv = ['GWATTACCGCGGCKGCTG'] mtol = 1 endstr = 3 w = open('ggmb.fa', 'w') nl = [] print('Forward:' + fw[0]) print('Reverse:' + rv[0]) print('Mismatches tolerated:' + str(mtol)) print('3\' end stringency length:' + str(endstr)) def degenerate(primer): r = [] for it in primer: p = list(it) for i in range(len(p)): if p[i] == 'R': r.append(''.join([p[x] if x!=i else 'A' for x in range(len(p))])) r.append(''.join([p[x] if x!=i else 'G' for x in range(len(p))])) break if p[i] == 'Y': r.append(''.join([p[x] if x!=i else 'C' for x in range(len(p))])) r.append(''.join([p[x] if x!=i else 'T' for x in range(len(p))])) break if p[i] == 'S': r.append(''.join([p[x] if x!=i else 'G' for x in range(len(p))])) r.append(''.join([p[x] if x!=i else 'C' for x in range(len(p))])) break if p[i] == 'W': r.append(''.join([p[x] if x!=i else 'A' for x in range(len(p))])) r.append(''.join([p[x] if x!=i else 'T' for x in range(len(p))])) break if p[i] == 'K': r.append(''.join([p[x] if x!=i else 'G' for x in range(len(p))])) r.append(''.join([p[x] if x!=i else 'T' for x in range(len(p))])) break if p[i] == 'M': r.append(''.join([p[x] if x!=i else 'A' for x in range(len(p))])) r.append(''.join([p[x] if x!=i else 'C' for x in range(len(p))])) break if p[i] == 'B': r.append(''.join([p[x] if x!=i else 'C' for x in range(len(p))])) r.append(''.join([p[x] if x!=i else 'G' for x in range(len(p))])) r.append(''.join([p[x] if x!=i else 'T' for x in range(len(p))])) break if p[i] == 'D': r.append(''.join([p[x] if x!=i else 'A' for x in range(len(p))])) r.append(''.join([p[x] if x!=i else 'G' for x in range(len(p))])) r.append(''.join([p[x] if x!=i else 'T' for x in range(len(p))])) break if p[i] == 'H': r.append(''.join([p[x] if x!=i else 'A' for x in range(len(p))])) r.append(''.join([p[x] if x!=i else 'C' for x in range(len(p))])) r.append(''.join([p[x] if x!=i else 'T' for x in range(len(p))])) break if p[i] == 'V': r.append(''.join([p[x] if x!=i else 'A' for x in range(len(p))])) r.append(''.join([p[x] if x!=i else 'C' for x in range(len(p))])) r.append(''.join([p[x] if x!=i else 'G' for x in range(len(p))])) break if p[i] == 'N': r.append(''.join([p[x] if x!=i else 'A' for x in range(len(p))])) r.append(''.join([p[x] if x!=i else 'C' for x in range(len(p))])) r.append(''.join([p[x] if x!=i else 'G' for x in range(len(p))])) r.append(''.join([p[x] if x!=i else 'T' for x in range(len(p))])) break return r def mismatch(primer): r = [] for it in primer: p = list(it) for i in range(len(p) - endstr): r.append(''.join([p[x] if x!=i else 'A' for x in range(len(p))])) r.append(''.join([p[x] if x!=i else 'C' for x in range(len(p))])) r.append(''.join([p[x] if x!=i else 'G' for x in range(len(p))])) r.append(''.join([p[x] if x!=i else 'T' for x in range(len(p))])) return r a = ['A','C','G','T'] fwndeg = len([x for x in list(fw[0])if x not in a]) rvndeg = len([x for x in list(rv[0])if x not in a]) for i in range(fwndeg): fw = degenerate(fw) for i in range(rvndeg): rv = degenerate(rv) for i in range(mtol): fw = mismatch(fw) rv = mismatch(rv) rv = [ x[::-1].replace('A','t').replace('C','g').replace('G','c').replace('T','a').upper() for x in rv ] for it in f: rt = '' cut = 0 for i in range(len(it[1])-len(fw[0])): if it[1][i:i+len(fw[0])] in fw: rt = it[1][i:] cut += 0 break for i in range(len(rt)-len(rv[0])): if rt[i:i+len(rv[0])] in rv: rt = rt[:i+len(rv[0])] cut += 2 break if cut == 2: nl.append([it[0], rt]) lnl = [len(x[1]) for x in nl] print('Matches:' + str(len(nl))+ '/' + str(len(f))) print('Min:' + str(min(lnl))) print('Max:' + str(max(lnl))) print('Mean:' + str(sum(lnl) / len(nl))) print('Matches shorter than 300:' + str(len([x for x in lnl if x < 300]))) print('Matches longer than 580:' + str(len([x for x in lnl if x > 580]))) w.write('\n'.join(['>' + '\n'.join(x) for x in nl])) w.close()
def say(message, times = 1): print(message * times) say('Hello', 4) say('World', 4) def func(a, b=5, c=10): print('a is', a, 'and b is', b, 'and c is', c) func(3) func(3, c=13) def maximum(x, y): if x > y: return x elif x == y: return 'The numbers are equal' else: return y a = maximum(2, 3) + 5 print(a)