content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
palavra = ('Curso', 'Video', 'Python') qualPalavra = 0 qualLetra = 0 while True: if palavra[qualPalavra][qualLetra] in 'AaEeIiOoUu': print(palavra[qualPalavra])
palavra = ('Curso', 'Video', 'Python') qual_palavra = 0 qual_letra = 0 while True: if palavra[qualPalavra][qualLetra] in 'AaEeIiOoUu': print(palavra[qualPalavra])
def to_batch_seq(batch): q_seq = [] history = [] label = [] for item in batch: q_seq.append(item['question_tokens']) history.append(item["history"]) label.append(item["label"]) return q_seq, history, label # CHANGED def to_batch_tables(batch, table_type): # col_lens = [...
def to_batch_seq(batch): q_seq = [] history = [] label = [] for item in batch: q_seq.append(item['question_tokens']) history.append(item['history']) label.append(item['label']) return (q_seq, history, label) def to_batch_tables(batch, table_type): col_seq = [] tname_...
def horn(coefs, x0): n = len(coefs) b = coefs[0] for index in range(1,n): b = coefs[index] + b * x0 return b j=horn([2,2,3,-21,8],8) print(j)
def horn(coefs, x0): n = len(coefs) b = coefs[0] for index in range(1, n): b = coefs[index] + b * x0 return b j = horn([2, 2, 3, -21, 8], 8) print(j)
class TradingDayData: def __init__(self, pricebars, tradingday): self.__pricebars = pricebars self.__tradingday = tradingday @property def price_bars(self): return self.__pricebars
class Tradingdaydata: def __init__(self, pricebars, tradingday): self.__pricebars = pricebars self.__tradingday = tradingday @property def price_bars(self): return self.__pricebars
# MEDIUM # since this is looking for permutation, the Time would be O(N!) # 1. first check if the input can form a palindrome => only <=1 odd occured char can used # 2. only permutate the half of the input == permutation II # eg. input = "aabb" # only permutate ["a","b"], append reversed(input) to the end ...
class Solution: def generate_palindromes(self, s: str) -> List[str]: check = [0] * 128 half = [0] * (len(s) // 2) if not self.canPalin(s, check): return [] k = 0 ch = 0 for i in range(128): if check[i] % 2 == 1: ch = chr(i) ...
''' Created on 15 May 2018 @author: igoroya ''' def read_text(file_path): my_file = open(file_path, 'r', encoding="utf-8") text = my_file.read() my_file.close() return text def print_text(text): print(text) def get_lines(text): return text.split("\n") def get_words(text): words = [] ...
""" Created on 15 May 2018 @author: igoroya """ def read_text(file_path): my_file = open(file_path, 'r', encoding='utf-8') text = my_file.read() my_file.close() return text def print_text(text): print(text) def get_lines(text): return text.split('\n') def get_words(text): words = [] ...
class Solution: def isSubsequence(self, s: str, t: str) -> bool: if not s: return True m, n = 0, len(s) - 1 i, j = 0, len(t) - 1 while i <= j and m <= n: if t[i] == s[m]: m += 1 i += 1 else: i += 1 ...
class Solution: def is_subsequence(self, s: str, t: str) -> bool: if not s: return True (m, n) = (0, len(s) - 1) (i, j) = (0, len(t) - 1) while i <= j and m <= n: if t[i] == s[m]: m += 1 i += 1 else: ...
def even(n): return n/2 def odd(n): return (3*n)+1 if __name__ == '__main__': appeared = [] z = 0 x = 0 for i in range(1,1000000): y = 0 a = i while a != 1: if i not in appeared: if a % 2 == 0: a = even(a...
def even(n): return n / 2 def odd(n): return 3 * n + 1 if __name__ == '__main__': appeared = [] z = 0 x = 0 for i in range(1, 1000000): y = 0 a = i while a != 1: if i not in appeared: if a % 2 == 0: a = even(a) ...
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") def arm_toolchains_repositories(): rules_pkg() org_linaro_components_toolchain_gcc_5_3_1() raspi_components_toolchain_gcc_4_8_3() def org_linaro_components_toolchain_gcc_5_3_1(): http_archive( name = 'org_linaro_components_to...
load('@bazel_tools//tools/build_defs/repo:http.bzl', 'http_archive') def arm_toolchains_repositories(): rules_pkg() org_linaro_components_toolchain_gcc_5_3_1() raspi_components_toolchain_gcc_4_8_3() def org_linaro_components_toolchain_gcc_5_3_1(): http_archive(name='org_linaro_components_toolchain_gcc...
class Solution: def solve(self, a, b): def bin_sum(x,y,c): x = int(x) y = int(y) c = int(c) si = (x+y+c)%2 c = (x+y+c)//2 if c: c = 1 return str(si),str(c) n , m = len(a),len(b) ...
class Solution: def solve(self, a, b): def bin_sum(x, y, c): x = int(x) y = int(y) c = int(c) si = (x + y + c) % 2 c = (x + y + c) // 2 if c: c = 1 return (str(si), str(c)) (n, m) = (len(a), len(b))...
# Copyright 2009-2017 Ram Rachum. # This program is distributed under the MIT license. '''Defines exceptions.''' class CuteBaseException(BaseException): ''' Base exception that uses its first docstring line in lieu of a message. ''' def __init__(self, message=None): # We use `None` as the de...
"""Defines exceptions.""" class Cutebaseexception(BaseException): """ Base exception that uses its first docstring line in lieu of a message. """ def __init__(self, message=None): if message is None: if self.__doc__ and type(self) not in (CuteBaseException, CuteException): ...
class RoutingRulesList: TITLE = "Maintain case routing rules" CREATE_BUTTON = "Create new routing rule" NO_CONTENT_NOTICE = "There are no registered routing rules at the moment." ACTIVE = "Active" DEACTIVATED = "Deactivated" DEACTIVATE = "Deactivate" REACTIVATE = "Reactivate" EDIT = "Edi...
class Routingruleslist: title = 'Maintain case routing rules' create_button = 'Create new routing rule' no_content_notice = 'There are no registered routing rules at the moment.' active = 'Active' deactivated = 'Deactivated' deactivate = 'Deactivate' reactivate = 'Reactivate' edit = 'Edi...
__all__ = ["_nsgroup", "association_api", "association_service_api", "codesystem_api", "codesystem_service_api", "codesystemversion_api", "codesystemversion_service_api", "conceptdomain_api", "conceptdomain_service_api", "conceptdomainbinding_api", "conceptdomainbinding_service_api", "c...
__all__ = ['_nsgroup', 'association_api', 'association_service_api', 'codesystem_api', 'codesystem_service_api', 'codesystemversion_api', 'codesystemversion_service_api', 'conceptdomain_api', 'conceptdomain_service_api', 'conceptdomainbinding_api', 'conceptdomainbinding_service_api', 'core_api', 'core_service_api', 'en...
# webex integration credentials webex_integration_client_id = "" webex_integration_client_secret= "" webex_integration_redirect_uri = "http://localhost:5000/webexoauth" webex_integration_scope = "spark:all meeting:schedules_write"
webex_integration_client_id = '' webex_integration_client_secret = '' webex_integration_redirect_uri = 'http://localhost:5000/webexoauth' webex_integration_scope = 'spark:all meeting:schedules_write'
# Advent of Code - Day 6 - Part Two class LanterFishPopulation: def __init__(self, initial_state): self.population = initial_state def tick(self, reset, gestation): spawn_count = self.population[0] # decrement all lantern fish timers for k in self.population.keys(): ...
class Lanterfishpopulation: def __init__(self, initial_state): self.population = initial_state def tick(self, reset, gestation): spawn_count = self.population[0] for k in self.population.keys(): if k < gestation: self.population[k] = self.population[k + 1] ...
nombreACalculer = str(2**1000) somme=0 for i in nombreACalculer: somme += int(i) print(somme) input()
nombre_a_calculer = str(2 ** 1000) somme = 0 for i in nombreACalculer: somme += int(i) print(somme) input()
# -------------- print(bool) # -------------- print(bool)
print(bool) print(bool)
class Solution: def nextClosestTime(self, time): t = sorted(set(time))[:-1] nex = {a: b for a, b in zip(t, t[1:])} for i, d in enumerate(time[::-1]): if d in nex: if i == 0: return time[:4] + nex[d] elif i == 1 and nex[d] < '6...
class Solution: def next_closest_time(self, time): t = sorted(set(time))[:-1] nex = {a: b for (a, b) in zip(t, t[1:])} for (i, d) in enumerate(time[::-1]): if d in nex: if i == 0: return time[:4] + nex[d] elif i == 1 and nex[d]...
class Solution: #Function to return a list containing the DFS traversal of the graph. def dfs(self,i,vis,q,adj): vis[i]=1 q.append(i) for i in adj[i]: if(vis[i]==0): self.dfs(i,vis,q,adj) def dfsOfGraph(self, V, adj): vis=[0 for i in...
class Solution: def dfs(self, i, vis, q, adj): vis[i] = 1 q.append(i) for i in adj[i]: if vis[i] == 0: self.dfs(i, vis, q, adj) def dfs_of_graph(self, V, adj): vis = [0 for i in range(V)] q = [] self.dfs(0, vis, q, adj) return...
# -*- coding: utf-8 -*- timeout = 8 keysize = 512 operator_root_path="/api/1.2" operator_cr_path="/cr" operator_slr_path="/slr" account_management_url="http://myaccount.dy.fi/" account_management_username="test_sdk" account_management_password="test_sdk_pw" operator_url="http://localhost:5000" service_url ="http://...
timeout = 8 keysize = 512 operator_root_path = '/api/1.2' operator_cr_path = '/cr' operator_slr_path = '/slr' account_management_url = 'http://myaccount.dy.fi/' account_management_username = 'test_sdk' account_management_password = 'test_sdk_pw' operator_url = 'http://localhost:5000' service_url = 'http://localhost:200...
def in1to10(n, outside_mode): if not outside_mode and n>=1 and n<=10: return True elif outside_mode: if n<=1 or n>=10: return True else: return False else: return False
def in1to10(n, outside_mode): if not outside_mode and n >= 1 and (n <= 10): return True elif outside_mode: if n <= 1 or n >= 10: return True else: return False else: return False
''' Serialize objects into SQLITE database calls. ''' class Serializable: ''' Serializable class that implements methods for objects wishing to serialize to SQLITE tables. This is done with a serialize table that maps property names to SQLITE table columns. When insert_into is called it takes the prop...
""" Serialize objects into SQLITE database calls. """ class Serializable: """ Serializable class that implements methods for objects wishing to serialize to SQLITE tables. This is done with a serialize table that maps property names to SQLITE table columns. When insert_into is called it takes the prope...
#!/usr/bin/env python3 SLIDE_WINDOWS = 3 f = open("input.txt", "r") window = [] for i in range(SLIDE_WINDOWS): window.append(int(f.readline())) count = 0 for cur in f: #print(f'current: {cur}') window.append(int(cur)) if sum(window[1:]) > sum(window[0:-1]): count +=1 window.pop(0) print(...
slide_windows = 3 f = open('input.txt', 'r') window = [] for i in range(SLIDE_WINDOWS): window.append(int(f.readline())) count = 0 for cur in f: window.append(int(cur)) if sum(window[1:]) > sum(window[0:-1]): count += 1 window.pop(0) print(f'increase: {count}')
def scale_01(feature,n_feature): for i in range(n_feature): feature_i=feature[:,i] feature[:,i]=0+(feature_i-min(feature_i))/(max(feature_i)-min(feature_i)) return feature
def scale_01(feature, n_feature): for i in range(n_feature): feature_i = feature[:, i] feature[:, i] = 0 + (feature_i - min(feature_i)) / (max(feature_i) - min(feature_i)) return feature
class DriverBase(object): def __init__(self, wheel_radius=0.06, wheel_track=0.33): self.wheel_speeds = [0.0, 0.0, 0.0, 0.0] self.wheel_radius = wheel_radius self.wheel_track = wheel_track def set_motors(self, linear, angular): raise NotImplementedError() class DriverStraight...
class Driverbase(object): def __init__(self, wheel_radius=0.06, wheel_track=0.33): self.wheel_speeds = [0.0, 0.0, 0.0, 0.0] self.wheel_radius = wheel_radius self.wheel_track = wheel_track def set_motors(self, linear, angular): raise not_implemented_error() class Driverstraight...
# -*- coding: utf-8 -*- # # Custom package settings # # Copyright (C) # Honda Research Institute Europe GmbH # Carl-Legien-Str. 30 # 63073 Offenbach/Main # Germany # # UNPUBLISHED PROPRIETARY MATERIAL. # ALL RIGHTS RESERVED. # # name = 'ToolBOSCore' package = 'ToolBOSCore' version ...
name = 'ToolBOSCore' package = 'ToolBOSCore' version = '4.0' section = 'DevelopmentTools' category = 'DevelopmentTools' patchlevel = 0 maintainer = ('mstein', 'Marijke Stein') git_branch = 'TBCORE-2231-GitLabCI' git_commit_id = '020950dfc0913a1a18b80335f25dd7b1335b0d48' git_origin = 'https://github.com/HRI-EU/ToolBOSCo...
INSTALLED_APPS = ( 'automatica_prometheus', ) TELEGRAM_BOT_NAME = 'name_bot'
installed_apps = ('automatica_prometheus',) telegram_bot_name = 'name_bot'
#Exercise 5.2.1 def check_fermat(a,b,c,n): a = int(a) b = int(b) c = int(c) n = int(n) if n>2 and a>0 and b>0 and c>0 and a**n + b**n == c**n: print('Holy smokes, Fermat was wrong!') else: print("No, that doesn't work") #Exercise 5.2.2 def prompting_fermat(): a = int(input('...
def check_fermat(a, b, c, n): a = int(a) b = int(b) c = int(c) n = int(n) if n > 2 and a > 0 and (b > 0) and (c > 0) and (a ** n + b ** n == c ** n): print('Holy smokes, Fermat was wrong!') else: print("No, that doesn't work") def prompting_fermat(): a = int(input('Type a an...
a,b,c=map(int,input().split()) x,d=0,0 while x<c: d+=1 x+=a if d%7==0: x+=b print(d)
(a, b, c) = map(int, input().split()) (x, d) = (0, 0) while x < c: d += 1 x += a if d % 7 == 0: x += b print(d)
load("//csharp:csharp_grpc_compile.bzl", "csharp_grpc_compile") load("//:compile.bzl", "invoke_transitive") load("@io_bazel_rules_dotnet//dotnet:defs.bzl", "core_library") def csharp_grpc_library(**kwargs): kwargs["srcs"] = [invoke_transitive(csharp_grpc_compile, "_pb", kwargs)] kwargs["deps"] = [ "...
load('//csharp:csharp_grpc_compile.bzl', 'csharp_grpc_compile') load('//:compile.bzl', 'invoke_transitive') load('@io_bazel_rules_dotnet//dotnet:defs.bzl', 'core_library') def csharp_grpc_library(**kwargs): kwargs['srcs'] = [invoke_transitive(csharp_grpc_compile, '_pb', kwargs)] kwargs['deps'] = ['@google.prot...
class TrieNode: def __init__(self): self.children = [None] * 26 self.isEndOfWord = False class Trie: def __init__(self): self.root_node = self.TrieNode() def getNewNode(self): return TrieNode() def char_to_index(self, char): return ord(char) - ord('a') ...
class Trienode: def __init__(self): self.children = [None] * 26 self.isEndOfWord = False class Trie: def __init__(self): self.root_node = self.TrieNode() def get_new_node(self): return trie_node() def char_to_index(self, char): return ord(char) - ord('a') ...
def reverseWords(string: str) -> str: words = " ".join(string.split()) words = [word for word in words.split(' ')] left, right = 0, len(words) - 1 while left < right: temp = words[left] words[left] = words[right] words[right] = temp left += 1 right -= 1 ...
def reverse_words(string: str) -> str: words = ' '.join(string.split()) words = [word for word in words.split(' ')] (left, right) = (0, len(words) - 1) while left < right: temp = words[left] words[left] = words[right] words[right] = temp left += 1 right -= 1 r...
bind = "0.0.0.0:5000" workers = 1 worker_class = "eventlet" reload = True
bind = '0.0.0.0:5000' workers = 1 worker_class = 'eventlet' reload = True
class Timespan: def __init__( self, days: int = 0, hours: int = 0, minutes: int = 0, seconds: int = 0, milliseconds: int = 0): conv_days = days * 3600 * 24 * 1000 conv_hours = hours * 3600000 conv_minutes = minutes * 60...
class Timespan: def __init__(self, days: int=0, hours: int=0, minutes: int=0, seconds: int=0, milliseconds: int=0): conv_days = days * 3600 * 24 * 1000 conv_hours = hours * 3600000 conv_minutes = minutes * 60000 conv_seconds = seconds * 1000 self._time = conv_days + conv_hou...
def merge(alist): if len(alist) > 1: mid = len(alist)//2 left = alist[:mid] right = alist[mid:] merge(left) merge(right) i,j,k = 0, 0, 0 while i<len(left) and j<len(right): if left[i]<right[j]: alist[k] = left[i] i...
def merge(alist): if len(alist) > 1: mid = len(alist) // 2 left = alist[:mid] right = alist[mid:] merge(left) merge(right) (i, j, k) = (0, 0, 0) while i < len(left) and j < len(right): if left[i] < right[j]: alist[k] = left[i] ...
class MACAddress: @staticmethod def isValid(macAddress): sanitizedMACAddress = macAddress.strip().upper() if sanitizedMACAddress == "": return False # Ensure that we have 6 sections items = sanitizedMACAddress.split(":") if len(items) != 6: return...
class Macaddress: @staticmethod def is_valid(macAddress): sanitized_mac_address = macAddress.strip().upper() if sanitizedMACAddress == '': return False items = sanitizedMACAddress.split(':') if len(items) != 6: return False for section in items: ...
# GYP file to build experimental directory. { 'targets': [ { 'target_name': 'experimental', 'type': 'static_library', 'include_dirs': [ '../include/config', '../include/core', ], 'sources': [ '../experimental/SkSetPoly3To3.cpp', '../experimental/SkSetP...
{'targets': [{'target_name': 'experimental', 'type': 'static_library', 'include_dirs': ['../include/config', '../include/core'], 'sources': ['../experimental/SkSetPoly3To3.cpp', '../experimental/SkSetPoly3To3_A.cpp', '../experimental/SkSetPoly3To3_D.cpp'], 'direct_dependent_settings': {'include_dirs': ['../experimental...
# N stands for North # S stands for south # E stands for east # W stands for west #Oeste es West y Este es East #NoSe == NWSE North and South are opposites, so are West and East # N # | # W---+--E # | # S # L stands for Left # R stands for right # F sta...
with open('E:\\code\\AoC\\day12\\input.txt', 'r') as input: instructions = input.read().split('\n') def degrees_to_position(action, degrees): if degrees == 90: if action == 'L': return 1 else: return -1 elif degrees == 180: return 2 elif action == 'L': ...
def divisors_count(n): count = 0 for i in range(1, n+1): if (n % i) == 0: count += 1 return count def triangulate(n): y = [int(x) for x in list(str(n))] return sum(y) triangle = 1 while divisors_count(triangle) <= 500: triangle += triangulate(triangle) print(triangle)
def divisors_count(n): count = 0 for i in range(1, n + 1): if n % i == 0: count += 1 return count def triangulate(n): y = [int(x) for x in list(str(n))] return sum(y) triangle = 1 while divisors_count(triangle) <= 500: triangle += triangulate(triangle) print(triangle)
class Solution: def countElements(self, nums: List[int]) -> int: nums.sort() k=0 for i in nums: if i+1 in nums: k=k+1 return k
class Solution: def count_elements(self, nums: List[int]) -> int: nums.sort() k = 0 for i in nums: if i + 1 in nums: k = k + 1 return k
# -*- coding: utf-8 -*- N = int(input()) answer = " ".join(["Ho"] * N) + "!" print(answer)
n = int(input()) answer = ' '.join(['Ho'] * N) + '!' print(answer)
for _ in range(int(input())): n,k=map(int,input().split()) a=bin(k)[2:] a=str(a) a=a.zfill(n) a=a[::-1] print(int(a,2))
for _ in range(int(input())): (n, k) = map(int, input().split()) a = bin(k)[2:] a = str(a) a = a.zfill(n) a = a[::-1] print(int(a, 2))
# -*- coding: utf-8 -*- ''' This module contains basic form access control classes. You can set permissions to form and fields like this:: class SampleForm(form.Form): permissions = 'rwcx' fields=[fields.Field('input', permissions='rw')] or define your own permission log...
""" This module contains basic form access control classes. You can set permissions to form and fields like this:: class SampleForm(form.Form): permissions = 'rwcx' fields=[fields.Field('input', permissions='rw')] or define your own permission logic:: class SampleFo...
# WAP in python to check the given year is leap or not. year=int(input("Enter Year: ")) if year % 4 == 0: if year % 100 == 0: if year % 400 == 0: print("{0} is a leap year".format(year)) else: print("{0} is not a leap year".format(year)) else: print("{0} is a le...
year = int(input('Enter Year: ')) if year % 4 == 0: if year % 100 == 0: if year % 400 == 0: print('{0} is a leap year'.format(year)) else: print('{0} is not a leap year'.format(year)) else: print('{0} is a leap year'.format(year)) else: print('{0} is not a lea...
def power(n, m): if m == 0: return 1 elif m == 1: return n return (n*power(n, m-1)) print(power(2,3))
def power(n, m): if m == 0: return 1 elif m == 1: return n return n * power(n, m - 1) print(power(2, 3))
def convert_to_strsid(binsid): if len(binsid) < 24: return None dashes = int(binsid[2:4]) list_sid = ["S", "1"] range_parts = range(16, dashes*8+16, 8) list_sid.append(str(int(binsid[4:16], 16))) for i in range_parts: list_sid.append(str(int(invert_endian(binsid[i:i+8]), 16))) ...
def convert_to_strsid(binsid): if len(binsid) < 24: return None dashes = int(binsid[2:4]) list_sid = ['S', '1'] range_parts = range(16, dashes * 8 + 16, 8) list_sid.append(str(int(binsid[4:16], 16))) for i in range_parts: list_sid.append(str(int(invert_endian(binsid[i:i + 8]), 16...
# global settings data_root = "../../data/winequality_dataset/" feature_save_dir = data_root + "features/" img_save_dir = data_root + "imgs/" # split chunk settings split_chunk_path = data_root + 'chunk/' raw_train_file = dict( file_path=data_root + 'raw_data/train.csv', size=3397, split_mode=['train', 'va...
data_root = '../../data/winequality_dataset/' feature_save_dir = data_root + 'features/' img_save_dir = data_root + 'imgs/' split_chunk_path = data_root + 'chunk/' raw_train_file = dict(file_path=data_root + 'raw_data/train.csv', size=3397, split_mode=['train', 'valA', 'valB'], split_ratio=[0.6, 0.2, 0.2], chunk_size=2...
Import("env") src_filter = ["+<TRB_MCP23017.h>"] env.Replace(SRC_FILTER=src_filter) build_flags = env.ParseFlags(env['BUILD_FLAGS']) cppdefines = build_flags.get("CPPDEFINES") if "TRB_MCP23017_ESP_IDF" in cppdefines: env.Append(SRC_FILTER=["+<TRB_MCP23017.c>", "+<sys/esp_idf>"]) if "TRB_MCP23017_ARDUINO_WIRE" in ...
import('env') src_filter = ['+<TRB_MCP23017.h>'] env.Replace(SRC_FILTER=src_filter) build_flags = env.ParseFlags(env['BUILD_FLAGS']) cppdefines = build_flags.get('CPPDEFINES') if 'TRB_MCP23017_ESP_IDF' in cppdefines: env.Append(SRC_FILTER=['+<TRB_MCP23017.c>', '+<sys/esp_idf>']) if 'TRB_MCP23017_ARDUINO_WIRE' in cp...
SEQUENCE_FILE = "data\\test_action_20_maxSeq15_20K.txt" CRASH_INDEX = "1" # SEQUENCE_FILE = "data\\activityseq_balanced_2018-02-05_2018-02-09_Excel_apphangb1_Production.tsv" # SEQUENCE_FILE = r"C:\Users\mahajiag\Documents\tmp\crash\eventseq_balanced_2018-02-05_2018-02-09_Excel_apphangb1_Production.tsv" ROOT_DIR = 'tf...
sequence_file = 'data\\test_action_20_maxSeq15_20K.txt' crash_index = '1' root_dir = 'tfboard' actions_to_be_filtered = [''] configs = {'batchSize': 512, 'maxSeqSize': 17, 'testSplit': 0.5, 'embeddingSize': None, 'epochs': 250, 'dedup': 1, 'conv1D': 0, 'lstmSize': None, 'testFlag': True, 'p2nRatio': 1, 'networkType': '...
major_colors = ["White", "Red", "Black", "Yellow", "Violet"] minor_colors = ["Blue", "Orange", "Green", "Brown", "Slate"] def color_mapping(): cp_rows = [] for i, major_color in enumerate(major_colors): for j, minor_color in enumerate(minor_colors): print_color_map((i * 5 + j)+1 ...
major_colors = ['White', 'Red', 'Black', 'Yellow', 'Violet'] minor_colors = ['Blue', 'Orange', 'Green', 'Brown', 'Slate'] def color_mapping(): cp_rows = [] for (i, major_color) in enumerate(major_colors): for (j, minor_color) in enumerate(minor_colors): print_color_map(i * 5 + j + 1, major_...
''' Nd Genie Ops Object Outputs for IOSXR. ''' class NdOutput(object): ShowIpv6Neighbors = { 'interfaces': { 'GigabitEthernet0/0/0/0.90': { 'interface': 'Gi0/0/0/0.90', 'neighbors': { 'fe80::f816:3eff:fe26:1224': { ...
""" Nd Genie Ops Object Outputs for IOSXR. """ class Ndoutput(object): show_ipv6_neighbors = {'interfaces': {'GigabitEthernet0/0/0/0.90': {'interface': 'Gi0/0/0/0.90', 'neighbors': {'fe80::f816:3eff:fe26:1224': {'age': '131', 'ip': 'fe80::f816:3eff:fe26:1224', 'link_layer_address': 'fa16.3e26.1224', 'neighbor_sta...
def solution(): sum = 0 for i in range(0,1000): if i % 3 == 0 or i % 5 == 0: sum += i return sum def test_MultiplesOf3And5(): assert solution() == 233168
def solution(): sum = 0 for i in range(0, 1000): if i % 3 == 0 or i % 5 == 0: sum += i return sum def test__multiples_of3_and5(): assert solution() == 233168
__all__ = ["__version__", "__version_info__"] __version__ = "0.0.3" __version_info__ = tuple(int(x) for x in __version__.split("."))
__all__ = ['__version__', '__version_info__'] __version__ = '0.0.3' __version_info__ = tuple((int(x) for x in __version__.split('.')))
@bot.message_handler(commands=['start', 'help']) def send_welcome(message): userid = message.from_user.id banlist = redisserver.sismember('zigzag_banlist', '{}'.format(userid)) if banlist: bot.reply_to(message, "You are banned!") return markup = types.ReplyKeyboardMarkup() numbers = list(range(3, 300...
@bot.message_handler(commands=['start', 'help']) def send_welcome(message): userid = message.from_user.id banlist = redisserver.sismember('zigzag_banlist', '{}'.format(userid)) if banlist: bot.reply_to(message, 'You are banned!') return markup = types.ReplyKeyboardMarkup() numbers = ...
src = Split(''' uart_test.c ''') component = aos_component('uart_test', src) component.add_cflags('-Wall') component.add_cflags('-Werror')
src = split('\n uart_test.c\n') component = aos_component('uart_test', src) component.add_cflags('-Wall') component.add_cflags('-Werror')
#Helpfer Function: def create_scoring_schema(number_objects): _field = "id*:int64,image:blob,_image_:blob,_nObjects_:double," for obj in range(0,number_objects): _field += "_Object" + str(obj) + "_:string," _field += "_P_Object" + str(obj) + "_:double," _field += "_Object" + str(obj) + "...
def create_scoring_schema(number_objects): _field = 'id*:int64,image:blob,_image_:blob,_nObjects_:double,' for obj in range(0, number_objects): _field += '_Object' + str(obj) + '_:string,' _field += '_P_Object' + str(obj) + '_:double,' _field += '_Object' + str(obj) + '_x:double,' ...
def load(): with open("input") as f: return [int(x) for x in f.read().strip().split(",")] def align_crabs(): crabs = load() min_fuel = None for pos in range(min(crabs), max(crabs) + 1): fuel = sum(abs(c - pos) for c in crabs) min_fuel = fuel if min_fuel is None else min(min_fu...
def load(): with open('input') as f: return [int(x) for x in f.read().strip().split(',')] def align_crabs(): crabs = load() min_fuel = None for pos in range(min(crabs), max(crabs) + 1): fuel = sum((abs(c - pos) for c in crabs)) min_fuel = fuel if min_fuel is None else min(min_fu...
a = [ 1, 2, 3, 6, 10, 14, ] t = 10 l = 0 r = len(a) - 1 while l != r: c = (l + r) // 2 if a[c] < t: l = c + 1 elif a[c] > t: r = c - 1 else: r = l = c print(l, r, a[l], a[r])
a = [1, 2, 3, 6, 10, 14] t = 10 l = 0 r = len(a) - 1 while l != r: c = (l + r) // 2 if a[c] < t: l = c + 1 elif a[c] > t: r = c - 1 else: r = l = c print(l, r, a[l], a[r])
# Runtime: 1007 ms, faster than 66.76% of Python3 online submissions for 3Sum. # Memory Usage: 18.1 MB, less than 38.93% of Python3 online submissions for 3Sum. class Solution: def threeSum(self, nums: List[int]) -> List[List[int]]: nums = sorted(nums) res = [] for i in range(len(nums)): ...
class Solution: def three_sum(self, nums: List[int]) -> List[List[int]]: nums = sorted(nums) res = [] for i in range(len(nums)): if nums[i] > 0: return res elif i == 0 or nums[i] != nums[i - 1]: hi = len(nums) - 1 lo = ...
# Adjusts numerical digits by a specified amount class Offsetter: # numericOffset is only altered by init numericOffset=0 def __init__(self, offset): self.numericOffset = int(offset) # apply offset def setOff(self, input_int): return (( int(input_int) + self.numericOffset ) % 10) # remov...
class Offsetter: numeric_offset = 0 def __init__(self, offset): self.numericOffset = int(offset) def set_off(self, input_int): return (int(input_int) + self.numericOffset) % 10 def set_on(self, input_int): return (input_int + (10 - self.numericOffset)) % 10 def string_off...
## Sum of Intervals ## 4 kyu ## https://www.codewars.com/kata/52b7ed099cdc285c300001cd def sum_of_intervals(intervals): seen = set() for (low,high) in intervals: for length in range(low, high): seen.add(length) return len(seen)
def sum_of_intervals(intervals): seen = set() for (low, high) in intervals: for length in range(low, high): seen.add(length) return len(seen)
# https://leetcode.com/problems/guess-number-higher-or-lower/ # We are playing the Guess Game. The game is as follows: # # I pick a number from 1 to n. You have to guess which number I picked. # # Every time you guess wrong, I'll tell you whether the number is higher or lower. # # You call a pre-defined API guess(int n...
def guess(num, x): pass class Solution(object): def guess_number(self, n): (begin, end) = (1, n) while True: cur_num = (begin + end) // 2 cur_bool = guess(curNum) if curBool == 1: end = curNum - 1 elif curBool == -1: ...
def isPalindrome(number): ispalindrome = True list = intToList(number) #if list is not an even number it can't be a palindrome if len(list) % 2 != 0: ispalindrome = False for x in range(0,int(len(list)/2)): if(ispalindrome): ispalindrome = (list[x] == list[len(list)-(x+...
def is_palindrome(number): ispalindrome = True list = int_to_list(number) if len(list) % 2 != 0: ispalindrome = False for x in range(0, int(len(list) / 2)): if ispalindrome: ispalindrome = list[x] == list[len(list) - (x + 1)] return ispalindrome def int_to_list(number): ...
sites = [ 'https://yii2-menu.pceuropa.net/', 'https://pceuropa.net', ] smtp = { 'server': 'smtp@example.com:587', 'login': 'info@example.com', 'password': 'pass', 'From': 'info@example.com', 'to': 'info@example.com', }
sites = ['https://yii2-menu.pceuropa.net/', 'https://pceuropa.net'] smtp = {'server': 'smtp@example.com:587', 'login': 'info@example.com', 'password': 'pass', 'From': 'info@example.com', 'to': 'info@example.com'}
broker_url = 'amqp://guest:guest@localhost:5672//' accept_content = ['application/json'] result_serializer = 'pickle' task_serializer = 'pickle'
broker_url = 'amqp://guest:guest@localhost:5672//' accept_content = ['application/json'] result_serializer = 'pickle' task_serializer = 'pickle'
word = "bottles" for beer_num in range(99, 0, -1): print(beer_num, word, " of beer on the wall,") print(beer_num, word, " bottles of beer.") print("You take one down,") print("You pass it around,") if (beer_num == 1): print("No more bottles of beer on the wall.") else: new_num =...
word = 'bottles' for beer_num in range(99, 0, -1): print(beer_num, word, ' of beer on the wall,') print(beer_num, word, ' bottles of beer.') print('You take one down,') print('You pass it around,') if beer_num == 1: print('No more bottles of beer on the wall.') else: new_num = be...
## Mel-filterbank mel_n_channels = 80 win_length = 512 hop_length = 128 n_fft = 512 mel_window_length = 25 # In milliseconds mel_window_step = 10 # In milliseconds ## Audio sampling_rate = 24000 # Number of spectrogram frames in a partial utterance partials_n_frames = 240 # 2400 ms # Number of spectrogram fra...
mel_n_channels = 80 win_length = 512 hop_length = 128 n_fft = 512 mel_window_length = 25 mel_window_step = 10 sampling_rate = 24000 partials_n_frames = 240 inference_n_frames = 120 vad_window_length = 20 vad_moving_average_width = 8 vad_max_silence_length = 6 audio_norm_target_d_bfs = -30
class CollapseRenderMixin: render_template = "djangocms_frontend/bootstrap5/collapse.html" class CollapseContainerRenderMixin: render_template = "djangocms_frontend/bootstrap5/collapse-container.html" def render(self, context, instance, placeholder): instance.add_classes("collapse") retur...
class Collapserendermixin: render_template = 'djangocms_frontend/bootstrap5/collapse.html' class Collapsecontainerrendermixin: render_template = 'djangocms_frontend/bootstrap5/collapse-container.html' def render(self, context, instance, placeholder): instance.add_classes('collapse') return...
# # PySNMP MIB module AtiL2-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/AtiL2-MIB # Produced by pysmi-0.3.4 at Wed May 1 11:33:22 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...
(object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_size_constraint, value_range_constraint, constraints_intersection, constraints_union, single_value_constraint) ...
TEST_CHANGES = { ('+1', '+1', '+1'): 3, ('+1', '+1', '-2'): 0, ('-1', '-2', '-3'): -6, } TEST_CHANGES_2 = { ('+1', '-1'): 0, ('+3', '+3', '+4', '-2', '-4'): 10, ('-6', '+3', '+8', '+5', '-6'): 5, ('+7', '+7', '-2', '-7', '-4'): 14, } def calibrate(deltas): frequency = 0 for delta i...
test_changes = {('+1', '+1', '+1'): 3, ('+1', '+1', '-2'): 0, ('-1', '-2', '-3'): -6} test_changes_2 = {('+1', '-1'): 0, ('+3', '+3', '+4', '-2', '-4'): 10, ('-6', '+3', '+8', '+5', '-6'): 5, ('+7', '+7', '-2', '-7', '-4'): 14} def calibrate(deltas): frequency = 0 for delta in deltas: frequency += int(...
class Solution: def reinitializePermutation(self, n: int) -> int: perm = [] for i in range(n): perm.append(i) def op(perm): arr = [0] * len(perm) for i in range(len(perm)): if i % 2 == 0: arr[i] = perm[int(i / 2)] ...
class Solution: def reinitialize_permutation(self, n: int) -> int: perm = [] for i in range(n): perm.append(i) def op(perm): arr = [0] * len(perm) for i in range(len(perm)): if i % 2 == 0: arr[i] = perm[int(i / 2)] ...
N = int(input()) C = [list(map(int, input().split())) for _ in range(N)] INF = 10 ** 18 a = INF i, j = 0, 0 for y in range(N): for x in range(N): if C[y][x] >= a: continue i, j = y, x a = C[y][x] def f(z): A = [INF] * N B = [INF] * N A[i] = z for x in range(N)...
n = int(input()) c = [list(map(int, input().split())) for _ in range(N)] inf = 10 ** 18 a = INF (i, j) = (0, 0) for y in range(N): for x in range(N): if C[y][x] >= a: continue (i, j) = (y, x) a = C[y][x] def f(z): a = [INF] * N b = [INF] * N A[i] = z for x in ran...
{ "targets": [ { "target_name": "lzh", "sources": [ "src/binding.cc", "src/lzh.c" ], "include_dirs": [ "<!(node -e \"require('nan')\")", "<!(node -e \"require('cpp-debug')\")" ] } ] }
{'targets': [{'target_name': 'lzh', 'sources': ['src/binding.cc', 'src/lzh.c'], 'include_dirs': ['<!(node -e "require(\'nan\')")', '<!(node -e "require(\'cpp-debug\')")']}]}
class TP_Texts: # __init__() init_error1 = "Start and End must be of type datetime.datetime!" init_error2 = "End must be larger than start!" # start() start_error1 = "Time must be of type datetime.datetime!" start_error2 = "start must be smaller than end of Time_Period!" # end() ...
class Tp_Texts: init_error1 = 'Start and End must be of type datetime.datetime!' init_error2 = 'End must be larger than start!' start_error1 = 'Time must be of type datetime.datetime!' start_error2 = 'start must be smaller than end of Time_Period!' end_error1 = 'end must be larger than start of Time...
# # PySNMP MIB module CISCO-OTV-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-OTV-MIB # Produced by pysmi-0.3.4 at Wed May 1 12:09:07 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 201...
(integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_range_constraint, constraints_intersection, single_value_constraint, value_size_constraint, constraints_union) ...
class ServerError(Exception): def __init__(self, details, model, response): self.details = details self.model = model self.response = response super(ServerError, self).__init__(self.details) def encode(self): return { "details": self.details, "exp...
class Servererror(Exception): def __init__(self, details, model, response): self.details = details self.model = model self.response = response super(ServerError, self).__init__(self.details) def encode(self): return {'details': self.details, 'expected': str(self.model),...
# Ariant Treasure Vault Entrance (915020100) => Ariant Treasure Vault if 2400 <= chr.getJob() <= 2412 and not sm.hasMobsInField(): sm.warp(915020101, 1) elif sm.hasMobsInField(): sm.chat("Eliminate all of the intruders first.")
if 2400 <= chr.getJob() <= 2412 and (not sm.hasMobsInField()): sm.warp(915020101, 1) elif sm.hasMobsInField(): sm.chat('Eliminate all of the intruders first.')
# Copyright (c) 2011 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. { 'targets': [ { 'target_name': 'libflac', 'product_name': 'flac', 'type': 'static_library', 'sources': [ 'include/...
{'targets': [{'target_name': 'libflac', 'product_name': 'flac', 'type': 'static_library', 'sources': ['include/FLAC/all.h', 'include/FLAC/assert.h', 'include/FLAC/callback.h', 'include/FLAC/export.h', 'include/FLAC/format.h', 'include/FLAC/metadata.h', 'include/FLAC/ordinals.h', 'include/FLAC/stream_decoder.h', 'includ...
class LUISEmulator(object): def __init__(self): self.name='luis' def normalise_request_json(self,data): _data = {} _data["text"]=data['q'][0] return _data def normalise_response_json(self,data): return { "query": data["text"], "topScoringInte...
class Luisemulator(object): def __init__(self): self.name = 'luis' def normalise_request_json(self, data): _data = {} _data['text'] = data['q'][0] return _data def normalise_response_json(self, data): return {'query': data['text'], 'topScoringIntent': {'intent': 'i...
def test_vm_reconfigured(controller, vm_service, vn_service, vmi_service, vrouter_port_service, vm_reconfigured_update): controller.handle_update(vm_reconfigured_update) vm_service.update_vm_models_interfaces.assert_called_once() vn_service.update_vns.assert_called_once() vmi_s...
def test_vm_reconfigured(controller, vm_service, vn_service, vmi_service, vrouter_port_service, vm_reconfigured_update): controller.handle_update(vm_reconfigured_update) vm_service.update_vm_models_interfaces.assert_called_once() vn_service.update_vns.assert_called_once() vmi_service.update_vmis.assert_...
with open('lexical.csv') as f: string=f.read() arr=string.split('\n') arr=arr[:10000] result='\n'.join(arr) with open('sub.csv','w') as f: f.write(result)
with open('lexical.csv') as f: string = f.read() arr = string.split('\n') arr = arr[:10000] result = '\n'.join(arr) with open('sub.csv', 'w') as f: f.write(result)
# program to restore the original string by entering the compressed string with this rule. However, # the # character does not appear in the restored character string. def restore_original_str(a1): result = "" ind = 0 end = len(a1) while ind < end: if a1[ind] == "#": result += a1[ind + 2] * int(a1[in...
def restore_original_str(a1): result = '' ind = 0 end = len(a1) while ind < end: if a1[ind] == '#': result += a1[ind + 2] * int(a1[ind + 1]) ind += 3 else: result += a1[ind] ind += 1 return result print('Original text:', 'XY#6Z1#4023') ...
def example2(n): h = lambda : print(n) return(h) ourfunc = example2(5) ourfunc()
def example2(n): h = lambda : print(n) return h ourfunc = example2(5) ourfunc()
# Outputs the sum of the range of all numbers from 1 to n. # Source: https://pynative.com/python-program-to-calculate-sum-and-average-of-numbers/ def main(): print("\n") input_string = input('Enter numbers separated by space ') print("\n") # Take input numbers into list numbers = input_string.spli...
def main(): print('\n') input_string = input('Enter numbers separated by space ') print('\n') numbers = input_string.split() for i in range(len(numbers)): numbers[i] = int(numbers[i]) print('Sum = ', sum(numbers)) print('Average = ', sum(numbers) / len(numbers)) if __name__ == '__mai...
# https://leetcode.com/problems/find-n-unique-integers-sum-up-to-zero/ class Solution: def sumZero(self, n: int) -> List[int]: res = [] if n % 2 == 0: for i in range(1, (n // 2) + 1): res.append(i) for i in range(-(n // 2), 0): res....
class Solution: def sum_zero(self, n: int) -> List[int]: res = [] if n % 2 == 0: for i in range(1, n // 2 + 1): res.append(i) for i in range(-(n // 2), 0): res.append(i) return res else: for i in range(1, n // 2...
# # PySNMP MIB module ARBOR-SMI (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ARBOR-SMI # Produced by pysmi-0.3.4 at Mon Apr 29 17:08:55 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...
(octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_range_constraint, value_size_constraint, constraints_union, constraints_intersection, single_value_constraint) ...
# default value from class context class A: FOO = 1 def foo(self, param=F<ref>OO): pass
class A: foo = 1 def foo(self, param=F < ref > OO): pass
class Solution: def climbStairs(self, n: int) -> int: if n == 1 or n == 0: return 1 prev, curr = 1, 1 for i in range(2, n + 1): temp = curr curr += prev prev = temp return curr
class Solution: def climb_stairs(self, n: int) -> int: if n == 1 or n == 0: return 1 (prev, curr) = (1, 1) for i in range(2, n + 1): temp = curr curr += prev prev = temp return curr
#Given two cells of a chessboard. If they are painted in one color, print the word YES, and if in a different color - NO. r = int(input("Row number of the first cell on Chessboard, r = ?")) if ((r > 8) or (r < 1)): print("Invalid row number for a Chessboard!") exit() c = int(input("The column number for the f...
r = int(input('Row number of the first cell on Chessboard, r = ?')) if r > 8 or r < 1: print('Invalid row number for a Chessboard!') exit() c = int(input('The column number for the first cell on Chessboard, c = ?')) if c > 8 or c < 1: print('Invalid column number for a Chessboard!') exit() r = int(input...
def int_to_byte(i): return i.to_bytes(1, byteorder='big') def byte_to_int(b): return int.from_bytes(b, byteorder='big', signed=False)
def int_to_byte(i): return i.to_bytes(1, byteorder='big') def byte_to_int(b): return int.from_bytes(b, byteorder='big', signed=False)
class ServicePrincipal: def __init__(self, client_id=None, tenant_id=None, credential=None): self.client_id = client_id self.tenant_id = tenant_id self.credential = credential def from_dict(self, service_principal_dict): self.client_id = service_principal_dict['client_id'] ...
class Serviceprincipal: def __init__(self, client_id=None, tenant_id=None, credential=None): self.client_id = client_id self.tenant_id = tenant_id self.credential = credential def from_dict(self, service_principal_dict): self.client_id = service_principal_dict['client_id'] ...
num_inpt = a = 7484 num_inpt_2 = b = 12312 while num_inpt != num_inpt_2: # nod if num_inpt > num_inpt_2: num_inpt = num_inpt - num_inpt_2 elif num_inpt_2 > num_inpt: num_inpt_2 = num_inpt_2 - num_inpt nok = a * b // num_inpt_2 #nok print(nok)
num_inpt = a = 7484 num_inpt_2 = b = 12312 while num_inpt != num_inpt_2: if num_inpt > num_inpt_2: num_inpt = num_inpt - num_inpt_2 elif num_inpt_2 > num_inpt: num_inpt_2 = num_inpt_2 - num_inpt nok = a * b // num_inpt_2 print(nok)
def count_and_print(f, l): c=0 for e in l: f.write(e) f.write("\n") c+=1 f.close() return c
def count_and_print(f, l): c = 0 for e in l: f.write(e) f.write('\n') c += 1 f.close() return c
def readFlat(filename, delimiter): f = open(filename) ans = [] for line in f: ans.append(map(lambda x:float(x), filter(lambda x:len(x)>0,line.split(delimiter)))) return ans
def read_flat(filename, delimiter): f = open(filename) ans = [] for line in f: ans.append(map(lambda x: float(x), filter(lambda x: len(x) > 0, line.split(delimiter)))) return ans
# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 # For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt def b(x): msg = "x is %s" % x print(msg)
def b(x): msg = 'x is %s' % x print(msg)
class DoubleNode: def __init__(self, value): self.value = value self.next = None self.previous = None class DoublyLinkedList: def __init__(self): self.head = None self.tail = None def append(self, value): if self.head == None: self.head = DoubleN...
class Doublenode: def __init__(self, value): self.value = value self.next = None self.previous = None class Doublylinkedlist: def __init__(self): self.head = None self.tail = None def append(self, value): if self.head == None: self.head = doubl...
# Authors: Soledad Galli <solegalli@protonmail.com> # License: BSD 3 clause # functions shared across transformers def _define_variables(variables): # Check that variable names are passed in a list. # Can take None as value if not variables or isinstance(variables, list): variables = variables ...
def _define_variables(variables): if not variables or isinstance(variables, list): variables = variables else: variables = [variables] return variables def _find_numerical_variables(X, variables=None): if not variables: variables = list(X.select_dtypes(include='number').columns)...
K, A, B = map(int, input().split()) if B-A <= 2: print(K+1) exit(0) if 1+(K-2) < A: print(K+1) exit(0) exchange_times, last = divmod(K-(A-1), 2) profit = B - A ans = A + exchange_times * profit + last print(ans)
(k, a, b) = map(int, input().split()) if B - A <= 2: print(K + 1) exit(0) if 1 + (K - 2) < A: print(K + 1) exit(0) (exchange_times, last) = divmod(K - (A - 1), 2) profit = B - A ans = A + exchange_times * profit + last print(ans)
m = "sdjlwdd" c print(mBytes) mInt = int.from_bytes(mBytes, byteorder="big") mBytes2 = mInt.to_bytes(((mInt.bit_length() + 7) // 8), byteorder="big") m2 = mBytes2.decode("utf-8") print(m == m2)
m = 'sdjlwdd' c print(mBytes) m_int = int.from_bytes(mBytes, byteorder='big') m_bytes2 = mInt.to_bytes((mInt.bit_length() + 7) // 8, byteorder='big') m2 = mBytes2.decode('utf-8') print(m == m2)
# -*- coding: UTF-8 -*- # vim: ts=4 sts=4 sw=4 tw=100 sta et class NotInRole(Exception): pass def check_role(my_roles, requested_roles): if not my_roles: return True for role in my_roles: if role in requested_roles: return True raise NotInRole()
class Notinrole(Exception): pass def check_role(my_roles, requested_roles): if not my_roles: return True for role in my_roles: if role in requested_roles: return True raise not_in_role()