content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
def one_away(string1,string2): idx = 0 if(len(string1) > len(string2)): aux = string1 string2 = string1 string1 = aux if(len(string2) -len(string1) > 1): return False while(idx < len(string1) and idx < len(string2)): char1 = string1[idx] char2 = str...
def one_away(string1, string2): idx = 0 if len(string1) > len(string2): aux = string1 string2 = string1 string1 = aux if len(string2) - len(string1) > 1: return False while idx < len(string1) and idx < len(string2): char1 = string1[idx] char2 = string2[idx...
#!/usr/bin/env python3 -tt def doAttackNavigator(case, nav_list, eachtechnique): nav_pairs = { "T1001": "{\n \"techniqueID\": \"T1001\",\n \"tactic\": \"command-and-control\",\n \"color\": \"#00ACB4\",\n \"comment\": \"\",\n \"enabled\": true,\n ...
def do_attack_navigator(case, nav_list, eachtechnique): nav_pairs = {'T1001': '{\n "techniqueID": "T1001",\n "tactic": "command-and-control",\n "color": "#00ACB4",\n "comment": "",\n "enabled": true,\n "metadata": [],\n "showSubtechniques"...
def preprocess_sotu_text(text): removed_applause_text = text.replace('(Applause.)', ' ') removed_ddash_text = removed_applause_text.replace('--', ' ') processed_text = removed_ddash_text return processed_text
def preprocess_sotu_text(text): removed_applause_text = text.replace('(Applause.)', ' ') removed_ddash_text = removed_applause_text.replace('--', ' ') processed_text = removed_ddash_text return processed_text
def executar(n, lista): for i in range(n): lista += str(i + 1) + "\t" print(lista) lista = '' n = int(input("Digite n: ")) executar(n, lista)
def executar(n, lista): for i in range(n): lista += str(i + 1) + '\t' print(lista) lista = '' n = int(input('Digite n: ')) executar(n, lista)
my_tuple = (1, 2, 3) str_tuple = ('hello!',) print("Tuple Length:", len(my_tuple)) print("Concatenation with (3, 4):", my_tuple + (3, 4)) print("Multiplication:", str_tuple*2) print("Search. Is 2 in my_tuple?", 2 in my_tuple) print("Values in my_tuple:") for x in my_tuple: print(x)
my_tuple = (1, 2, 3) str_tuple = ('hello!',) print('Tuple Length:', len(my_tuple)) print('Concatenation with (3, 4):', my_tuple + (3, 4)) print('Multiplication:', str_tuple * 2) print('Search. Is 2 in my_tuple?', 2 in my_tuple) print('Values in my_tuple:') for x in my_tuple: print(x)
class Car: def __init__(self, engine): self.engine = engine def run(self): self.engine.start() class Engine: def start(self): print("Engine started!") trinity5_8 = Engine() ford = Car(trinity5_8) ford.run()
class Car: def __init__(self, engine): self.engine = engine def run(self): self.engine.start() class Engine: def start(self): print('Engine started!') trinity5_8 = engine() ford = car(trinity5_8) ford.run()
__author__ = 'fmontes' class ContributionStats: def __init__(self, contributor_name, line_count): self.contributor_name = contributor_name self.contributed_lines = line_count def average(self, total_lines_to_consider=1): return float(self.contributed_lines) / float(total_lines_to_con...
__author__ = 'fmontes' class Contributionstats: def __init__(self, contributor_name, line_count): self.contributor_name = contributor_name self.contributed_lines = line_count def average(self, total_lines_to_consider=1): return float(self.contributed_lines) / float(total_lines_to_cons...
class A(object): def __init__(self): self.value = "Some Value" def return_true(self): return True def raise_exc(self, val): raise KeyError(val)
class A(object): def __init__(self): self.value = 'Some Value' def return_true(self): return True def raise_exc(self, val): raise key_error(val)
# coding=utf-8 FLODER_AUTH = 'auth' HTTP_OR_HTTPS = 'https://' AGENT_WEIXIN = 'MicroMessenger' AGENT_ALIPAY = 'AlipayClient' AGENT_WEIBO = 'Weibo' AGENT_QQ = 'QQ' TEMPLATE_FOOTER = \ "<script language=javascript src='/r/theme/whiteconsole/scripts/jquery-3.3.1.min.js'></script>\ <script language=javascript sr...
floder_auth = 'auth' http_or_https = 'https://' agent_weixin = 'MicroMessenger' agent_alipay = 'AlipayClient' agent_weibo = 'Weibo' agent_qq = 'QQ' template_footer = "<script language=javascript src='/r/theme/whiteconsole/scripts/jquery-3.3.1.min.js'></script> <script language=javascript src='/r/plugin/baiduTemplate...
class Triangle(object): def __init__(self, angle1, angle2, angle3): self.angle1 = angle1 self.angle2 = angle2 self.angle3 = angle3 number_of_sides = 3 def check_angles(self): if (self.angle1 + self.angle2 + self.angle3) == 180: return True else: ...
class Triangle(object): def __init__(self, angle1, angle2, angle3): self.angle1 = angle1 self.angle2 = angle2 self.angle3 = angle3 number_of_sides = 3 def check_angles(self): if self.angle1 + self.angle2 + self.angle3 == 180: return True else: ...
# https://binarysearch.com/ # GGA 2020.10.27 # # User Problem # You have: int # You Need: each digit ^ number of dig # You Must: # # Solution (Feature/Product) # # Edge cases: # # input-ouput-example: # Given an integer n, return whether it is equal to the # sum of its own digits raised to the power of the # number...
class Solution: def solve(self, nums): len_dig = len(str(nums)) solution = 0 numlist_1 = list(str(nums)) numlist_2 = [int(i) for i in numlist_1] for i in numlist_2: solution += i ** len_dig return nums == solution tom = solution() Tom.solve(153)
# Python program to demonstrate delete operation # in binary search tree # A Binary Tree Node class Node: # Constructor to create a new node def __init__(self, key): self.key = key self.left = None self.right = None def inorder(root): if root is not None: inorder(root.left) print...
class Node: def __init__(self, key): self.key = key self.left = None self.right = None def inorder(root): if root is not None: inorder(root.left) (print(root.key),) inorder(root.right) def preorder(root): if root is not None: print(root.key) ...
while True: s=input().split() if len(s)==1 and len(s[0])==1 and s[0]=='*':break tam=len(s) f=[] for i in range(tam):f.append(s[i][0].lower()) tam=len(f) print("Y") if f.count(f[0])==tam else print("N")
while True: s = input().split() if len(s) == 1 and len(s[0]) == 1 and (s[0] == '*'): break tam = len(s) f = [] for i in range(tam): f.append(s[i][0].lower()) tam = len(f) print('Y') if f.count(f[0]) == tam else print('N')
def releaseleftclothes(): ##arms get to middle i01.setHandSpeed("left", 1.0, 0.80, 0.80, 0.80, 1.0, 0.80) i01.setHandSpeed("right", 1.0, 0.70, 0.70, 1.0, 1.0, 0.80) i01.setArmSpeed("left", 1.0, 1.0, 1.0, 1.0) i01.setArmSpeed("right", 1.0, 1.0, 1.0, 1.0) i01.setHeadSpeed(0.90, 0.80) i0...
def releaseleftclothes(): i01.setHandSpeed('left', 1.0, 0.8, 0.8, 0.8, 1.0, 0.8) i01.setHandSpeed('right', 1.0, 0.7, 0.7, 1.0, 1.0, 0.8) i01.setArmSpeed('left', 1.0, 1.0, 1.0, 1.0) i01.setArmSpeed('right', 1.0, 1.0, 1.0, 1.0) i01.setHeadSpeed(0.9, 0.8) i01.setTorsoSpeed(1.0, 0.8, 1.0) i01.mo...
stats = airline[['Year', 'Passengers']].groupby('Year').mean() stats['Max'] = airline[['Year', 'Passengers']].groupby('Year').max() stats['Min'] = airline[['Year', 'Passengers']].groupby('Year').min() stats['Range'] = stats['Max']-stats['Min'] ax = stats.plot(y='Passengers', yerr='Range', legend=False) ax.set_ylabel(r...
stats = airline[['Year', 'Passengers']].groupby('Year').mean() stats['Max'] = airline[['Year', 'Passengers']].groupby('Year').max() stats['Min'] = airline[['Year', 'Passengers']].groupby('Year').min() stats['Range'] = stats['Max'] - stats['Min'] ax = stats.plot(y='Passengers', yerr='Range', legend=False) ax.set_ylabel(...
n = 0 while True: inn = input() if inn == '0': break n += int(inn) print(n)
n = 0 while True: inn = input() if inn == '0': break n += int(inn) print(n)
PAS = 'pass' INF = float('inf') class Expectimax: def __init__(self, max_who, rules): self.max_who = max_who self.rules = rules def value(self, state, agent_id, depth): if state.is_over() or depth <= 0: return self.evaluation_function(state, agent_id) if agent_id =...
pas = 'pass' inf = float('inf') class Expectimax: def __init__(self, max_who, rules): self.max_who = max_who self.rules = rules def value(self, state, agent_id, depth): if state.is_over() or depth <= 0: return self.evaluation_function(state, agent_id) if agent_id =...
substrings = ['These', 'are', 'strings', 'to', 'concatanate.'] s = ' ' # Highly inefficient # for substring in substrings: # s += substring # print(s) s = ' '.join(substrings) print(s) # OR using an "unbound" method call x = str.join(' ', substrings) print(x)
substrings = ['These', 'are', 'strings', 'to', 'concatanate.'] s = ' ' s = ' '.join(substrings) print(s) x = str.join(' ', substrings) print(x)
def main(): n = int(input()) l = list(map(int, input().split())) l = sorted(l) if n==1 or n==2: print(0) for i in l: print(i, end=' ') print() return flag = 0 ind = n//2 while(l[ind]==l[ind+1] and ind>0): ind -= 1 flag = 1...
def main(): n = int(input()) l = list(map(int, input().split())) l = sorted(l) if n == 1 or n == 2: print(0) for i in l: print(i, end=' ') print() return flag = 0 ind = n // 2 while l[ind] == l[ind + 1] and ind > 0: ind -= 1 flag = ...
expected_output = { 'eigrp_instance': { '100': { 'vrf': { 'default': { 'address_family': { 'ipv6': { 'eigrp_interface': { 'Ethernet1/1.90': { ...
expected_output = {'eigrp_instance': {'100': {'vrf': {'default': {'address_family': {'ipv6': {'eigrp_interface': {'Ethernet1/1.90': {'eigrp_nbr': {'fe80::f816:3eff:fecf:5a5b': {'peer_handle': 0, 'hold': 12, 'uptime': '01:40:09', 'srtt': 0.01, 'rto': 60, 'q_cnt': 0, 'last_seq_number': 30}}}, 'Ethernet1/2.90': {'eigrp_nb...
class Solution: def subsetsWithDup(self, nums: List[int], sorted: bool = False) -> List[List[int]]: if not nums: return [[]] if len(nums) == 1: return [[], nums] if not sorted: nums.sort() pre_lists = self.subsetsWithDup(nums[:-1], sorted=True) all_lists = [i + [nums[-1]] for...
class Solution: def subsets_with_dup(self, nums: List[int], sorted: bool=False) -> List[List[int]]: if not nums: return [[]] if len(nums) == 1: return [[], nums] if not sorted: nums.sort() pre_lists = self.subsetsWithDup(nums[:-1], sorted=True) ...
#!/usr/bin/env python # mode - Degree of scanning done by service modules. # Default is 'normal', 2nd option is 'stealth'. mode = 'normal'
mode = 'normal'
arr=[1,0,-1,0,-2,2] target=0 def four_sum( arr, target): hash_map = dict() arr.sort() result = set() for i in range(len(arr)): for j in range(i + 1, len(arr)): curr_sum = arr[i] + arr[j] diff = target - curr_sum if diff in hash_map: ...
arr = [1, 0, -1, 0, -2, 2] target = 0 def four_sum(arr, target): hash_map = dict() arr.sort() result = set() for i in range(len(arr)): for j in range(i + 1, len(arr)): curr_sum = arr[i] + arr[j] diff = target - curr_sum if diff in hash_map: fo...
class Reader: def __init__(self, checker, size: int): self.checker = checker self.size = size def read(self, path: str): f = open(path, 'rb') data = [0] * self.size for i in range(self.size): data[i] = [0] * self.size col = 0 row = 0 ...
class Reader: def __init__(self, checker, size: int): self.checker = checker self.size = size def read(self, path: str): f = open(path, 'rb') data = [0] * self.size for i in range(self.size): data[i] = [0] * self.size col = 0 row = 0 ...
# Author Maria carroll # Week 2 # https://www.w3resource.com/python-exercises/python-basic-exercise-66.php # Lecture 2 Statements # Lecturer: Andrew Beatty #Here we are writng a program to take information from the user to assertain a bmi result from their input height = float(input ("Enter height in metres: ")) w...
height = float(input('Enter height in metres: ')) weight = float(input('Enter weight in in kg: ')) bmi = weight / height ** 2 print('Your BMI is: {0} and you are: '.format(bmi), end='') if bmi < 16: print('obese') elif bmi >= 16 and bmi < 18.5: print('underweight') elif bmi >= 18.5 and bmi < 25: print('Heal...
def pause_game(game): for i in range(1): r = game.make_action([False, False, False]) def spawn_agent(game, x, y, orientation=0): x_pos, y_pos = to_acs_float(x), to_acs_float(y) game.send_game_command("pukename set_position %i %i %i" % (x_pos, y_pos, orientation)) # pa...
def pause_game(game): for i in range(1): r = game.make_action([False, False, False]) def spawn_agent(game, x, y, orientation=0): (x_pos, y_pos) = (to_acs_float(x), to_acs_float(y)) game.send_game_command('pukename set_position %i %i %i' % (x_pos, y_pos, orientation)) def spawn_object(game, object_...
# Is Graph Bipartite?: https://leetcode.com/problems/is-graph-bipartite/ # There is an undirected graph with n nodes, where each node is numbered between 0 and n - 1. You are given a 2D array graph, where graph[u] is an array of nodes that node u is adjacent to. More formally, for each v in graph[u], there is an undir...
class Solution: def is_bipartite(self, graph) -> bool: visited = {} self.hasFaled = False def dfs(node, color=0): if node in visited: if visited[node] ^ color: self.hasFaled = True return False return True ...
def _get_main(ctx): if ctx.file.main: return ctx.workspace_name + "/" + ctx.file.main.path main = ctx.label.name + ".py" for src in ctx.files.srcs: if src.basename == main: return ctx.workspace_name + "/" + src.path fail( "corresponding default '{}' does not appear in...
def _get_main(ctx): if ctx.file.main: return ctx.workspace_name + '/' + ctx.file.main.path main = ctx.label.name + '.py' for src in ctx.files.srcs: if src.basename == main: return ctx.workspace_name + '/' + src.path fail("corresponding default '{}' does not appear in srcs. "....
def aMax (list): if len(list) == 0: return None max = list[0] for item in list: if item > max: max = item return max def aMin (list): if len(list) == 0: return None min = list[0] for item in list: if item < min: ...
def a_max(list): if len(list) == 0: return None max = list[0] for item in list: if item > max: max = item return max def a_min(list): if len(list) == 0: return None min = list[0] for item in list: if item < min: min = item return m...
load( "@rules_mono//dotnet/private:providers.bzl", "DotnetLibrary", ) def _make_runner_arglist(dotnet, source, output): args = dotnet.actions.args() args.add("/useSourcePath") if type(source) == "Target": args.add_all(source.files) else: args.add(source) args.add(output) ...
load('@rules_mono//dotnet/private:providers.bzl', 'DotnetLibrary') def _make_runner_arglist(dotnet, source, output): args = dotnet.actions.args() args.add('/useSourcePath') if type(source) == 'Target': args.add_all(source.files) else: args.add(source) args.add(output) return arg...
try: f = open("myfile","w") a,b = [int(x) for x in input("Enter two numbers:").split()] c = a/b f.write("Writing %d into file" %c) except ZeroDivisionError: print("Division by zero is not allowed") print("Please enter a non zero number") finally: f.close() # Writi...
try: f = open('myfile', 'w') (a, b) = [int(x) for x in input('Enter two numbers:').split()] c = a / b f.write('Writing %d into file' % c) except ZeroDivisionError: print('Division by zero is not allowed') print('Please enter a non zero number') finally: f.close() print('File Closed') pri...
# File: cofenseintelligence_consts.py # # Copyright (c) 2020-2021 Splunk Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless req...
phishme_api_search = 'https://www.threathq.com/apiv1' phishme_api_threat_update = '/threat/updates' phishme_endpoint = '/threat/search' phishme_endpoint_get_report_malware = '/threat/malware/' phishme_err_api_unsupported_method = 'Unsupported method {method}' phishme_connection_test_msg = 'Querying endpoint to verify t...
n=int(input("enter year\n")) if(n%400==0 and n%100==0): print("leap year") elif(n%4==0 and n%100!=0): print("leap year") else: print("not leap year")
n = int(input('enter year\n')) if n % 400 == 0 and n % 100 == 0: print('leap year') elif n % 4 == 0 and n % 100 != 0: print('leap year') else: print('not leap year')
def create_new(numbers): n = len(numbers) keys = [None for i in range(2 * n)] for num in numbers: idx = num % len(keys) while keys[idx] is not None: idx = (idx + 1) % len(keys) keys[idx] = num return keys def create_new_broken(numbers): n = len(numbers) ...
def create_new(numbers): n = len(numbers) keys = [None for i in range(2 * n)] for num in numbers: idx = num % len(keys) while keys[idx] is not None: idx = (idx + 1) % len(keys) keys[idx] = num return keys def create_new_broken(numbers): n = len(numbers) keys ...
class Solution: def isHappy(self, n: int) -> bool: x=[] def Happy(n,x): t,k=0,0 while n>0: t=n%10 n=n//10 k=k+t*t if k==1: return True else: if k in x: ...
class Solution: def is_happy(self, n: int) -> bool: x = [] def happy(n, x): (t, k) = (0, 0) while n > 0: t = n % 10 n = n // 10 k = k + t * t if k == 1: return True elif k in x: ...
def draw_mem(): c_width = int( w.Canvas2.cget( "width" )) c_height = int( w.Canvas2.cget( "height" )) print( c_width ) box_start = c_width * 0.05 box_end = c_width * 0.95 mem_title = w.Canvas2.create_text(( c_width / 2 ), 10, fill = "black", font = "Times 10", text = "Flash" ) mem1 = w.Canva...
def draw_mem(): c_width = int(w.Canvas2.cget('width')) c_height = int(w.Canvas2.cget('height')) print(c_width) box_start = c_width * 0.05 box_end = c_width * 0.95 mem_title = w.Canvas2.create_text(c_width / 2, 10, fill='black', font='Times 10', text='Flash') mem1 = w.Canvas2.create_rectangle...
disease_name = 'COVID-19' # Prob. of fatality (https://www.worldometers.info/coronavirus/coronavirus-age-sex-demographics): p_covid19_fat_by_age_group = { '0-9' : 0.000, '10-19' : 0.002, '20-29' : 0.002, '30-39' : 0.002, '40-49' : 0.004, '50-59' : 0.013, '60-69' : 0.036, '70-79' : 0.0...
disease_name = 'COVID-19' p_covid19_fat_by_age_group = {'0-9': 0.0, '10-19': 0.002, '20-29': 0.002, '30-39': 0.002, '40-49': 0.004, '50-59': 0.013, '60-69': 0.036, '70-79': 0.08, '80+': 0.148} p_covid19_fat_by_age_group_comb = {'0-50': 0.002, '50-59': 0.013, '60-69': 0.036, '70-79': 0.08, '80+': 0.148} p_covid19_fat = ...
def test_snap100_component_sub_pages(component_map, dash_doc): for _, grouper in component_map: for resources in grouper: href = "/".join(resources) dash_doc.visit_and_snapshot( href, hook_id="wait-for-page-/{}".format(href) )
def test_snap100_component_sub_pages(component_map, dash_doc): for (_, grouper) in component_map: for resources in grouper: href = '/'.join(resources) dash_doc.visit_and_snapshot(href, hook_id='wait-for-page-/{}'.format(href))
t=int(input()) a=1 while(a<=t): n=int(input()) h=input().split() for i in range(n): h[i]=int(h[i]) c=0 for i in range(1,n-1): if(h[i-1]<h[i]>h[i+1]): c+=1 print('Case #' + str(a) + ': ' + str(c)) a+=1
t = int(input()) a = 1 while a <= t: n = int(input()) h = input().split() for i in range(n): h[i] = int(h[i]) c = 0 for i in range(1, n - 1): if h[i - 1] < h[i] > h[i + 1]: c += 1 print('Case #' + str(a) + ': ' + str(c)) a += 1
# Singleton through a decorator. def singleton(class_): instances = {} def getinstance(*args, **kwargs): if class_ not in instances: instances[class_] = class_(*args, **kwargs) return instances[class_] return getinstance @singleton class MyClass(object): pass m1 = MyClass() print(m1) m2 = ...
def singleton(class_): instances = {} def getinstance(*args, **kwargs): if class_ not in instances: instances[class_] = class_(*args, **kwargs) return instances[class_] return getinstance @singleton class Myclass(object): pass m1 = my_class() print(m1) m2 = my_class() print...
def data(Type, value): ''' Type (NAME | FLOAT | NUMBER | STRING) ''' return (Type, {'value': value}) def expression(op, lhs, rhs): ''' lhs (left-hand-side) rhs (right-hand-side) op (operator) ''' return ('Expression', {'op': op, 'lhs': lhs, 'rhs': rhs}) def var_assign(name, ...
def data(Type, value): """ Type (NAME | FLOAT | NUMBER | STRING) """ return (Type, {'value': value}) def expression(op, lhs, rhs): """ lhs (left-hand-side) rhs (right-hand-side) op (operator) """ return ('Expression', {'op': op, 'lhs': lhs, 'rhs': rhs}) def var_assign(name, val...
class Watchdog: def waitForData(self): data = self.Socket.recv(1024) print(data) return data def sendData(self,data): print(data) return self.Socket.send(data.encode("UTF-8")) def __init__(self, clientSocket): self.Socket = clientSocket
class Watchdog: def wait_for_data(self): data = self.Socket.recv(1024) print(data) return data def send_data(self, data): print(data) return self.Socket.send(data.encode('UTF-8')) def __init__(self, clientSocket): self.Socket = clientSocket
# 1.4) check if palindrome permutation def palindrome_permutation(str=''): if len(str) < 2: return False frequencies = {} not_even_count = 0 for char in str.lower(): if char == ' ': continue frequencies[char] = 1 + frequencies.get(char, 0) for number in frequ...
def palindrome_permutation(str=''): if len(str) < 2: return False frequencies = {} not_even_count = 0 for char in str.lower(): if char == ' ': continue frequencies[char] = 1 + frequencies.get(char, 0) for number in frequencies.values(): if number % 2 != 0:...
# # PySNMP MIB module HOST-RESOURCES-V2-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HOST-RESOURCES-V2-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 19:20:16 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (def...
(octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_range_constraint, value_size_constraint, single_value_constraint, constraints_union, constraints_intersection) ...
#!/usr/bin/env python # -*- coding: utf-8 -*- class AdversarialMachine(): ''' An abstract adversarial learning-to-rank framework ''' def __init__(self, eval_dict=None, data_dict=None, gpu=False, device=None): #todo double-check the necessity of these two arguments self.eval_dict = eva...
class Adversarialmachine: """ An abstract adversarial learning-to-rank framework """ def __init__(self, eval_dict=None, data_dict=None, gpu=False, device=None): self.eval_dict = eval_dict self.data_dict = data_dict (self.gpu, self.device) = (gpu, device) def pre_check(self)...
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Author: mcxiaoke # @Date: 2015-08-18 20:14:05 INVALID_CHARS='/\\<>:?*"|' def get_safe_filename(text): text=text.replace(':', 'x') for c in INVALID_CHARS: if c in text: text = text.replace(c, "_")
invalid_chars = '/\\<>:?*"|' def get_safe_filename(text): text = text.replace(':', 'x') for c in INVALID_CHARS: if c in text: text = text.replace(c, '_')
server_records_from_cap = { "@id": "doc:server", "@type": "terminus:Server", "rdfs:comment": {"@language": "en", "@value": "The current Database Server itself"}, "rdfs:label": {"@language": "en", "@value": "The DB server"}, "terminus:allow_origin": {"@type": "xsd:string", "@value": "*"}, "termin...
server_records_from_cap = {'@id': 'doc:server', '@type': 'terminus:Server', 'rdfs:comment': {'@language': 'en', '@value': 'The current Database Server itself'}, 'rdfs:label': {'@language': 'en', '@value': 'The DB server'}, 'terminus:allow_origin': {'@type': 'xsd:string', '@value': '*'}, 'terminus:resource_includes': [{...
command = '/opt/django/mikaponics-back/env/bin/gunicorn' pythonpath = '/opt/django/mikaponics-back/mikaponics' bind = '127.0.0.1:8001' workers = 3
command = '/opt/django/mikaponics-back/env/bin/gunicorn' pythonpath = '/opt/django/mikaponics-back/mikaponics' bind = '127.0.0.1:8001' workers = 3
treatment = [ { "id": "1", "name": "Dactolisib", "data_source": "TRACE" }, { "id": "2", "name": "capecitabine", "data_source": "TRACE" }, { "id": "3", "name": "PREDNISONE", "data_source": "TRACE" }, { "id": "4", ...
treatment = [{'id': '1', 'name': 'Dactolisib', 'data_source': 'TRACE'}, {'id': '2', 'name': 'capecitabine', 'data_source': 'TRACE'}, {'id': '3', 'name': 'PREDNISONE', 'data_source': 'TRACE'}, {'id': '4', 'name': 'FU-LV regimen', 'data_source': 'TRACE'}] treatment_and_component_helper = [{'treatment_protocol_id': '1', '...
CLUSTER_COL = "cluster" COUNT_COL = "count" RECOMMENDED_COL = "recommended" CLUSTER_COUNT_COL = "cluster_count" CLUSTER_SUM_COL = "cluster_sum" NGRAM_COL = "ngram" FINGERPRINT_COL = "fingerprint" NGRAM_FINGERPRINT_COL = "ngram_fingerprint" LEVENSHTEIN_DISTANCE = "LEVENSHTEIN_DISTANCE" STRING_TO_INDEX = "string_to_ind...
cluster_col = 'cluster' count_col = 'count' recommended_col = 'recommended' cluster_count_col = 'cluster_count' cluster_sum_col = 'cluster_sum' ngram_col = 'ngram' fingerprint_col = 'fingerprint' ngram_fingerprint_col = 'ngram_fingerprint' levenshtein_distance = 'LEVENSHTEIN_DISTANCE' string_to_index = 'string_to_index...
# # PySNMP MIB module TIMETRA-QOS-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/TIMETRA-QOS-MIB # Produced by pysmi-0.3.4 at Wed May 1 15:17:06 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27...
(integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (single_value_constraint, value_size_constraint, constraints_intersection, value_range_constraint, constraints_union) ...
# # PySNMP MIB module CISCO-FC-SPAN-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-FC-SPAN-MIB # Produced by pysmi-0.3.4 at Wed May 1 11:58:14 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Ma...
(integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_intersection, single_value_constraint, value_range_constraint, constraints_union, value_size_constraint) ...
# Source : https://github.com/mission-peace/interview/blob/master/python/dynamic/longest_increasing_subsequence.py # Find a subsequence in given array in which the subsequence's elements are in sorted order, lowest to highest, and in which the subsequence is as long as possible. # Time Complexity: O(N^2), Space Compl...
def longest_increasing_subsequence(arr): length_arr = len(arr) longest = float('-inf') for idx in range(length_arr - 1): longest_so_far = longest_increasing_subsequence_recursive(arr, idx + 1, arr[idx]) longest = max(longest, longest_so_far) return longest + 1 def longest_increasing_sub...
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may...
table_name = 'birth_names' num_girls = 'num_girls' num_boys = 'num_boys' state = 'state' num = 'num' name = 'name' gender = 'gender' ds = 'ds' girl = 'girl' boy = 'boy'
#Copyright (c) 2016 Vidhya, Nandini #Following code is available for use under MIT license. Please see the LICENSE file for details. #This project uses as constant the genres we need to train with and classify into. This constant list of genres is stored in this file and is included in others for prediction. # This i...
genres = ['folk', 'reggae', 'punk', 'classical', 'electronica', 'hip hop', 'rock', 'metal', 'pop', 'jazz']
fah = float(input("Qual a temperatura em farenheit ==> ")) celsius = 0.56 * (fah-32) print("A temperatura de", fah, "farenheit equivale a", celsius, "celsius")
fah = float(input('Qual a temperatura em farenheit ==> ')) celsius = 0.56 * (fah - 32) print('A temperatura de', fah, 'farenheit equivale a', celsius, 'celsius')
# coding: utf-8 BASE_DOCS_URL = 'https://developer.zendesk.com/rest_api/docs/support' RESOURCE_MAPPING = { 'organizations': { 'resource': 'organizations.json', 'docs': '{0}/organizations'.format(BASE_DOCS_URL) }, 'tickets': { 'resource': 'tickets.json', 'docs': '{0}/tickets...
base_docs_url = 'https://developer.zendesk.com/rest_api/docs/support' resource_mapping = {'organizations': {'resource': 'organizations.json', 'docs': '{0}/organizations'.format(BASE_DOCS_URL)}, 'tickets': {'resource': 'tickets.json', 'docs': '{0}/tickets'.format(BASE_DOCS_URL)}, 'create_many_tickets': {'resource': 'tic...
# Copyright 2016 VMware, Inc. # 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 appl...
i_pv4_any = '0.0.0.0/0' proto_name_ah = 'ah' proto_name_dccp = 'dccp' proto_name_egp = 'egp' proto_name_esp = 'esp' proto_name_gre = 'gre' proto_name_icmp = 'icmp' proto_name_igmp = 'igmp' proto_name_ipip = 'ipip' proto_name_ipv6_encap = 'ipv6-encap' proto_name_ipv6_frag = 'ipv6-frag' proto_name_ipv6_icmp = 'ipv6-icmp'...
n= int(input()) for i in range(1,n+1): u= (i**3 + 2*i) print(u,end=',')
n = int(input()) for i in range(1, n + 1): u = i ** 3 + 2 * i print(u, end=',')
# File: ipcontrol_consts.py # Copyright (c) 2021 Splunk Inc. # # Licensed under Apache 2.0 (https://www.apache.org/licenses/LICENSE-2.0.txt) IPCONTROL_ENDPOINT_LOGIN = '/login' IPCONTROL_ENDPOINT = '/inc-rest/api/v1' IPCONTROL_ENDPOINT_GET_CHILD_BLOCK = '/Exports/initExportChildBlock' IPCONTROL_ENDPOINT_GET_HOSTNAME =...
ipcontrol_endpoint_login = '/login' ipcontrol_endpoint = '/inc-rest/api/v1' ipcontrol_endpoint_get_child_block = '/Exports/initExportChildBlock' ipcontrol_endpoint_get_hostname = '/Gets/getDeviceByIPAddr?ipAddress=' ipcontrol_endpoint_get_block_type = '/Exports/initExportChildBlock' ipcontrol_endpoint_get_ip_address = ...
# using if statement in complex situation # elif country= input("Where are you form?\n").upper() if country=="ENGLAND": print("Hello!") elif country=="GERMANY":# elif allows us to check for different values. It means else-if. print("Gutan Tag!") elif country=="FRANCE": print("Bonjour!") elif country=="MEXI...
country = input('Where are you form?\n').upper() if country == 'ENGLAND': print('Hello!') elif country == 'GERMANY': print('Gutan Tag!') elif country == 'FRANCE': print('Bonjour!') elif country == 'MEXICO': print('Ola Amigo!') elif country == 'INDIA': print('Namaste!') else: print('Hey!') deposi...
# -*- coding: utf-8 -*- author = 'thecokerdavid'
author = 'thecokerdavid'
class LogMessages: GW_SERVER_LISTENING = 'RD Gateway server listening on {}:{}' GW_FAILED_PROCESS_HTTP_REQUEST = 'Failed to process HTTP request' GW_ATTEMPT_NON_WEBSOCKET = 'Unsupported attempt to connect without WebSocket' WEBSOCKET_RECEIVED_CONNECTION_REQUEST = 'Received WebSocket connec...
class Logmessages: gw_server_listening = 'RD Gateway server listening on {}:{}' gw_failed_process_http_request = 'Failed to process HTTP request' gw_attempt_non_websocket = 'Unsupported attempt to connect without WebSocket' websocket_received_connection_request = 'Received WebSocket connection request' ...
class Solution: def corpFlightBookings(self, bookings: List[List[int]], n: int) -> List[int]: dp = [0] * n for i, j, k in bookings: dp[i - 1] += k if j < n: dp[j] -= k result = [0] * n result[0] = dp[0] for i in range(1, n): ...
class Solution: def corp_flight_bookings(self, bookings: List[List[int]], n: int) -> List[int]: dp = [0] * n for (i, j, k) in bookings: dp[i - 1] += k if j < n: dp[j] -= k result = [0] * n result[0] = dp[0] for i in range(1, n): ...
#!/bin/bash x = 99 def f1(): x = 88 def f2(): print(x) f2() f1()
x = 99 def f1(): x = 88 def f2(): print(x) f2() f1()
class Solution: def maxProfit(self, prices: List[int]) -> int: low = prices[0] ans = 0 for i in range(1, len(prices)): low = min(low, prices[i]) ans = max(prices[i] - low, ans) return ans
class Solution: def max_profit(self, prices: List[int]) -> int: low = prices[0] ans = 0 for i in range(1, len(prices)): low = min(low, prices[i]) ans = max(prices[i] - low, ans) return ans
class Solution: def wordsAbbreviation(self, words: List[str]) -> List[str]: def compute_LCP(w1, w2): cnt = 0 for i, (c1, c2) in enumerate(zip(w1, w2)): if c1 == c2: cnt += 1 else: break return cnt ...
class Solution: def words_abbreviation(self, words: List[str]) -> List[str]: def compute_lcp(w1, w2): cnt = 0 for (i, (c1, c2)) in enumerate(zip(w1, w2)): if c1 == c2: cnt += 1 else: break return cn...
def palindrome(s): s=s.replace(" ",'') reverse=s[::-1] if s==reverse: return True else: return False
def palindrome(s): s = s.replace(' ', '') reverse = s[::-1] if s == reverse: return True else: return False
for _ in range(int(input())): inp = input().lower() cha = list('abcdefghijklmnopqrstuvwxyz') for i in inp: if i in cha: cha.remove(i) if len(cha)==0: print('pangram') else: print('missing', ''.join(cha))
for _ in range(int(input())): inp = input().lower() cha = list('abcdefghijklmnopqrstuvwxyz') for i in inp: if i in cha: cha.remove(i) if len(cha) == 0: print('pangram') else: print('missing', ''.join(cha))
msg = 'Hello World' print(msg[8]) print(msg[-3]) tinker = 'Tinker' print(tinker[1:4]) numbers = '123456789' even = numbers[1:9:2] odd = numbers[0:10:2] print(even, odd)
msg = 'Hello World' print(msg[8]) print(msg[-3]) tinker = 'Tinker' print(tinker[1:4]) numbers = '123456789' even = numbers[1:9:2] odd = numbers[0:10:2] print(even, odd)
string1 = "Linux" string2 = "Hint" joined_string = string1 + string2 print(joined_string)
string1 = 'Linux' string2 = 'Hint' joined_string = string1 + string2 print(joined_string)
N, M, X, Y = map(int, input().rstrip().split()) a = list(map(int, input().rstrip().split())) a = [n for n in a if n > Y] if len(a) <= M: print(sum(a)) else: a.sort() while True: n = a.pop(0) if n >= X: print('Handicapped') exit() if len(a) <= M: print(sum(a)) exit()
(n, m, x, y) = map(int, input().rstrip().split()) a = list(map(int, input().rstrip().split())) a = [n for n in a if n > Y] if len(a) <= M: print(sum(a)) else: a.sort() while True: n = a.pop(0) if n >= X: print('Handicapped') exit() if len(a) <= M: ...
class Solution: def maxDepth(self, root: 'Node') -> int: if not root: return 0 if not root.children: return 1 return 1 + max(self.maxDepth(child) for child in root.children)
class Solution: def max_depth(self, root: 'Node') -> int: if not root: return 0 if not root.children: return 1 return 1 + max((self.maxDepth(child) for child in root.children))
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # @Date : 2019-11-26 01:20:25 # @Author : Racter Liu (racterub) (racterub@gmail.com) # @Link : https://racterub.io # @License : MIT def has_dups(data): for i in data: if data.count(i) > 1: return True else: return False ...
def has_dups(data): for i in data: if data.count(i) > 1: return True else: return False print(has_dups([1, 2, 3, 4, 5])) print(has_dups([1, 2, 1, 3, 4, 5]))
class Prays: TheBenedictus = 'Blessed be the Lord, the God of Israel he has come to his people and set them free.\ He has raised up for us a mighty savior,\ born of the house of his servant David.\ Through his holy prophets he promised of old\ that he would save us from our enemies,\...
class Prays: the_benedictus = 'Blessed be the Lord, the God of Israel he has come to his people and set them free. He has raised up for us a mighty savior, born of the house of his servant David. Through his holy prophets he promised of old that he would save us from our enemies, ...
# https://leetcode.com/problems/count-the-number-of-consistent-strings/ class Solution: def countConsistentStrings(self, allowed: str, words: List[str]) -> int: dictx = {} for each in allowed: dictx[each] = 1 count = 0 for each in ...
class Solution: def count_consistent_strings(self, allowed: str, words: List[str]) -> int: dictx = {} for each in allowed: dictx[each] = 1 count = 0 for each in words: flag = True for i in range(0, len(each)): if each[i] not in dic...
test_str = "111" def show(): print(__name__, "show")
test_str = '111' def show(): print(__name__, 'show')
class Solution: def twoSum(self, nums: List[int], target: int) -> List[int]: s_nums = sorted(nums) l = len(nums) for i, num in enumerate(nums): t = target - num o = bisect.bisect_left(s_nums, t) if o <l: if t == s_nums[o]: ...
class Solution: def two_sum(self, nums: List[int], target: int) -> List[int]: s_nums = sorted(nums) l = len(nums) for (i, num) in enumerate(nums): t = target - num o = bisect.bisect_left(s_nums, t) if o < l: if t == s_nums[o]: ...
class RangeSlicer: @staticmethod def get_sliced_range(start_block: int, end_block: int, step: int): for index, block_index_breakpoint in enumerate(range(start_block, end_block+step, step)): if not index: continue if block_index_breakpoint > end_block: ...
class Rangeslicer: @staticmethod def get_sliced_range(start_block: int, end_block: int, step: int): for (index, block_index_breakpoint) in enumerate(range(start_block, end_block + step, step)): if not index: continue if block_index_breakpoint > end_block: ...
#!/usr/bin/python europe = [] germany = {"name": "Germany", "population": 81000000, "price": 1000} europe.append(germany) luxembourg = {"name": "Luxembourg", "population": 512000, "price": 2000} europe.append(luxembourg) andorra = {"name": "Andorra", "population": 900000, "price": 3000} europe.append(andorra) print(le...
europe = [] germany = {'name': 'Germany', 'population': 81000000, 'price': 1000} europe.append(germany) luxembourg = {'name': 'Luxembourg', 'population': 512000, 'price': 2000} europe.append(luxembourg) andorra = {'name': 'Andorra', 'population': 900000, 'price': 3000} europe.append(andorra) print(len(europe)) europe2 ...
LONG_TIMEOUT = 30.0 # For wifi scan SHORT_TIMEOUT = 10.0 # For any other command DEFAULT_MEROSS_HTTP_API = "https://iot.meross.com" DEFAULT_MQTT_HOST = "mqtt.meross.com" DEFAULT_MQTT_PORT = 443 DEFAULT_COMMAND_TIMEOUT = 10.0
long_timeout = 30.0 short_timeout = 10.0 default_meross_http_api = 'https://iot.meross.com' default_mqtt_host = 'mqtt.meross.com' default_mqtt_port = 443 default_command_timeout = 10.0
# Programa 05 b = 5/2 + 6/4 a = 3 + b if (a > 7): c = a + c print(b - a) elif (a == 7): c = a - b print(2*c + 1) else: a = a + b
b = 5 / 2 + 6 / 4 a = 3 + b if a > 7: c = a + c print(b - a) elif a == 7: c = a - b print(2 * c + 1) else: a = a + b
message = input('Enter a message. Go ahead, I\'ll wait!\n') count = 0 for i in message: if i != 'a': print(i, end = "") elif i == 'a': count += 1 if count > 3: i = 'A' print(i, end = '') else: i = '@' print(i, end = '')
message = input("Enter a message. Go ahead, I'll wait!\n") count = 0 for i in message: if i != 'a': print(i, end='') elif i == 'a': count += 1 if count > 3: i = 'A' print(i, end='') else: i = '@' print(i, end='')
# PR#208, calling apply with bogus 3rd argument def test(x): return x assert 7 == test(*(7,)) assert 7 == test(*(), **{'x': 7}) try: test(*(1,), **7) print('TypeError expected') except TypeError: pass try: test(*(1,), **{7:3}) print('TypeError expected') except TypeError: pass try: ...
def test(x): return x assert 7 == test(*(7,)) assert 7 == test(*(), **{'x': 7}) try: test(*(1,), **7) print('TypeError expected') except TypeError: pass try: test(*(1,), **{7: 3}) print('TypeError expected') except TypeError: pass try: test(*(1,), **None) print('TypeError expected') ...
class ResponseCookie: def __init__(self, name, value, expires, max_age, domain, path, secure, http_only): self._name = name self._value = value self._expires = expires self._max_age = max_age self._domain = domain self._path = path self._secure = secure ...
class Responsecookie: def __init__(self, name, value, expires, max_age, domain, path, secure, http_only): self._name = name self._value = value self._expires = expires self._max_age = max_age self._domain = domain self._path = path self._secure = secure ...
def isValid(self, s: str) -> bool: stack = [] closeToOpen = {')':'(',']':'[','}':'{'} # dictionarry mappin to avoid alot of if staements for symbol in s : if symbol in closeToOpen:#because the key is always the closing parenthesis if stack and stack...
def is_valid(self, s: str) -> bool: stack = [] close_to_open = {')': '(', ']': '[', '}': '{'} for symbol in s: if symbol in closeToOpen: if stack and stack[-1] == closeToOpen[symbol]: stack.pop() else: return False else: sta...
class Temperature(object): ''' Used to model the temperature value = 0 - Not known value = 1 - < 25 degrees value = 2 - => 25 ''' def __init__(self, value = 0, created = False): self.value = value self.created = created @property def value(self): return sel...
class Temperature(object): """ Used to model the temperature value = 0 - Not known value = 1 - < 25 degrees value = 2 - => 25 """ def __init__(self, value=0, created=False): self.value = value self.created = created @property def value(self): return self._v...
#!/usr/bin/python3 number = 2 number = number * number * number print (number * number * number) print ("!@#$%^&*()-=") # testing character matching
number = 2 number = number * number * number print(number * number * number) print('!@#$%^&*()-=')
new_fruit=input('what fruit am I sorting?') if new_fruit == Apple: print ('Bin 1') elif new_fruit == Orange: print ('Bin 2') elif new_fruit == Olive: print ('Bin 3') else: print('Error! I do not recognize this fruit')
new_fruit = input('what fruit am I sorting?') if new_fruit == Apple: print('Bin 1') elif new_fruit == Orange: print('Bin 2') elif new_fruit == Olive: print('Bin 3') else: print('Error! I do not recognize this fruit')
#Empty print for not disturbing the unit tests output def myPrint( str ): pass def add( i, j): return i + j def subtract( i, j): return i - j def innerFunction(): pass def outerFunction(): innerFunction() def noParamsFunction(): return MyClass() def mySubstring( st...
def my_print(str): pass def add(i, j): return i + j def subtract(i, j): return i - j def inner_function(): pass def outer_function(): inner_function() def no_params_function(): return my_class() def my_substring(str, length): return str[:length] def process_list(aList): my_print('...
# https://www.codewars.com/kata/522551eee9abb932420004a0/train/python ''' Instructions : I love Fibonacci numbers in general, but I must admit I love some more than others. I would like for you to write me a function that when given a number (n) returns the n-th number in the Fibonacci Sequence. For example: nt...
""" Instructions : I love Fibonacci numbers in general, but I must admit I love some more than others. I would like for you to write me a function that when given a number (n) returns the n-th number in the Fibonacci Sequence. For example: nth_fib(4) == 2 Because 2 is the 4th number in the Fibonacci Sequence. F...
class c(): def __init__(self) : self.h = {0:0,1:1} self.max = 1 def fib(self,n): if n in self.h: return self.h[n] for i in range(self.max+1,n+1): self.h[i] = self.h[i-1]+self.h[i-2] return self.h[n] Fib = c() for i in range(3): ...
class C: def __init__(self): self.h = {0: 0, 1: 1} self.max = 1 def fib(self, n): if n in self.h: return self.h[n] for i in range(self.max + 1, n + 1): self.h[i] = self.h[i - 1] + self.h[i - 2] return self.h[n] fib = c() for i in range(3): r ...
def main(): in_string = input() counts = [0] * 26 for c in in_string: counts[ord(c) - 65] += 1 palindrome = "" middle = "" for i in range(26): if counts[i] % 2 == 1: if middle: print("NO SOLUTION") return middle = chr(65 + ...
def main(): in_string = input() counts = [0] * 26 for c in in_string: counts[ord(c) - 65] += 1 palindrome = '' middle = '' for i in range(26): if counts[i] % 2 == 1: if middle: print('NO SOLUTION') return middle = chr(65 + i...
# 3. Write a recursive Python function that returns the sum of the first # n integers. (Hint: The function will be similar to the factorial function!) # ie sum_nint(3) = 1 + 2 + 3 = 6 , sum_nint(4) = 1 + 2 + 3 + 4 = 10. def sum_nint(num): ''' recursive sum of integers num = last integer in range ''' ...
def sum_nint(num): """ recursive sum of integers num = last integer in range """ if num == 1: return 1 else: return num + sum_nint(num - 1) def main(): print('Test cases') n = 3 print('Sum of first', n, 'integers is', sum_nint(n)) n = 4 print('Sum of first', ...
''' 07 - Removing missing values: Now that you know there are some missing values in your DataFrame, you have a few options to deal with them. One way is to remove them from the dataset completely. In this exercise, you'll remove missing values by removing all rows that contain missing values. pandas has be...
""" 07 - Removing missing values: Now that you know there are some missing values in your DataFrame, you have a few options to deal with them. One way is to remove them from the dataset completely. In this exercise, you'll remove missing values by removing all rows that contain missing values. pandas has be...
#### Regulation B IGNORE_DEFINITIONS_IN_PART_1002 = [ 'International Banking Act of 1978', 'Packers and Stockyards Act', 'Federal Reserve Act', 'Federal Credit Unions', 'National Credit Union Administration', 'Federal Intermediate Credit Banks', 'Production Credit Associations', 'Farm C...
ignore_definitions_in_part_1002 = ['International Banking Act of 1978', 'Packers and Stockyards Act', 'Federal Reserve Act', 'Federal Credit Unions', 'National Credit Union Administration', 'Federal Intermediate Credit Banks', 'Production Credit Associations', 'Farm Credit Administration', 'Equal Credit Opportunity', '...
# Author: btjanaka (Bryon Tjanaka) # Problem: (HackerRank) and-product # Title: AND Product # Link: https://www.hackerrank.com/challenges/and-product/problem # Idea: The problem boils down to finding the leftmost non-aligned bit between # two numbers, i.e. the leftmost bit that is not identical in a and b. We know # th...
n = int(input()) for _ in range(n): (a, b) = map(int, input().split()) nonaligned_pos = -1 for pos in range(32, -1, -1): a_bit = a & 1 << pos b_bit = b & 1 << pos if a_bit != b_bit: nonaligned_pos = pos break if nonaligned_pos == -1: print(a) ...
with open("/Users/mccoybecker/Documents/GitHub/scratch-code/numbers.txt", "r") as myfile: data=myfile.read().replace('\n', '') print(data) max = 0 for i in range(len(data)-12): product = 1 for j in range(i,13+i): product = product * int(data[j]) if product > max: max = product print(ma...
with open('/Users/mccoybecker/Documents/GitHub/scratch-code/numbers.txt', 'r') as myfile: data = myfile.read().replace('\n', '') print(data) max = 0 for i in range(len(data) - 12): product = 1 for j in range(i, 13 + i): product = product * int(data[j]) if product > max: max = product pri...
# An n-bit gray code sequence is a sequence of 2n integers where: # Every integer is in the inclusive range [0, 2n - 1], # The first integer is 0, # An integer appears no more than once in the sequence, # The binary representation of every pair of adjacent integers differs by exactly one bit, and # The binary re...
class Solution: def gray_code(self, n: int) -> List[int]: res = [] for i in range(1 << n): res.append(i ^ i >> 1) return res
#! /usr/bin/env python3.7 def find_active_cat(game_categories, title): in_title = [] position = {} title = title.lower() for k in list(game_categories.keys()): if k.lower() in title: in_title.append(k) position[k] = title.find(k.lower()) in_title = list(set(in_title...
def find_active_cat(game_categories, title): in_title = [] position = {} title = title.lower() for k in list(game_categories.keys()): if k.lower() in title: in_title.append(k) position[k] = title.find(k.lower()) in_title = list(set(in_title)) in_title_len = len(in...