content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
def findRotatedIndexHelper(arr,item,lo,hi): if hi <= lo: return -1 mid = (lo + hi)//2 if arr[mid] == item: return mid elif item < arr[mid]: hi = mid -1 return findRotatedIndexHelper(arr,item,lo,hi) else: lo = mid + 1 return findRotatedIndexHelper(arr,i...
def find_rotated_index_helper(arr, item, lo, hi): if hi <= lo: return -1 mid = (lo + hi) // 2 if arr[mid] == item: return mid elif item < arr[mid]: hi = mid - 1 return find_rotated_index_helper(arr, item, lo, hi) else: lo = mid + 1 return find_rotated_...
while True: n = int(input('Deseja ver qual Tabuada? ')) if n < 0: break print('-+'*15) for c in range(1, 11): print(f'{n} X {c} = {n * c}') print('-+' * 15) print('Programa de Tabuada Encerrado. Volte Sempre!')
while True: n = int(input('Deseja ver qual Tabuada? ')) if n < 0: break print('-+' * 15) for c in range(1, 11): print(f'{n} X {c} = {n * c}') print('-+' * 15) print('Programa de Tabuada Encerrado. Volte Sempre!')
#----------------------------------------------------------------------------- # Runtime: 28ms # Memory Usage: # Link: #----------------------------------------------------------------------------- class Solution: def removeElement(self, nums: list, val: int) -> int: if nums is None or len(nums) == 0: ...
class Solution: def remove_element(self, nums: list, val: int) -> int: if nums is None or len(nums) == 0: return 0 result = 0 for i in range(len(nums)): if nums[i] != val: nums[result] = nums[i] result += 1 return result
def is_moving_top_right(velocity): return velocity.x > 0 and velocity.y < 0 def is_moving_bottom_right(velocity): return velocity.x > 0 and velocity.y > 0 def is_moving_bottom_left(velocity): return velocity.x < 0 and velocity.y > 0 def is_moving_top_left(velocity): return velocity.x ...
def is_moving_top_right(velocity): return velocity.x > 0 and velocity.y < 0 def is_moving_bottom_right(velocity): return velocity.x > 0 and velocity.y > 0 def is_moving_bottom_left(velocity): return velocity.x < 0 and velocity.y > 0 def is_moving_top_left(velocity): return velocity.x < 0 and velocity...
# Taking input from user n = int(input()) # if-else statement for condition checking. if n % 2 == 0: #(if remainder after dividing is 0 its divisible by 2) print("Even") else: #(this statement will be executed after failure of if block) print("Odd")
n = int(input()) if n % 2 == 0: print('Even') else: print('Odd')
# do not change these parameters here seq_len = 20 seq_len_few_shot = 2 batch_size_few_shot = 20 eval_only_last = False eps_corr = None mask_dims = False def set_parameters(args): params_dict = vars(args) global seq_len global seq_len_mnist global seq_len_few_shot if 'seq_len' in params_dict: ...
seq_len = 20 seq_len_few_shot = 2 batch_size_few_shot = 20 eval_only_last = False eps_corr = None mask_dims = False def set_parameters(args): params_dict = vars(args) global seq_len global seq_len_mnist global seq_len_few_shot if 'seq_len' in params_dict: seq_len = params_dict['seq_len'] ...
class Solution: def numJewelsInStones(self, J: str, S: str) -> int: jewel_dict = {} jewel_count = 0 for jewel in J: jewel_dict[jewel] = True for stone in S: if stone in jewel_dict: jewel_count += 1 ret...
class Solution: def num_jewels_in_stones(self, J: str, S: str) -> int: jewel_dict = {} jewel_count = 0 for jewel in J: jewel_dict[jewel] = True for stone in S: if stone in jewel_dict: jewel_count += 1 return jewel_count
# Have the function SwitchSort(arr) take arr which will be an an array consisting of integers # 1...size(arr) and determine what the fewest number of steps is in order to sort the array # from least to greatest using the following technique: Each element E in the array can swap # places with another element that is ...
def switch_sort(arr): swaps = 0 sorted_arr = sorted(arr) while arr != sorted_arr: for i in range(len(arr)): idx_right = (i + arr[i]) % len(arr) idx_left = (i - arr[i]) % len(arr) idx_desired = arr[i] - 1 if arr[i] == sorted_arr[i]: cont...
def run_game(sequence, limit=100, verbose=True): def run_step(seq): new = [] for n in range(len(seq) - 1): new.append(abs(seq[n] - seq[n + 1])) new.append(abs(seq[0] - seq[-1])) return new current = sequence step = 1 monster = [current] first_indices = {t...
def run_game(sequence, limit=100, verbose=True): def run_step(seq): new = [] for n in range(len(seq) - 1): new.append(abs(seq[n] - seq[n + 1])) new.append(abs(seq[0] - seq[-1])) return new current = sequence step = 1 monster = [current] first_indices = {t...
if input(): v1 = 1 else: v1 = 2 v2 = v1
if input(): v1 = 1 else: v1 = 2 v2 = v1
__version__ = '0.2.1.1' __author__ = 'Gil Ferreira Hoben' __author_email__ = 'gil.hoben.16@ucl.ac.uk' __license__ = 'MIT'
__version__ = '0.2.1.1' __author__ = 'Gil Ferreira Hoben' __author_email__ = 'gil.hoben.16@ucl.ac.uk' __license__ = 'MIT'
class Config: TESTING = True SECRET_KEY = 'so_much_testing_secret' SQLALCHEMY_DATABASE_URI = 'sqlite://' SQLALCHEMY_TRACK_MODIFICATIONS = False LOGIN_REQUIRED_DISABLED = True ADMIN_LOGIN_REQUIRED_DISABLED = True
class Config: testing = True secret_key = 'so_much_testing_secret' sqlalchemy_database_uri = 'sqlite://' sqlalchemy_track_modifications = False login_required_disabled = True admin_login_required_disabled = True
msmarco_distilroberta_base_v2 = { "description": "A distilled version of Facebook AI's Base RoBERTa Model. It has been finetuned on the MS MARCO dataset to produce accurate vectors for semantic search.", "tasks": ["text-vectorisation"], "init_kwargs": { "model_path": "msmarco-distilroberta-base-v2",...
msmarco_distilroberta_base_v2 = {'description': "A distilled version of Facebook AI's Base RoBERTa Model. It has been finetuned on the MS MARCO dataset to produce accurate vectors for semantic search.", 'tasks': ['text-vectorisation'], 'init_kwargs': {'model_path': 'msmarco-distilroberta-base-v2', 'max_length': 512}, '...
# O(n) time | O(1) space def longestPeak(array): n = len(array) if n < 3: return 0 max_len = 0 for p in range(1, n - 1): l,r = p,p cur_len = 1 while l - 1 >= 0 and array[l-1] < array[l]: cur_len+=1 l-=1 if l == p: continue ...
def longest_peak(array): n = len(array) if n < 3: return 0 max_len = 0 for p in range(1, n - 1): (l, r) = (p, p) cur_len = 1 while l - 1 >= 0 and array[l - 1] < array[l]: cur_len += 1 l -= 1 if l == p: continue while r +...
# # PySNMP MIB module HPN-ICF-SMLK-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HPN-ICF-SMLK-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 19:29:12 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar ...
(integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_range_constraint, single_value_constraint, value_size_constraint, constraints_intersection, constraints_union) ...
_CONST1 = 42 __CONST2 = 43 class _NotAutoImported: pass class __JustTheSame: pass def _and_again(): def sub_is_private(): pass def _even_with_underscore(): pass class ClassesToo: pass class _ForReal: pass pass def __still_the_same(): pass def but_tha...
_const1 = 42 __const2 = 43 class _Notautoimported: pass class __Justthesame: pass def _and_again(): def sub_is_private(): pass def _even_with_underscore(): pass class Classestoo: pass class _Forreal: pass pass def __still_the_same(): pass def but_...
my_list = [] temp_list = [] answer = 'Y' people = 0 heavy = ['', 0] light = ['', 0] while answer == 'Y': print('=' * 50) temp_list.append(str(input('Enter a name: '))) temp_list.append(float(input('Enter the weight of this person: '))) if heavy == ['', 0]: heavy = temp_list[:] light = ...
my_list = [] temp_list = [] answer = 'Y' people = 0 heavy = ['', 0] light = ['', 0] while answer == 'Y': print('=' * 50) temp_list.append(str(input('Enter a name: '))) temp_list.append(float(input('Enter the weight of this person: '))) if heavy == ['', 0]: heavy = temp_list[:] light = te...
# constants relating to the player's physics and controls SIMPLE_MOVE_SPEED = 200 MASS = 0.01 MOVE_FORCE = MASS * 1.4e3
simple_move_speed = 200 mass = 0.01 move_force = MASS * 1400.0
''' Author: Hans Erik Heggem Email: hans.erik.heggem@gmail.com Project: Master's Thesis - Autonomous Inspection Of Wind Blades Repository: Master's Thesis - CV (Computer Vision) ''' class PtGreyError(Exception): def __init__(self, error_key=None): '''CONSTRUCTOR''' self.__error_messages = { 'import_fc2_error_...
""" Author: Hans Erik Heggem Email: hans.erik.heggem@gmail.com Project: Master's Thesis - Autonomous Inspection Of Wind Blades Repository: Master's Thesis - CV (Computer Vision) """ class Ptgreyerror(Exception): def __init__(self, error_key=None): """CONSTRUCTOR""" self.__error_messages = {'im...
# https://www.codewars.com/kata/526571aae218b8ee490006f4/train/python # Write a function that takes an integer as input, and returns the # number of bits that are equal to one in the binary representation # of that number. You can guarantee that input is non-negative. # Example: The binary representation of 1234 i...
def count_bits(n): binary = f'{n:b}' return len([char for char in binary if char == '1'])
def phonebook(n): data = [] while 1 <= n <= 1e5: data.append(input().split(' ')) n -= 1 return data def queries(n): phone = dict(phonebook(n)) while True: try: query = input() if phone.get(query): print('{}={}'.format(query, phone[que...
def phonebook(n): data = [] while 1 <= n <= 100000.0: data.append(input().split(' ')) n -= 1 return data def queries(n): phone = dict(phonebook(n)) while True: try: query = input() if phone.get(query): print('{}={}'.format(query, phone...
class ClothCollisionSettings: collision_quality = None damping = None distance_min = None distance_repel = None friction = None group = None repel_force = None self_collision_quality = None self_distance_min = None self_friction = None use_collision = None use_self_collis...
class Clothcollisionsettings: collision_quality = None damping = None distance_min = None distance_repel = None friction = None group = None repel_force = None self_collision_quality = None self_distance_min = None self_friction = None use_collision = None use_self_collis...
# for constants which need to be accessed by various parts of Sentinel # skip proposals on governanceblock creation if the SB isn't within the fudge window GOVERNANCEBLOCK_FUDGE_WINDOW = 60 * 60 * 2
governanceblock_fudge_window = 60 * 60 * 2
# Given two binary trees s and t, check if t is a subtree of s. # A subtree of a tree t is a tree consisting of a node in t and # all of its descendants in t. # Example 1: # Given s: # 3 # / \ # 4 5 # / \ # 1 2 # Given t: # 4 # / \ # 1 2 # Return true, because t is a subtree of s. # Exa...
def is_subtree(big, small): flag = False queue = collections.deque() queue.append(big) while queue: node = queue.popleft() if node.val == small.val: flag = comp(node, small) break else: queue.append(node.left) queue.append(node.righ...
class LazyOperation: def __init__(self, function, *args, **kwargs): self.function = function self.args = args self.kwargs = kwargs def __call__(self, *args, **kwargs): return LazyOperation(self.function, *args, **kwargs) def eval(self): newargs = list() for ...
class Lazyoperation: def __init__(self, function, *args, **kwargs): self.function = function self.args = args self.kwargs = kwargs def __call__(self, *args, **kwargs): return lazy_operation(self.function, *args, **kwargs) def eval(self): newargs = list() fo...
# FizzBuzz Without using modulus operator (%) # Author: @gahan9 def reminder_finder(number, divisor=3): if number < divisor: return number reminder = reminder_finder(number, divisor << 1) if reminder >= divisor: return reminder - divisor return reminder print(*("Fizz" * (reminder_fin...
def reminder_finder(number, divisor=3): if number < divisor: return number reminder = reminder_finder(number, divisor << 1) if reminder >= divisor: return reminder - divisor return reminder print(*('Fizz' * (reminder_finder(i, 3) == 0) + 'Buzz' * (reminder_finder(i, 5) == 0) or str(i) fo...
lst=[20,30,40,234] print(type(lst)) b=bytes(lst) print(type(b)) #b[3]=22 b1=bytearray(lst) print(type(b1)) b1[2]=33
lst = [20, 30, 40, 234] print(type(lst)) b = bytes(lst) print(type(b)) b1 = bytearray(lst) print(type(b1)) b1[2] = 33
class Tateti: def __init__(self): self.tablero = list(range(0, 9)) self.turno = 9 def jugada(self, p: int): p = int(p) while p not in self.tablero: p = int(input("Ingrese otro casillero: ")) self.tablero[int(p)] = self.turno if self.hay_ganador(): ...
class Tateti: def __init__(self): self.tablero = list(range(0, 9)) self.turno = 9 def jugada(self, p: int): p = int(p) while p not in self.tablero: p = int(input('Ingrese otro casillero: ')) self.tablero[int(p)] = self.turno if self.hay_ganador(): ...
description = 'TUD-SMI Motors' pvprefix = 'TUD-SMI:MC-MCU-01:' devices = dict( tudsmi_m1 = device('nicos_ess.devices.epics.motor.EpicsMotor', description = 'Motor 1', lowlevel = False, unit = 'mm', fmtstr = '%.2f', ...
description = 'TUD-SMI Motors' pvprefix = 'TUD-SMI:MC-MCU-01:' devices = dict(tudsmi_m1=device('nicos_ess.devices.epics.motor.EpicsMotor', description='Motor 1', lowlevel=False, unit='mm', fmtstr='%.2f', abslimits=(-20, 20), epicstimeout=3.0, precision=0.1, motorpv=pvprefix + 'm1', errormsgpv=pvprefix + 'm1-MsgTxt', er...
'''CRYPTO-ENGINE: Configuration Parameters''' '''Key Generation: Public-private Key pair. Algorithms supported: RSA and ECDSA with keysize 2048 and 4096. Different encoding formats are supported for private-key, the crypto engine also supports SSH format.''' CONF_ASYMMETRIC={'protocol':['RSA','ECDSA'], 'keysize':[204...
"""CRYPTO-ENGINE: Configuration Parameters""" 'Key Generation: Public-private Key pair. Algorithms supported:\nRSA and ECDSA with keysize 2048 and 4096. Different encoding formats are supported\nfor private-key, the crypto engine also supports SSH format.' conf_asymmetric = {'protocol': ['RSA', 'ECDSA'], 'keysize': [20...
##Patterns:E0117 def test(): def parent(): a = 42 def stuff(): nonlocal a c = 24 def parent2(): a = 42 def stuff(): def other_stuff(): nonlocal a nonlocal c b = 42 def func(): def other_func(): ##Err: E0117...
def test(): def parent(): a = 42 def stuff(): nonlocal a c = 24 def parent2(): a = 42 def stuff(): def other_stuff(): nonlocal a nonlocal c b = 42 def func(): def other_func(): nonlocal b class Somecl...
# Read three values (variables A, B and C), which are the three student's grades. # Then, calculate the average, considering that grade A has weight 2, grade B has weight 3 and the grade C has weight 5. # Consider that each grade can go from 0 to 10.0, always with one decimal place. WEIGHT_FIRST_GRADE = 2.0 WEIGHT_SEC...
weight_first_grade = 2.0 weight_second_grade = 3.0 weigth_third_grade = 5.0 first_grade = float(input()) second_grade = float(input()) third_grade = float(input()) print('MEDIA = {:.1f}'.format((first_grade * WEIGHT_FIRST_GRADE + second_grade * WEIGHT_SECOND_GRADE + third_grade * WEIGTH_THIRD_GRADE) / (WEIGHT_FIRST_GRA...
n=int(input("Enter Number ...")) arm=0 temp=n while temp>0: rem=temp%10 arm=arm+(rem**3) temp//=10 if arm==n: print("Number is armstrong..") else: print("Number is not armstrong..")
n = int(input('Enter Number ...')) arm = 0 temp = n while temp > 0: rem = temp % 10 arm = arm + rem ** 3 temp //= 10 if arm == n: print('Number is armstrong..') else: print('Number is not armstrong..')
X = int(input()) cnt = 0 ans = [] length = len(bin(X)[2:]) bi = bin(X)[2:] for i in range(length): bit = bi[i] if bit == "1": continue else: ans.append(length - i) cnt += 1 X = X ^ (2 ** (length - i) - 1) bi = bin(X)[2:] f = True for b in bi: ...
x = int(input()) cnt = 0 ans = [] length = len(bin(X)[2:]) bi = bin(X)[2:] for i in range(length): bit = bi[i] if bit == '1': continue else: ans.append(length - i) cnt += 1 x = X ^ 2 ** (length - i) - 1 bi = bin(X)[2:] f = True for b in bi: ...
def str_time(seconds): res = "" if seconds < 60: res = str(round(seconds, 2)) + " s" elif seconds < 3600: res = str(round(seconds / 60.0, 2)) + " min" elif seconds < 3600 * 24: res = str(round(seconds / 3600.0, 2)) + " h" elif seconds < 3600 * 24 * 7: res = str(round(seconds / (3600 * 24.0), 2)) + " d" el...
def str_time(seconds): res = '' if seconds < 60: res = str(round(seconds, 2)) + ' s' elif seconds < 3600: res = str(round(seconds / 60.0, 2)) + ' min' elif seconds < 3600 * 24: res = str(round(seconds / 3600.0, 2)) + ' h' elif seconds < 3600 * 24 * 7: res = str(round(...
single = 18 apartment = 25 president = 35 stay = int(input()) nights = stay - 1 room_type = input() review = input() if room_type == "room for one person": total_cost = nights * single elif room_type == "apartment": total_cost = nights * apartment if stay < 10: total_cost *= 0.7 elif 10 <= st...
single = 18 apartment = 25 president = 35 stay = int(input()) nights = stay - 1 room_type = input() review = input() if room_type == 'room for one person': total_cost = nights * single elif room_type == 'apartment': total_cost = nights * apartment if stay < 10: total_cost *= 0.7 elif 10 <= stay ...
# different ways to loop def printN_for(n, str): for i in range(n): print(str) def printN_while(n, str): while n >= 0: print(str) n -= 1 def printN_recursion(n, str): if n >= 0: print(str) printN_recursion(n - 1, str) printN_for(3, "Hello, For!") printN_for(3,...
def print_n_for(n, str): for i in range(n): print(str) def print_n_while(n, str): while n >= 0: print(str) n -= 1 def print_n_recursion(n, str): if n >= 0: print(str) print_n_recursion(n - 1, str) print_n_for(3, 'Hello, For!') print_n_for(3, 'Hello, While!') print_n...
OFFSET = 400 X = 0 Y = 1 Z = 2 W = 3 V = 4 SCREENSIZE = (800, 800)
offset = 400 x = 0 y = 1 z = 2 w = 3 v = 4 screensize = (800, 800)
# https://atcoder.jp/contests/abc210/tasks/abc210_b N = int(input()) S = input() for i in range(N): if S[i] == '1': if i % 2 == 0: print('Takahashi') exit() else: print('Aoki') exit()
n = int(input()) s = input() for i in range(N): if S[i] == '1': if i % 2 == 0: print('Takahashi') exit() else: print('Aoki') exit()
class GraphHandle(object): def __init__(self, name, graph_cls, init_args, setup_args, graph_name, parent, framework='ray', machine="", resources=None): # E...
class Graphhandle(object): def __init__(self, name, graph_cls, init_args, setup_args, graph_name, parent, framework='ray', machine='', resources=None): self.name = name if name else '{0}_{1}'.format(op_cls.__class__.__name__, hash(self)) assert '/' not in self.name, 'Operator name {} contains slash...
class AbstractParserOperation(object): _custom_name = "Here place operation name" @property def name(self): return self._custom_name @property def desc(self): #return "Description " + self._custom_name return '' def __init__(self): return def apply(self, i...
class Abstractparseroperation(object): _custom_name = 'Here place operation name' @property def name(self): return self._custom_name @property def desc(self): return '' def __init__(self): return def apply(self, image): return def arg_html(self): ...
a=int(input("enter you first number:")) b=int(input("enter your second number:")) sum=a+b print("sum is =",sum) diff=a-b print("diff is =",diff) mul=a*b print("mul is =",mul) quo=a/b print("quo is =",quo) remain=a%b print("remain is =",remain) power=a**b print("power is =",power) intd=a//b print("the int...
a = int(input('enter you first number:')) b = int(input('enter your second number:')) sum = a + b print('sum is =', sum) diff = a - b print('diff is =', diff) mul = a * b print('mul is =', mul) quo = a / b print('quo is =', quo) remain = a % b print('remain is =', remain) power = a ** b print('power is =', power) intd ...
''' Create a list containing all integers within a given range. If first argument is smaller than second, produce a list in decreasing order. Example: * (range 4 9) (4 5 6 7 8 9) ''' #new list creation demo_list = list() #taking starting and ending point as inputs start_point,end_point = input("E...
""" Create a list containing all integers within a given range. If first argument is smaller than second, produce a list in decreasing order. Example: * (range 4 9) (4 5 6 7 8 9) """ demo_list = list() (start_point, end_point) = input('Enter starting and ending point seperating by colon(:)-> ').spl...
n1 = int(input('Digite um valor: '))#observacao colocar o tipo de dados, porque senao o python ira concatenar(pois ele ire achar que uma string) n2 = int(input('Digite outro valor: ')) soma = n1 + n2 #print('A soma entre', n1, "e", n2 , 'vale', soma) print(f'A soma entre {n1} e {n2} vale {soma}') #sintaxe nova com meto...
n1 = int(input('Digite um valor: ')) n2 = int(input('Digite outro valor: ')) soma = n1 + n2 print(f'A soma entre {n1} e {n2} vale {soma}')
class AttackDatasetConfig(object): def __init__(self, type, train=[], test=[], target_label=None, remove_from_benign_dataset=False, augment_times=0, augment_data=False, tasks=None, source_label=None, ...
class Attackdatasetconfig(object): def __init__(self, type, train=[], test=[], target_label=None, remove_from_benign_dataset=False, augment_times=0, augment_data=False, tasks=None, source_label=None, aux_samples=None, edge_case_type=None, edge_case_p=1.0, pixel_pattern_type=None, max_test_batches=None): se...
class Value: def __hash__(self): return hash(self.value) def __eq__(self, o: object) -> bool: if isinstance(o, self.__class__): o: Value return self.value == o.value else: return False def __init__(self, value, ): self.value = value ...
class Value: def __hash__(self): return hash(self.value) def __eq__(self, o: object) -> bool: if isinstance(o, self.__class__): o: Value return self.value == o.value else: return False def __init__(self, value): self.value = value d...
# # PySNMP MIB module HH3C-DOT11S-MESH-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HH3C-DOT11S-MESH-MIB # Produced by pysmi-0.3.4 at Wed May 1 13:26:24 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (defau...
(object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_union, value_range_constraint, constraints_intersection, single_value_constraint, value_size_constraint) ...
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # This is file111 print("This is file111")
print('This is file111')
# We've seen a few arithmetic expressions so far, like addition, # subtraction, and division. Remember when we turned Python into a # calculator? Well, Python can also compare values. This lets us check # whether something is smaller than, equal to, or bigger than something # else. This allows us to take the result of ...
print('cat' > 'Cat')
# The list of candies to print to the screen candyList = ["Snickers", "Kit Kat", "Sour Patch Kids", "Juicy Fruit", "Swedish Fish", "Skittles", "Hershey Bar", "Starbursts", "M&Ms"] # The amount of candy the user will be allowed to choose allowance = 5 # The list used to store all of the candies selected i...
candy_list = ['Snickers', 'Kit Kat', 'Sour Patch Kids', 'Juicy Fruit', 'Swedish Fish', 'Skittles', 'Hershey Bar', 'Starbursts', 'M&Ms'] allowance = 5 candy_cart = [] for i in range(len(candyList)): print('[' + str(i) + '] ' + candyList[i])
class Node: # Constructor to initialize a node def __init__(self, data): self.data = data self.next = None class Stack: def __init__(self) : self.head = None # The method push to push element into # the stack def push(self, data): temp = Node(data) if self...
class Node: def __init__(self, data): self.data = data self.next = None class Stack: def __init__(self): self.head = None def push(self, data): temp = node(data) if self.head is None: self.head = temp else: temp.next = self.head ...
#------------------------------------------------------------------------------- # Name: module1 # Purpose: # # Author: Administrator # # Created: 08/10/2011 # Copyright: (c) Administrator 2011 # Licence: <your licence> #--------------------------------------------------------------------...
class Gol01: def __init__(self): pass def __init__(self, size): self.size = size self.field = [[0] * size for _ in range(size)] pass def init_field(self, a): self.field = a def num_neighbours_old(self, x, y): return 3 if x != 0 else 1 def num_neig...
def d(n): num = 0 for i in str(n): num += int(i) return n + num def getSelfNumber(): notSelfNumber = [] for i in range(0, 10001): notSelfNumber.append(d(i)) for j in range(0, 10001): if j in notSelfNumber: continue print(j) getSelfNumber()
def d(n): num = 0 for i in str(n): num += int(i) return n + num def get_self_number(): not_self_number = [] for i in range(0, 10001): notSelfNumber.append(d(i)) for j in range(0, 10001): if j in notSelfNumber: continue print(j) get_self_number()
# program to calculate percentage increase # made by itsmeevil def percentageIncrease(startNumber, finalNumber): percentageIncrease = round(((finalNumber - startNumber) / startNumber) * 100, 2) return f"{percentageIncrease}%" print("***Percentage Increase Calculator***\n") startNumber = float(input("Enter th...
def percentage_increase(startNumber, finalNumber): percentage_increase = round((finalNumber - startNumber) / startNumber * 100, 2) return f'{percentageIncrease}%' print('***Percentage Increase Calculator***\n') start_number = float(input('Enter the starting value: ')) final_number = float(input('Enter the final...
__author__ = 'dipsy' providers = { "1": "Backpage", "2": "Craigslist", "3": "Classivox", "4": "MyProviderGuide", "5": "NaughtyReviews", "6": "Redbook", "7": "Cityvibe", "8": "Massagetroll", "9": "Redbook Forum", "10": "Cityxguide", "11": "Cityxguide Forum", "12": "Rubads", "13": "Anunico", "14": "SipSap", "...
__author__ = 'dipsy' providers = {'1': 'Backpage', '2': 'Craigslist', '3': 'Classivox', '4': 'MyProviderGuide', '5': 'NaughtyReviews', '6': 'Redbook', '7': 'Cityvibe', '8': 'Massagetroll', '9': 'Redbook Forum', '10': 'Cityxguide', '11': 'Cityxguide Forum', '12': 'Rubads', '13': 'Anunico', '14': 'SipSap', '15': 'Escorts...
def preceeded_by(string): return r"(?<={})".format(string) def followed_by(string): return r"(?={})".format(string) def not_preceeded_by(string): return r"(?<!{})".format(string) def not_followed_by(string): return r"(?!{})".format(string)
def preceeded_by(string): return '(?<={})'.format(string) def followed_by(string): return '(?={})'.format(string) def not_preceeded_by(string): return '(?<!{})'.format(string) def not_followed_by(string): return '(?!{})'.format(string)
#!/usr/bin/env python # # brief: defines the food class, and some useful functions, for use in soylent calculator # author: bto # date: Jun 2013 # ------------------------------------------------------------- # conversions def kcal2j(kcal): return 4184*kcal def iu2g(mineral, iu): factor = { 'vitamin ...
def kcal2j(kcal): return 4184 * kcal def iu2g(mineral, iu): factor = {'vitamin a': 3e-07, 'vitamin c': 5e-05, 'vitamin d': 2.5e-08, 'vitamin e': 0.000667} if mineral in factor.keys(): return factor[mineral] * iu else: print("'%s' is not in conversion list" % mineral) sys.exit() ...
def s(j, w): return 12 * j * w + 10 * j for j in [5, 20, 50]: for w in [100, 1000, 10000]: print(j, w, s(j, w / 24 / 7) * 24 * 7 / 1000)
def s(j, w): return 12 * j * w + 10 * j for j in [5, 20, 50]: for w in [100, 1000, 10000]: print(j, w, s(j, w / 24 / 7) * 24 * 7 / 1000)
N,A,B = map(int,input().split()) P,Q,R,S = map(int,input().split()) ans=[] #for i in range(N): # ans.append(["."]*N) left_up = max(1-A,1-B) right_up = min(N-A,N-B) left_un = max(1-A,B-N) right_un = min(N-A,B-1) #if(left_up > P): # left_up = P #if(right_up > Q): # right_up = Q #if(left_un < R): # left_...
(n, a, b) = map(int, input().split()) (p, q, r, s) = map(int, input().split()) ans = [] left_up = max(1 - A, 1 - B) right_up = min(N - A, N - B) left_un = max(1 - A, B - N) right_un = min(N - A, B - 1) flag = 0 for i in range(left_up + P - 1, right_up + Q - P, 1): if 1 <= A + i < N + 1 and 1 <= B + i < N + 1: ...
class pFindMGFReader(object): def __init__(self, filename, **kwargs): self.scan_to_RT_dict = {} with open(filename) as f: scan = -1 while True: line = f.readline() if not line: break if line.startswith("TITLE"): ...
class Pfindmgfreader(object): def __init__(self, filename, **kwargs): self.scan_to_RT_dict = {} with open(filename) as f: scan = -1 while True: line = f.readline() if not line: break if line.startswith('TITL...
#https://www.hackerrank.com/challenges/insert-a-node-at-the-tail-of-a-linked-list/problem?h_r=next-challenge&h_v=zen def insertNodeAtTail(head, data): node = SinglyLinkedListNode(data) a if not head: head=node return head else: current=head ...
def insert_node_at_tail(head, data): node = singly_linked_list_node(data) a if not head: head = node return head else: current = head while current.next: current = current.next current.next = node return head
def handler(event, context): userID = event["userID"] Token = event["Token"] # Any logic that your app should perform. return { "statusCode": 200, "body": "Hello there", "userID" : userID, "Token": Token }
def handler(event, context): user_id = event['userID'] token = event['Token'] return {'statusCode': 200, 'body': 'Hello there', 'userID': userID, 'Token': Token}
# *-* coding: utf-8 *-* class CountriesHelperAD: def __init__(self, app): self.app = app def get_countries_list(self) -> list: wd = self.app.wd self.app.ad_menu.select_countries() countries = [] rows = len(wd.find_elements_by_css_selector('.row')) for i in rang...
class Countrieshelperad: def __init__(self, app): self.app = app def get_countries_list(self) -> list: wd = self.app.wd self.app.ad_menu.select_countries() countries = [] rows = len(wd.find_elements_by_css_selector('.row')) for i in range(rows): coun...
basicHandsPlain = { "8":76145, "89":17316, "22":6961, "89T":2848, "TTQ":1108, "333":193, "c":188474, "hd":121173, "ss":69667, "hcs":68107, "hsh":36166, "ddd":11869, "Td":20825, "A9c":4610, "3cTT":286, "TsThT":97, "TT98":96, "54h32d":16 } #Add in RONY testing basicHandsVars = { "AR":76144, "2RO":75328, "KOO":13296,...
basic_hands_plain = {'8': 76145, '89': 17316, '22': 6961, '89T': 2848, 'TTQ': 1108, '333': 193, 'c': 188474, 'hd': 121173, 'ss': 69667, 'hcs': 68107, 'hsh': 36166, 'ddd': 11869, 'Td': 20825, 'A9c': 4610, '3cTT': 286, 'TsThT': 97, 'TT98': 96, '54h32d': 16} basic_hands_vars = {'AR': 76144, '2RO': 75328, 'KOO': 13296, 'QR...
# Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def swapPairs(self, head: Optional[ListNode]) -> Optional[ListNode]: dummy = ListNode() dummy.next = head prev = dummy ...
class Solution: def swap_pairs(self, head: Optional[ListNode]) -> Optional[ListNode]: dummy = list_node() dummy.next = head prev = dummy curr = head while curr and curr.next: prev.next = curr.next curr.next = curr.next.next prev.next.next ...
''' Menghitung volume kerucut ''' PI = 3.14 masukan_str = input() # Ekspektasi masukan berupa dua angka dipisah dengan spasi alas, tinggi = list(map(float, masukan_str.split())) hasil = ((1/3) * PI * alas**2 * tinggi) print(hasil)
""" Menghitung volume kerucut """ pi = 3.14 masukan_str = input() (alas, tinggi) = list(map(float, masukan_str.split())) hasil = 1 / 3 * PI * alas ** 2 * tinggi print(hasil)
class StylesQueue: def __init__(self): self.styles = {} def add(self, styles): for name, value in styles.items(): if name in self.styles: self.styles[name].append(value) else: self.styles[name] = [value] def remove(self, names): ...
class Stylesqueue: def __init__(self): self.styles = {} def add(self, styles): for (name, value) in styles.items(): if name in self.styles: self.styles[name].append(value) else: self.styles[name] = [value] def remove(self, names): ...
class PurchaseOperation: AUTHORIZATION = 'AUTHORIZATION' SALE = 'SALE' class DefaultPaymentMethod: DIRECTDEBIT = 'DIRECTDEBIT' IDEAL = 'IDEAL' CPA = 'CPA' CREDITCARD = 'CREDITCARD' PX = 'PX' MICROACCOUNT = 'MICROACCOUNT' PAYPAL = 'PAYPAL' INVOICE = 'INVOICE' EVC = 'EVC' ...
class Purchaseoperation: authorization = 'AUTHORIZATION' sale = 'SALE' class Defaultpaymentmethod: directdebit = 'DIRECTDEBIT' ideal = 'IDEAL' cpa = 'CPA' creditcard = 'CREDITCARD' px = 'PX' microaccount = 'MICROACCOUNT' paypal = 'PAYPAL' invoice = 'INVOICE' evc = 'EVC' ...
class SubtitleNotFound(Exception): pass class CastNotFound(Exception): pass
class Subtitlenotfound(Exception): pass class Castnotfound(Exception): pass
# Given an array of non-negative integers, you are initially positioned at the first index of the array. # Each element in the array represents your maximum jump length at that position. # Your goal is to reach the last index in the minimum number of jumps. # For example: # Given array A = [2,3,1,1,4] # The minimum...
class Solution: def jump(self, nums): idx = times = 0 maximum = nums[0] while True: if idx == len(nums) - 1: return times times += 1 base = idx for step in range(nums[idx], 0, -1): at = base + step ...
class FbConstants: GRAPH_API_BASE_URL = 'https://graph.facebook.com' WABAS_EDGE = 'whatsapp_business_accounts' # validate the fields to get (such as status and message throughput) WABAS_FIELDS = [ 'verified_name', 'status', 'quality_rating', 'id', '...
class Fbconstants: graph_api_base_url = 'https://graph.facebook.com' wabas_edge = 'whatsapp_business_accounts' wabas_fields = ['verified_name', 'status', 'quality_rating', 'id', 'display_phone_number', 'thread_limit_per_day'] phone_numbers_edge = 'phone_numbers' message_templates_edge = 'message_tem...
def to_hex(n): # gives string output num=hex(n) return num def twos(string): x=string l=len(x) for i in range(32-len(x)): x='1'+x y=int(x,2) y=~y z=y+4294967297 z=bin(z) z='-'+z return z def decode(instrc): x=int(instrc,16) bin_x="{:032b}".form...
def to_hex(n): num = hex(n) return num def twos(string): x = string l = len(x) for i in range(32 - len(x)): x = '1' + x y = int(x, 2) y = ~y z = y + 4294967297 z = bin(z) z = '-' + z return z def decode(instrc): x = int(instrc, 16) bin_x = '{:032b}'.format(x...
def getvar(self, name): path = self.namespace var = self.variables.get(f'{path}.{name}') while not var and path != '__main__': path = path[:path.rfind('.')] var = self.variables.get(f'{path}.{name}') return var or {} def get_ctx(self): path = self.namespace while path != '__main...
def getvar(self, name): path = self.namespace var = self.variables.get(f'{path}.{name}') while not var and path != '__main__': path = path[:path.rfind('.')] var = self.variables.get(f'{path}.{name}') return var or {} def get_ctx(self): path = self.namespace while path != '__main...
#!/usr/bin/env python3 # -*- coding: utf-8 -*- def create_diagram(x=10, y=10): diagram = [['.' for _ in range(y)] for _ in range(x)] return diagram def get_max_diagram_coords(input_file): max_ = 0 with open(input_file, 'r') as ftr: for line in ftr.readlines(): # 309,347 -> 309,464 line = line....
def create_diagram(x=10, y=10): diagram = [['.' for _ in range(y)] for _ in range(x)] return diagram def get_max_diagram_coords(input_file): max_ = 0 with open(input_file, 'r') as ftr: for line in ftr.readlines(): line = line.strip().split(' ') (x1, y1) = map(int, line[0...
n=int(input()) s1=list(input()) count=0 i=0 while i<n: try: if s1[i]==s1[i+1]: s1.remove(s1[i+1]) count+=1 else: i+=1 except: break print(count)
n = int(input()) s1 = list(input()) count = 0 i = 0 while i < n: try: if s1[i] == s1[i + 1]: s1.remove(s1[i + 1]) count += 1 else: i += 1 except: break print(count)
# # This file contains the piui screen defintions. # Docs on the screen types and fields needed TBD. # # This is currently for the Adafruit SSD1306 OLED 128x64 screen. # On the Adafruit SSD1306 1.3" 128x64 OLED screen, with the default font, # you can fit 20 characters on a single line and 7 lines of text on the screen...
screens = {1: {'screen_type': 'graphics', 'imagefile': '/home/pi/ProtoSat/piui/images/protosat_logo_64.png', 'exit_to': 2}, 2: {'screen_type': 'menu', 'screen_name': 'main_menu', 'first_menu': 3, 'rows': {1: {'type': 'text', 'text': '---- Proto-Sat ----'}, 2: {'type': 'data', 'text': 'IP: ', 'topic': 'psz/sys/ipaddr'},...
# # The MIT License (MIT) # # Copyright (C) 2014 hellosign.com # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy,...
class Hsexception(Exception): """ General HelloSign exception We use this object to raise exceptions when none of its child classes is suitable for use. """ def __init__(self, message): self.message = message self.type = self.__class__.__name__ def __str__(self): retu...
# Padding lines: lines printed but not highlighted # Dotted lines: only show dots def calc_lines_to_highligh(file_len:int, highligth_set:set): padding_set = set([]) dots_set = set([]) for l in highligth_set: before = l-1 after = l+1 dots_before = before-1 dots_after = after+1 if before >= 1: ...
def calc_lines_to_highligh(file_len: int, highligth_set: set): padding_set = set([]) dots_set = set([]) for l in highligth_set: before = l - 1 after = l + 1 dots_before = before - 1 dots_after = after + 1 if before >= 1: padding_set.add(before) if ...
inputs = [] # the list of inputs from the previous layer weights = [[], [], []] # nested list of weights for each node in the layer biases = [] # biad for each node layer_outputs = [] for neuron_weights, neuron_bias in zip(weights, biases): neuron_output = 0 for neuron_input, weight in zip(inputs, neuron_weights...
inputs = [] weights = [[], [], []] biases = [] layer_outputs = [] for (neuron_weights, neuron_bias) in zip(weights, biases): neuron_output = 0 for (neuron_input, weight) in zip(inputs, neuron_weights): neuron_output += neuron_input * weight neuron_output += neuron_bias layer_outputs.append(neuro...
N = input().split() a = int(N[0]) b = int(N[-1]) jieguo = 0 if b == 0: print(N[0] + '/' + N[-1] + '=Error') elif b < 0: jieguo = a / b print("%d/(%d)=%.2f" % (a, b, jieguo)) else: jieguo = a / b print("%d/%d=%.2f" % (a, b, jieguo))
n = input().split() a = int(N[0]) b = int(N[-1]) jieguo = 0 if b == 0: print(N[0] + '/' + N[-1] + '=Error') elif b < 0: jieguo = a / b print('%d/(%d)=%.2f' % (a, b, jieguo)) else: jieguo = a / b print('%d/%d=%.2f' % (a, b, jieguo))
# EG8-24 Day Name List day_number=1 day_names=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'] day_name=day_names[day_number] print(day_name)
day_number = 1 day_names = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] day_name = day_names[day_number] print(day_name)
# TODO: add more filetypes paste_file_types = [ ["All supprted files", ""], ("All files", "*"), ("Plain text", "*.txt"), ("Bash script", "*.sh"), ("Batch script", "*.bat"), ("C file", "*.c"), ("C++ file", "*.cpp"), ("Python file", "*.py"), ("R script file", "*.R") ] for _, extension ...
paste_file_types = [['All supprted files', ''], ('All files', '*'), ('Plain text', '*.txt'), ('Bash script', '*.sh'), ('Batch script', '*.bat'), ('C file', '*.c'), ('C++ file', '*.cpp'), ('Python file', '*.py'), ('R script file', '*.R')] for (_, extension) in paste_file_types[2:]: paste_file_types[0][1] += extensio...
def sum_pairs(ints, s): memo = {} for i in ints: if i in memo: return [memo[i], i] memo[s-i] = i return None
def sum_pairs(ints, s): memo = {} for i in ints: if i in memo: return [memo[i], i] memo[s - i] = i return None
print('Chances are formulaically calculated and precise; percentages rounded to 9th decimal\n') chance_for_31 = 1 / 32 for i in range(1, 7): chance_for_i_31s = chance_for_31**i print(f'Chance to roll {i}IV: 1/{int(1/chance_for_i_31s)} ({chance_for_i_31s:.9%})')
print('Chances are formulaically calculated and precise; percentages rounded to 9th decimal\n') chance_for_31 = 1 / 32 for i in range(1, 7): chance_for_i_31s = chance_for_31 ** i print(f'Chance to roll {i}IV: 1/{int(1 / chance_for_i_31s)} ({chance_for_i_31s:.9%})')
l = int(input()) d = int(input()) x = int(input()) mintemp = d maxtemp = 0 def digits(num): nums = [int(nums) for nums in str(num)] return sum(nums) for i in range(l, d + 1): if digits(i) == x: if i < mintemp: mintemp = i if i > maxtemp: maxtemp = i print(mintemp) ...
l = int(input()) d = int(input()) x = int(input()) mintemp = d maxtemp = 0 def digits(num): nums = [int(nums) for nums in str(num)] return sum(nums) for i in range(l, d + 1): if digits(i) == x: if i < mintemp: mintemp = i if i > maxtemp: maxtemp = i print(mintemp) pr...
print(not True) print(not False) print(True and True) print(False and False) print(True and False) print(False and True) print(True or True) print(False or False) print(True or False) print(False or True)
print(not True) print(not False) print(True and True) print(False and False) print(True and False) print(False and True) print(True or True) print(False or False) print(True or False) print(False or True)
def countBits(num): bitsList = [] for i in range(0, num+1): if i != 0 and (i & (i-1) == 0): bitsList.append(1) elif i == 0: bitsList.append(0) else: num = 0 for j in bin(i): if j == "1": num += 1 ...
def count_bits(num): bits_list = [] for i in range(0, num + 1): if i != 0 and i & i - 1 == 0: bitsList.append(1) elif i == 0: bitsList.append(0) else: num = 0 for j in bin(i): if j == '1': num += 1 ...
# -*- coding: utf-8 -*- # Token which you received from @BotFather token = 'Numbers:SomeHashSymbols' # List of user IDs who can send command to Telegram bot admin = ['012345678','1234567890','123456789']
token = 'Numbers:SomeHashSymbols' admin = ['012345678', '1234567890', '123456789']
'''104. Maximum Depth of Binary Tree Easy 2256 69 Add to List Share Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. Note: A leaf is a node with no children. Example: Given binary t...
"""104. Maximum Depth of Binary Tree Easy 2256 69 Add to List Share Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. Note: A leaf is a node with no children. Example: Given binary tree [3,9,20,null,nul...
# THIS FILE IS GENERATED FROM SCIPY SETUP.PY short_version = '0.17.0' version = '0.17.0' full_version = '0.17.0' git_revision = '4b17e2bcbed2ef65cd14923a1ed5d1ccb6d8f8aa' release = True if not release: version = full_version
short_version = '0.17.0' version = '0.17.0' full_version = '0.17.0' git_revision = '4b17e2bcbed2ef65cd14923a1ed5d1ccb6d8f8aa' release = True if not release: version = full_version
DEBUG = True SECRET_KEY = 'chave-do-form' SQLALCHEMY_DATABASE_URI = 'sqlite:///storage.db' SQLALCHEMY_TRACK_MODIFICATIONS = True
debug = True secret_key = 'chave-do-form' sqlalchemy_database_uri = 'sqlite:///storage.db' sqlalchemy_track_modifications = True
try: x except: y finally: z
try: x except: y finally: z
letter = '''Dear <|NAME|>, Greetings from ABC coding house. I am happy to tell you about your selection You are selected! Have a great day ahead! Thanks and regards, Bill Date: <|DATE|> ''' name = input("Enter Your Name\n") date = input("Enter Date\n") letter = letter.replace("<|NAME|>", name) letter = lette...
letter = 'Dear <|NAME|>,\nGreetings from ABC coding house. I am happy to tell you about your selection\nYou are selected!\nHave a great day ahead!\nThanks and regards,\nBill\nDate: <|DATE|>\n' name = input('Enter Your Name\n') date = input('Enter Date\n') letter = letter.replace('<|NAME|>', name) letter = letter.replac...
# Copyright (c) 2014 . All rights reserved. # Use of this source code is governed by the APACHE 2.0 license that can be # found in the LICENSE file. # Author: Frederick Lefebre <frederick.lefebvre@calculquebec.ca> class lustre_mdt_stats : timestamp = 0.0 nb_open = 0 nb_close = 0 nb_mknod ...
class Lustre_Mdt_Stats: timestamp = 0.0 nb_open = 0 nb_close = 0 nb_mknod = 0 nb_unlink = 0 nb_mkdir = 0 nb_rmdir = 0 nb_rename = 0 nb_getattr = 0 nb_setattr = 0 nb_getxattr = 0 nb_link = 0 nb_statfs = 0
# directed acyclic graph class graph: def __init__(self, adj={}): self.adj = adj def setgraph(self, adj): self.adj = adj def addnode(self, node, adjlist): self.adj[node] = adjlist for e in adjlist: if e not in self.adj.keys(): self.addnode(e, [])...
class Graph: def __init__(self, adj={}): self.adj = adj def setgraph(self, adj): self.adj = adj def addnode(self, node, adjlist): self.adj[node] = adjlist for e in adjlist: if e not in self.adj.keys(): self.addnode(e, []) def addedge(self, ...
# view names ENSIME_NOTES_VIEW = "Ensime notes" ENSIME_OUTPUT_VIEW = "Ensime output" ENSIME_STACK_VIEW = "Ensime stack" ENSIME_LOCALS_VIEW = "Ensime locals" # region names ENSIME_ERROR_OUTLINE_REGION = "ensime-error" ENSIME_ERROR_UNDERLINE_REGION = "ensime-error-underline" ENSIME_BREAKPOINT_REGION = "ensime-breakpoint...
ensime_notes_view = 'Ensime notes' ensime_output_view = 'Ensime output' ensime_stack_view = 'Ensime stack' ensime_locals_view = 'Ensime locals' ensime_error_outline_region = 'ensime-error' ensime_error_underline_region = 'ensime-error-underline' ensime_breakpoint_region = 'ensime-breakpoint' ensime_debugfocus_region = ...
#!/usr/bin/env python3 # enable operation that is performed in https://github.com/williamleif/GraphSAGE # but are not mentioned in the paper ENABLE_UNKNOWN_OP = False
enable_unknown_op = False
# 6. Sa se scrie o functie care primeste ca parametru un numar variabil de liste si un numar intreg x. # Sa se returneze o lista care sa contina elementele care apar de exact x ori in listele primite. # Exemplu: pentru listele [1,2,3], [2,3,4], [4,5,6], [4, 1, "test"] si x = 2 se va returna [1, 2, 3] # 1 se afla in...
def elements(x, *lists): flatten = [] for l in lists: flatten += l return [e for e in set(flatten) if flatten.count(e) == x] print(elements(2, [1, 2, 3], [2, 3, 4], [4, 5, 6], [4, 1, 'test']))
# strings.py # # Program to illustrate the "string concatenation operator" (+) # and the use of string variables. # # CSC 110 # 9/25/2011, updated 10/4/2016 str1 = input("Enter a string: ") str2 = input("Enter a second string: ") # create a 2 more strings str3 = str1 + str2 str4 = "second string = " + str2 # display...
str1 = input('Enter a string: ') str2 = input('Enter a second string: ') str3 = str1 + str2 str4 = 'second string = ' + str2 print(str3) print(str4) print('Here is ' + str1 + '. Notice there is no space added before the period.') print(str2 * 3)
if __name__ == '__main__': for t in range(int(input())): s = input() c = 1 m = 0 n = len(s) while c < n: if s[c] == 'x': if s[c-1] == 'y': c += 2 m += 1 else : c += ...
if __name__ == '__main__': for t in range(int(input())): s = input() c = 1 m = 0 n = len(s) while c < n: if s[c] == 'x': if s[c - 1] == 'y': c += 2 m += 1 else: c += 1 ...