content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
EAST = 1 NORTH = 0 WEST = 3 SOUTH = 2 class Robot: def __init__(self, direction=NORTH, x=0, y=0): self.coordinates = (x, y) self.direction = direction def turn_right(self): self.direction = (self.direction + 1) % 4 def turn_left(self): for _ in range(3): self....
east = 1 north = 0 west = 3 south = 2 class Robot: def __init__(self, direction=NORTH, x=0, y=0): self.coordinates = (x, y) self.direction = direction def turn_right(self): self.direction = (self.direction + 1) % 4 def turn_left(self): for _ in range(3): self....
# --- # jupyter: # jupytext: # text_representation: # extension: .py # format_name: light # format_version: '1.5' # jupytext_version: 1.12.0 # kernelspec: # display_name: Python 3 # language: python # name: python3 # --- # + class Service: def __init__(self): sel...
class Service: def __init__(self): self.__choice = -1 def list(self): print('1.Bank information storage 2. Simple savings tracker 3.Basic budget Planning 4.Detailed analysis and customized suggestion') def show(self, service_number): class Error(Exception): pass ...
keywords = ('red', 'black', 'blue', 'magenta', 'lime', 'gold', 'ruby', 'warm', 'emerald', 'clean', 'noxious', 'mute', 'absent', 'agonizing', 'frail', 'disgusted', 'innocent', 'puzzled', 'flowery', 'shiny', 'concerned', 'billowy', 'wonderful', 'empty', 'tacky', 'ancient', 'physical', 'resolute', ...
keywords = ('red', 'black', 'blue', 'magenta', 'lime', 'gold', 'ruby', 'warm', 'emerald', 'clean', 'noxious', 'mute', 'absent', 'agonizing', 'frail', 'disgusted', 'innocent', 'puzzled', 'flowery', 'shiny', 'concerned', 'billowy', 'wonderful', 'empty', 'tacky', 'ancient', 'physical', 'resolute', 'depressed', 'elfin', 'r...
def avoidObstacles(inputArray): for i in range(1, max(inputArray)): divs = any([x for x in inputArray if not x % i]) if not divs: return i return max(inputArray) + 1
def avoid_obstacles(inputArray): for i in range(1, max(inputArray)): divs = any([x for x in inputArray if not x % i]) if not divs: return i return max(inputArray) + 1
t = int(input()) for i in range(t): s = int(input()) if(s<1500): hra = 0.1 * float(s) da = 0.9 * float(s) print(s + hra + da) else: print(500 + float(s)*1.98)
t = int(input()) for i in range(t): s = int(input()) if s < 1500: hra = 0.1 * float(s) da = 0.9 * float(s) print(s + hra + da) else: print(500 + float(s) * 1.98)
t = int(input()) for i in range(t): n = int(input()) arr = list(map(int, input().split())) k = int(input()) list.sort(arr) print(arr[k-1])
t = int(input()) for i in range(t): n = int(input()) arr = list(map(int, input().split())) k = int(input()) list.sort(arr) print(arr[k - 1])
_base_ = '../swin/mask_rcnn_swin-t-p4-w7_fpn_ms-crop-3x_coco.py' model = dict( roi_head=dict( mask_head=dict(num_classes=1), bbox_head=dict(num_classes=1), ), train_cfg=dict( rpn=dict( assigner=dict( gpu_assign_thr=50, ), ), rc...
_base_ = '../swin/mask_rcnn_swin-t-p4-w7_fpn_ms-crop-3x_coco.py' model = dict(roi_head=dict(mask_head=dict(num_classes=1), bbox_head=dict(num_classes=1)), train_cfg=dict(rpn=dict(assigner=dict(gpu_assign_thr=50)), rcnn=dict(assigner=dict(gpu_assign_thr=50)))) dataset_type = 'COCODataset' classes = ('pneumonia',) data =...
local_98='''0x3e 0x4f 0x41 0x4d 0x76 0x61 0x2c 0x6d 0x30 0x6f 0x5a 0x6f 0x2c 0x68 0x2e 0x5a 0x6f 0x2b 0x5a 0x5d 0x6d 0x2e 0x2f 0x66 0x6b 0x2b 0x2c 0x69 0x6f 0x3a 0x78''' local_98=local_98.split('\n') # make local_98 a list of bytes local_98=[int(x,16) for x in local_98] for i in range(len(local_98)): print(chr(loca...
local_98 = '0x3e\n0x4f\n0x41\n0x4d\n0x76\n0x61\n0x2c\n0x6d\n0x30\n0x6f\n0x5a\n0x6f\n0x2c\n0x68\n0x2e\n0x5a\n0x6f\n0x2b\n0x5a\n0x5d\n0x6d\n0x2e\n0x2f\n0x66\n0x6b\n0x2b\n0x2c\n0x69\n0x6f\n0x3a\n0x78' local_98 = local_98.split('\n') local_98 = [int(x, 16) for x in local_98] for i in range(len(local_98)): print(chr(loc...
# # PySNMP MIB module SONUS-DS1-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/SONUS-DS1-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 21:01:44 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 201...
(object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_range_constraint, constraints_intersection, single_value_constraint, value_size_constraint, constraints_union) ...
def lshift(s, rpc): rpc["FLAGS"] = "0" * 16 s = s[5::] R_a = s[:3] imm_a = int(s[3:], 2) register = { "000": "R0", "001": "R1", "010": "R2", "011": "R3", "100": "R4", "101": "R5", "110": "R6", } R_a = register[R_a] rlist = ["R0", ...
def lshift(s, rpc): rpc['FLAGS'] = '0' * 16 s = s[5:] r_a = s[:3] imm_a = int(s[3:], 2) register = {'000': 'R0', '001': 'R1', '010': 'R2', '011': 'R3', '100': 'R4', '101': 'R5', '110': 'R6'} r_a = register[R_a] rlist = ['R0', 'R1', 'R2', 'R3', 'R4', 'R5', 'R6'] if R_a in rlist: t...
# https://www.codechef.com/problems/AVG for T in range(int(input())): n,k,v=map(int,input().split()) a=list(map(int,input().split())) ans=v*(n+k)-sum(a) print(int(ans/k)) if(ans%k==0 and ans/k>0) else print(-1)
for t in range(int(input())): (n, k, v) = map(int, input().split()) a = list(map(int, input().split())) ans = v * (n + k) - sum(a) print(int(ans / k)) if ans % k == 0 and ans / k > 0 else print(-1)
def Replace_Duplicates(Test_string, replace_dict): Test_list = Test_string.split() return [replace_dict.get(Value) if Value in replace_dict.keys() and Test_list.index(Value) != Index else Value for Index, Value in enumerate(Test_list)] Test_string = 'Gfg is best . Gfg also has Classes now. Classes help u...
def replace__duplicates(Test_string, replace_dict): test_list = Test_string.split() return [replace_dict.get(Value) if Value in replace_dict.keys() and Test_list.index(Value) != Index else Value for (index, value) in enumerate(Test_list)] test_string = 'Gfg is best . Gfg also has Classes now. Classes help under...
def read_int_list(separator = ' '): return [int(x) for x in input().split(separator)] (rows_count , columns_count) = read_int_list(', ') matrix = [] for _ in range(rows_count): matrix.append(read_int_list()) #print(matrix) columns_sum = [0] * columns_count for r in range(rows_count): for c in range(co...
def read_int_list(separator=' '): return [int(x) for x in input().split(separator)] (rows_count, columns_count) = read_int_list(', ') matrix = [] for _ in range(rows_count): matrix.append(read_int_list()) columns_sum = [0] * columns_count for r in range(rows_count): for c in range(columns_count): co...
def number_letter_counts(): num1 = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine'] num2 = ['eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen'] num3 = ['ten', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'nine...
def number_letter_counts(): num1 = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine'] num2 = ['eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen'] num3 = ['ten', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninet...
d={'a':'Alpha', 'b':'Bravo', 'c':'Charlie', 'd':'Delta', 'e':'Echo', 'f':'Foxtrot', 'g':'Golf', 'h':'Hotel', 'i':'India', 'j':'Juliett', 'k':'Kilo', 'l':'Lima', 'm':'Mike', 'n':'November', 'o':'Oscar', 'p':'Papa', 'q':'Quebec', 'r':'Romeo', 's':'Sierra', 't':'Tango', 'u':'Uniform', 'v':'Victor', 'w':'Whiskey', 'x':'X-r...
d = {'a': 'Alpha', 'b': 'Bravo', 'c': 'Charlie', 'd': 'Delta', 'e': 'Echo', 'f': 'Foxtrot', 'g': 'Golf', 'h': 'Hotel', 'i': 'India', 'j': 'Juliett', 'k': 'Kilo', 'l': 'Lima', 'm': 'Mike', 'n': 'November', 'o': 'Oscar', 'p': 'Papa', 'q': 'Quebec', 'r': 'Romeo', 's': 'Sierra', 't': 'Tango', 'u': 'Uniform', 'v': 'Victor',...
card = input() hand = input().split(" ") flag = False for c in hand: if(c[0] == card[0] or c[1] == card[1]): flag = True print("YES") if flag else print("NO")
card = input() hand = input().split(' ') flag = False for c in hand: if c[0] == card[0] or c[1] == card[1]: flag = True print('YES') if flag else print('NO')
fh = open("cs190j-students.txt") for name in fh: #print(name) clean_name = name.split() pathname ="" for each in clean_name: pathname += each.strip() + "-" print("cs190j-" + pathname+"teaching-demo") fh.close()
fh = open('cs190j-students.txt') for name in fh: clean_name = name.split() pathname = '' for each in clean_name: pathname += each.strip() + '-' print('cs190j-' + pathname + 'teaching-demo') fh.close()
# # PySNMP MIB module PW-ENET-STD-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/PW-ENET-STD-MIB # Produced by pysmi-0.3.4 at Wed May 1 13:13:31 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') (constraints_union, value_range_constraint, single_value_constraint, value_size_constraint, constraints_intersection) ...
x,y = map(int,input().split()) a = list(input()) i=0 for _ in range(y): while i<x-1: if a[i]=="B" and a[i+1]=="G": a[i],a[i+1]="G","B" i+=1 i+=1 i=0 print(*a,sep='')
(x, y) = map(int, input().split()) a = list(input()) i = 0 for _ in range(y): while i < x - 1: if a[i] == 'B' and a[i + 1] == 'G': (a[i], a[i + 1]) = ('G', 'B') i += 1 i += 1 i = 0 print(*a, sep='')
def dfs(root, level, index, m): if root == None: return if level not in m: m[level] = [index] else: m[level].append(index) dfs(root.left, level+1, 2*index, m) dfs(root.right, level+1, 2*index+1, m) class Solution: def widthOfBinaryTree(self, root: Optional[Tree...
def dfs(root, level, index, m): if root == None: return if level not in m: m[level] = [index] else: m[level].append(index) dfs(root.left, level + 1, 2 * index, m) dfs(root.right, level + 1, 2 * index + 1, m) class Solution: def width_of_binary_tree(self, root: Optional[...
# Given n activities with their start and finish time (start, finish). Find # set that has maximum number of non-conflicting activities that can be executed # in a single time frame. def activity_selection(T): T.sort(key=lambda x: x[1]) A = [] A.append(T[0]) index = 0 for i in range(1, len(T)): ...
def activity_selection(T): T.sort(key=lambda x: x[1]) a = [] A.append(T[0]) index = 0 for i in range(1, len(T)): if T[i][0] >= A[index][1]: A.append(T[i]) index += 1 return A t = [(8, 12), (6, 10), (8, 11), (5, 7), (12, 16), (5, 9), (3, 5), (0, 6), (1, 4), (2, 14)...
N=input(int()) A=0 while(A<11): A+=1 M=N*A print("%d x %d = %d"%(A,N,M)) break
n = input(int()) a = 0 while A < 11: a += 1 m = N * A print('%d x %d = %d' % (A, N, M)) break
#!/usr/bin/env python class State(object): def __init__(self,name): self.name = name def stateAction(self): pass def checkConditions(self): pass def enterAction(self): pass def exitAction(self): pass class StateMachine(dict): def __init__(self,na...
class State(object): def __init__(self, name): self.name = name def state_action(self): pass def check_conditions(self): pass def enter_action(self): pass def exit_action(self): pass class Statemachine(dict): def __init__(self, name): self.n...
#!/usr/bin/env python # _*_ coding: utf-8 _*_ class cp2k_motion_print_cell_each: def __init__(self): self.params = {} self.status = False def to_input(self, fout): fout.write("\t\t\t&EACH\n") for item in self.params: if self.params[item] is not none: ...
class Cp2K_Motion_Print_Cell_Each: def __init__(self): self.params = {} self.status = False def to_input(self, fout): fout.write('\t\t\t&EACH\n') for item in self.params: if self.params[item] is not none: fout.write('\t\t\t%s %s\n' % (item, self.para...
temps = [25.2, 16.8, 31.4, 23.9, 28, 22.5, 19.6] print(temps) temps.sort() print(temps) cool_temps = temps[:2] warm_temps = temps[2:] print(cool_temps) print(warm_temps) print(cool_temps + warm_temps)
temps = [25.2, 16.8, 31.4, 23.9, 28, 22.5, 19.6] print(temps) temps.sort() print(temps) cool_temps = temps[:2] warm_temps = temps[2:] print(cool_temps) print(warm_temps) print(cool_temps + warm_temps)
# Numero de rainhas que devem ser colocadas no tabuleiro numero_rainhas = 8 # Array utilizada para marcar as linhas que estao no alcance de uma rainha no tabuleiro linhas = [0] * numero_rainhas # Arrays utilizadas para marcar as diagonais que estao no alcance de uma rainha no tabuleiro, # o index eh calculado a parti...
numero_rainhas = 8 linhas = [0] * numero_rainhas diagonais_principais = [0] * (numero_rainhas * 2 - 1) diagonais_secundarias = [0] * (numero_rainhas * 2) def imprimir_tabuleiro(tabuleiro): for linha in range(numero_rainhas): for coluna in range(numero_rainhas): print(tabuleiro[linha][coluna], e...
# Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights # reserved. Use of this source code is governed by a BSD-style license that # can be found in the LICENSE file. { 'variables': { 'chromium_code': 1, 'conditions': [ [ 'OS=="mac"', { # Don't use clang with CEF binary releas...
{'variables': {'chromium_code': 1, 'conditions': [['OS=="mac"', {'clang': 0}]]}, 'includes': ['cef_paths2.gypi'], 'targets': [{'target_name': 'cefclient', 'type': 'executable', 'mac_bundle': 1, 'msvs_guid': '6617FED9-C5D4-4907-BF55-A90062A6683F', 'dependencies': ['libcef_dll_wrapper'], 'defines': ['USING_CEF_SHARED'], ...
# Copyright (c) 2009 Google Inc. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. { 'targets': [ { 'target_name': 'null_input', 'type': 'executable', 'msvs_cygwin_shell': 0, 'actions': [ { ...
{'targets': [{'target_name': 'null_input', 'type': 'executable', 'msvs_cygwin_shell': 0, 'actions': [{'action_name': 'generate_main', 'process_outputs_as_sources': 1, 'inputs': [], 'outputs': ['<(INTERMEDIATE_DIR)/main.c'], 'action': ['python', 'generate_main.py', '<(INTERMEDIATE_DIR)/main.c'], 'msvs_cygwin_shell': 0}]...
theBoard = { 'top-L': ' ', 'top-M': ' ', 'top-R': ' ', 'mid-L': ' ', 'mid-M': ' ', 'mid-R': ' ', 'low-L': ' ', 'low-M': ' ', 'low-R': ' ' } def printBoard(board): print(board['top-L'] + '|' + board['top-M'] + '|' + board['top-R']) print('-+-+-') print(board['mid-L'] + '|' + board...
the_board = {'top-L': ' ', 'top-M': ' ', 'top-R': ' ', 'mid-L': ' ', 'mid-M': ' ', 'mid-R': ' ', 'low-L': ' ', 'low-M': ' ', 'low-R': ' '} def print_board(board): print(board['top-L'] + '|' + board['top-M'] + '|' + board['top-R']) print('-+-+-') print(board['mid-L'] + '|' + board['mid-M'] + '|' + board['mi...
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # SPDX-License-Identifier: MIT-0 # # 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 ...
initial_state_name = 'Initial' def get_states(self): states = [{'stateName': 'Initial', 'onInput': {'events': [{'eventName': 'CountInputs', 'condition': 'true', 'actions': [{'setVariable': {'variableName': 'input_message_count', 'value': '$variable.input_message_count + 1'}}]}, {'eventName': 'SetGatewayId', 'condi...
# AUTOGENERATED BY NBDEV! DO NOT EDIT! __all__ = ["index", "modules", "custom_doc_links", "git_url"] index = {"ci_width": "00_core.ipynb", "expand_bbox": "00_core.ipynb", "annotate_label": "00_core.ipynb", "trim_spines": "00_core.ipynb", "bootstrap": "00_core.ipynb", "rugp...
__all__ = ['index', 'modules', 'custom_doc_links', 'git_url'] index = {'ci_width': '00_core.ipynb', 'expand_bbox': '00_core.ipynb', 'annotate_label': '00_core.ipynb', 'trim_spines': '00_core.ipynb', 'bootstrap': '00_core.ipynb', 'rugplot': '00_core.ipynb', 'scatter_line': '00_core.ipynb', 'hline': '00_core.ipynb', 'sho...
class Solution: # @param s, a string # @param wordDict, a set<string> # @return a boolean def wordBreak(self, s, wordDict): self.tree = {} self.memo = {} for word in wordDict: self.buildNode(word, self.tree) return self.traverse(s) def traverse(self, s): ...
class Solution: def word_break(self, s, wordDict): self.tree = {} self.memo = {} for word in wordDict: self.buildNode(word, self.tree) return self.traverse(s) def traverse(self, s): if s in self.memo: return self.memo[s] if not s: ...
signle_cve = [ {"source": "Bugtraq ID", "url": "http://www.securityfocus.com/bid/193"}, {"source": "Snort Signature ID", "url": "http://www.snort.org/search/sid/1500?r=1"}, { "source": "CVE ID", "url": "http://cve.mitre.org/cgi-bin/cvename.cgi?name=1999-0449", }, ] multiple_cve = [ ...
signle_cve = [{'source': 'Bugtraq ID', 'url': 'http://www.securityfocus.com/bid/193'}, {'source': 'Snort Signature ID', 'url': 'http://www.snort.org/search/sid/1500?r=1'}, {'source': 'CVE ID', 'url': 'http://cve.mitre.org/cgi-bin/cvename.cgi?name=1999-0449'}] multiple_cve = [{'source': 'Vendor Specific Advisory URL', '...
MAX_HIST = 10 def active_history_terms(hist): terms = [] for q in hist: if q['active']: terms.append(q['query']) return terms def update_history(hist, query, active): for q in hist: if q['query'] == query: q['active'] = bool(int(active)) return hist def a...
max_hist = 10 def active_history_terms(hist): terms = [] for q in hist: if q['active']: terms.append(q['query']) return terms def update_history(hist, query, active): for q in hist: if q['query'] == query: q['active'] = bool(int(active)) return hist def ame...
helpful_title = widgets.HTML('Generated password is:') password_text = widgets.HTML('No password yet', placeholder='No password generated yet') password_text.layout.margin = '0 0 0 20px' password_length = widgets.IntSlider(description='Length of password', min=8, max=20, ...
helpful_title = widgets.HTML('Generated password is:') password_text = widgets.HTML('No password yet', placeholder='No password generated yet') password_text.layout.margin = '0 0 0 20px' password_length = widgets.IntSlider(description='Length of password', min=8, max=20, style={'description_width': 'initial'}) password...
class JSON(object): def __init__(self, value): self._value = value def getValue(self): return self._value class Number(JSON): def __init__(self, num): super(Number, self).__init__(num) def __str__(self): return 'Number(%f)' % self.getValue() class String(JSON): ...
class Json(object): def __init__(self, value): self._value = value def get_value(self): return self._value class Number(JSON): def __init__(self, num): super(Number, self).__init__(num) def __str__(self): return 'Number(%f)' % self.getValue() class String(JSON): ...
my_salary = 100 tax_rate = 0.18 net_salary = my_salary - my_salary*tax_rate net_salary_one = my_salary * (1 - tax_rate) print(net_salary) print(net_salary_one)
my_salary = 100 tax_rate = 0.18 net_salary = my_salary - my_salary * tax_rate net_salary_one = my_salary * (1 - tax_rate) print(net_salary) print(net_salary_one)
# function to generate all the sub lists def sub_lists(list1): # store all the sublists sublist = [[]] # first loop for i in range(len(list1) + 1): # second loop for j in range(i + 1, len(list1) + 1): # slice the subarray ...
def sub_lists(list1): sublist = [[]] for i in range(len(list1) + 1): for j in range(i + 1, len(list1) + 1): sub = list1[i:j] sublist.append(sub) return sublist (end, length) = map(int, input().split()) room = [int(x) for x in input().split()] room.append(end) dist = list() pr...
def part1(): values = [[True if j == "#" else False for j in i] for i in open("input.txt","r").read().split("\n")] for _ in range(100): copy = [row[:] for row in values] for i in range(0, len(values)): for j in range(0, len(values)): sum = 0 for x in r...
def part1(): values = [[True if j == '#' else False for j in i] for i in open('input.txt', 'r').read().split('\n')] for _ in range(100): copy = [row[:] for row in values] for i in range(0, len(values)): for j in range(0, len(values)): sum = 0 for x in ...
class Teacher: def __init__(self, teacherName): self.teacherName = teacherName # TODO
class Teacher: def __init__(self, teacherName): self.teacherName = teacherName
y = 2 if True: x = 5 else: x = 2 print (len(y)) print (str(x))
y = 2 if True: x = 5 else: x = 2 print(len(y)) print(str(x))
def bubble_sort(A): # O(n^2) n = len(A) for i in range(n-1): for j in range(n-1): if A[j] > A[j+1]: A[j+1], A[j] = A[j], A[j+1] print(A)
def bubble_sort(A): n = len(A) for i in range(n - 1): for j in range(n - 1): if A[j] > A[j + 1]: (A[j + 1], A[j]) = (A[j], A[j + 1]) print(A)
# -*- coding: utf-8 -*- class Solution: @staticmethod def permutation(s: str) -> [str]: c, result = list(s), [] def dfs(x): if x == len(c) - 1: result.append(''.join(c)) return dic = set() for i in range(x, len(c)): ...
class Solution: @staticmethod def permutation(s: str) -> [str]: (c, result) = (list(s), []) def dfs(x): if x == len(c) - 1: result.append(''.join(c)) return dic = set() for i in range(x, len(c)): if c[i] in dic...
#!/usr/bin/python3 def add(a,b): return a + b def substract(a, b): return a + b
def add(a, b): return a + b def substract(a, b): return a + b
def compute_composed_data(transform_list,L, C, xb,yb): BS,N_CHANNELS,HEIGHT,WIDTH = xb.shape C_images = torch.zeros(C, BS, N_CHANNELS, HEIGHT, WIDTH, device=device) C_targets = torch.zeros(C, BS, device=device, dtype=torch.long) for c in range(C): # create a list of L linear transforms randoml...
def compute_composed_data(transform_list, L, C, xb, yb): (bs, n_channels, height, width) = xb.shape c_images = torch.zeros(C, BS, N_CHANNELS, HEIGHT, WIDTH, device=device) c_targets = torch.zeros(C, BS, device=device, dtype=torch.long) for c in range(C): sampled_tfms = list(np.random.choice(tran...
expected_output = { "r5-s": { "name": "r5-s", "color": 102, "end_point": "5.5.5.5", "owners": "CLI", "status": { "admin": "up", "operational": { "state": "up", "time_for_state": "02:07:25", "since": "08-2...
expected_output = {'r5-s': {'name': 'r5-s', 'color': 102, 'end_point': '5.5.5.5', 'owners': 'CLI', 'status': {'admin': 'up', 'operational': {'state': 'up', 'time_for_state': '02:07:25', 'since': '08-20 06:52:36.113'}}, 'candidate_paths': {'preference': {1: {'path_type': {'explicit': {'segment_list': {'to-R5-s': {'statu...
server_module = 'txtemplates.echo' backend_options = [{}] backend_ids = ['default'] error_options = [{'unknown': 'parameter'}] error_ids = ['too_many_parameters'] full_server_options = [({}, {})] full_server_ids = ['default'] # vim: set ft=python sw=4 et spell spelllang=en:
server_module = 'txtemplates.echo' backend_options = [{}] backend_ids = ['default'] error_options = [{'unknown': 'parameter'}] error_ids = ['too_many_parameters'] full_server_options = [({}, {})] full_server_ids = ['default']
# for dentro de for size(480, 120) background(0) noStroke() for y in range(0, height+40, 40): for x in range(0, width + 45, 40): fill(233, 51, 85, 140) ellipse(x, y, 40, 40)
size(480, 120) background(0) no_stroke() for y in range(0, height + 40, 40): for x in range(0, width + 45, 40): fill(233, 51, 85, 140) ellipse(x, y, 40, 40)
class Modo: def __init__(self): pass def esAgresivo(self): return False def esPerezoso(self): return False def dormir(self): print("Bicho dormir") def mover(self,bicho): print("el bicho se mueve") def atacar(self,bicho): print("el bicho ", bich...
class Modo: def __init__(self): pass def es_agresivo(self): return False def es_perezoso(self): return False def dormir(self): print('Bicho dormir') def mover(self, bicho): print('el bicho se mueve') def atacar(self, bicho): print('el bicho '...
#%% # data_path = Path("/media/batman/f4023177-48c1-456b-bff2-cc769f3ac277/ASSETS/Dogs vs Cats") # image_path = data_path / '12499.jpg' # image_path = data_path / '12500.jpg' data_path = Path("/media/batman/f4023177-48c1-456b-bff2-cc769f3ac277/DATA/airbus-ship-detection") assert data_path.exists() img_zip_path = data_p...
data_path = path('/media/batman/f4023177-48c1-456b-bff2-cc769f3ac277/DATA/airbus-ship-detection') assert data_path.exists() img_zip_path = data_path / 'train_v2.zip' assert img_zip_path.exists() record_path = data_path / 'train_ship_segmentations_v2.csv' assert record_path.exists() img_zip = zipfile.ZipFile(img_zip_pat...
for movie in movies: try: # Find the first occurrence of word print(movie.index('money', 12, 51)) except ValueError: print("substring not found")
for movie in movies: try: print(movie.index('money', 12, 51)) except ValueError: print('substring not found')
Linux = "Linux" Windows = "Windows" WSL = "WSL" Cygwin = "Cygwin" Mac = "Mac" Bsd = "Bsd"
linux = 'Linux' windows = 'Windows' wsl = 'WSL' cygwin = 'Cygwin' mac = 'Mac' bsd = 'Bsd'
def convert_to_python_bool_if_value_is_json_string_bool(s): if s == "true": return True elif s == "false": return False return s
def convert_to_python_bool_if_value_is_json_string_bool(s): if s == 'true': return True elif s == 'false': return False return s
class Channel(object): def __init__(self, targets): self.targets = targets self.__volume = sum(t.volume for t in targets) / len(targets) self.__muted = False @property def volume(self): return self.__volume @volume.setter def volume(self, value): self.__volu...
class Channel(object): def __init__(self, targets): self.targets = targets self.__volume = sum((t.volume for t in targets)) / len(targets) self.__muted = False @property def volume(self): return self.__volume @volume.setter def volume(self, value): self.__v...
class _PropertyMeta(type): def __iter__(self): for item in dir(self): if not item.startswith('_'): attr = getattr(self, item) if not callable(attr): yield attr def list(cls): return list(iter(cls)) # region Application class _App...
class _Propertymeta(type): def __iter__(self): for item in dir(self): if not item.startswith('_'): attr = getattr(self, item) if not callable(attr): yield attr def list(cls): return list(iter(cls)) class _Applicationattributesbas...
# Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. { 'variables': { 'use_system_libwebp%': 0, }, 'conditions': [ ['use_system_libwebp==0', { 'targets': [ { 'target_na...
{'variables': {'use_system_libwebp%': 0}, 'conditions': [['use_system_libwebp==0', {'targets': [{'target_name': 'libwebp_dec', 'type': 'static_library', 'include_dirs': ['../third_party/externals/libwebp'], 'sources': ['../third_party/externals/libwebp/dec/alpha.c', '../third_party/externals/libwebp/dec/buffer.c', '../...
def make_train_step(model, optimizer): # Builds function that performs a step in the train loop def train_step(x, y): # Sets model to TRAIN mode model.train() # forward forward_dict = model(x, y) # Computes loss loss_dict = model.loss_function(forward_dict) ...
def make_train_step(model, optimizer): def train_step(x, y): model.train() forward_dict = model(x, y) loss_dict = model.loss_function(forward_dict) total_loss = loss_dict['total_loss'] total_loss.backward() optimizer.step() optimizer.zero_grad() retur...
class VineError(Exception): def __init__(self, code, error): self.code = code self.error = error def __str__(self): return '#%i: %s' % (self.code, self.error) class ParameterError(Exception): def __init__(self, description): self.description = description def __str__(...
class Vineerror(Exception): def __init__(self, code, error): self.code = code self.error = error def __str__(self): return '#%i: %s' % (self.code, self.error) class Parametererror(Exception): def __init__(self, description): self.description = description def __str__...
'''input 3 2 ..# .#. #.# #. .# Yes 3 2 #.# .#. #.# #. .# Yes 4 1 .... .... .... .... # No 3 2 .#. .#. #.# #. .# Yes 3 2 ..# #.. .#. #. .# Yes ''' # -*- coding: utf-8 -*- # AtCoder Beginner Contest # Problem B if __name__ == '__main__': n, m = list(map(int, ...
"""input 3 2 ..# .#. #.# #. .# Yes 3 2 #.# .#. #.# #. .# Yes 4 1 .... .... .... .... # No 3 2 .#. .#. #.# #. .# Yes 3 2 ..# #.. .#. #. .# Yes """ if __name__ == '__main__': (n, m) = list(map(int, input().split())) a = [list(input()) for _ in range(n)] b = [list(input()) for _ in range(m)] for i in ...
# Scrapy settings for scraper project # # For simplicity, this file contains only settings considered important or # commonly used. You can find more settings consulting the documentation: # # https://docs.scrapy.org/en/latest/topics/settings.html # https://docs.scrapy.org/en/latest/topics/downloader-middleware...
bot_name = 'scraper' spider_modules = ['scraper.spiders'] newspider_module = 'scraper.spiders' user_agent = 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:66.0) Gecko/20100101 Firefox/66.0' robotstxt_obey = False download_delay = 0.25 default_request_headers = {'Accept': '*/*', 'Accept-Language': 'en'} item_pipelines = {'...
def is_duplicate_lec(lec_bag, t, cur_enrol, cur_total): cur_enrol_stats = str(cur_enrol) + "/" + str(cur_total) cur_name = {"LEC" in t:"LEC", "WEB" in t:"WEB"}.get(True, None) # lec/web if ("LEC" in list(*zip(*lec_bag)) and cur_name == "WEB") or ("WEB" in list(*zip(*lec_bag)) and cur_name == "LEC"): ...
def is_duplicate_lec(lec_bag, t, cur_enrol, cur_total): cur_enrol_stats = str(cur_enrol) + '/' + str(cur_total) cur_name = {'LEC' in t: 'LEC', 'WEB' in t: 'WEB'}.get(True, None) if 'LEC' in list(*zip(*lec_bag)) and cur_name == 'WEB' or ('WEB' in list(*zip(*lec_bag)) and cur_name == 'LEC'): lec_sum =...
def advance_a(a): while True: a = (a * 16807) % 2147483647 if a % 4 == 0: break return a def advance_b(b): while True: b = (b * 48271) % 2147483647 if b % 8 == 0: break return b if __name__ == "__main__": a = 591 b = 393 count = 0 ...
def advance_a(a): while True: a = a * 16807 % 2147483647 if a % 4 == 0: break return a def advance_b(b): while True: b = b * 48271 % 2147483647 if b % 8 == 0: break return b if __name__ == '__main__': a = 591 b = 393 count = 0 for ...
test_input = ["00100", "11110", "10110", "10111", "10101", "01111", "00111", "11100", "10000", "11001", "00010", "01010"] def part_one(report): length = len(report[0]) gamma = '' epsilon = '' for i in range(length): chars = [line[i] for line in report] ones = [c for c in chars if c == '...
test_input = ['00100', '11110', '10110', '10111', '10101', '01111', '00111', '11100', '10000', '11001', '00010', '01010'] def part_one(report): length = len(report[0]) gamma = '' epsilon = '' for i in range(length): chars = [line[i] for line in report] ones = [c for c in chars if c == '...
#!/usr/bin/env python3 # -*- coding: UTF-8 -*- __all__ = [ "app_menu", "app_view" ]
__all__ = ['app_menu', 'app_view']
#get a list of events #write out specific output if __name__ == "__main__": listOfEvents = [{'number': 1, 'run':1 , 'lumi':1}] inputfiles = [] writeCollections = [] #== all writeCollections = ['TTree branch name', #... ]
if __name__ == '__main__': list_of_events = [{'number': 1, 'run': 1, 'lumi': 1}] inputfiles = [] write_collections = [] write_collections = ['TTree branch name']
def differentValues(a, d): result = -1 for i in range(len(a)): for j in range(i + 1, len(a)): diff = abs(a[j] - a[i]) if 0 <= d - diff and d - diff <= d - result: result = diff return result
def different_values(a, d): result = -1 for i in range(len(a)): for j in range(i + 1, len(a)): diff = abs(a[j] - a[i]) if 0 <= d - diff and d - diff <= d - result: result = diff return result
def setup(): size(300, 300) smooth() strokeWeight(30) background(0) def draw(): stroke(200, 20) line(mouseX - 50, mouseY - 50, 100 + mouseX -50, 100 + mouseY -50) line(100 + mouseX - 50, mouseY - 50, mouseX -50, 100 + mouseY -50)
def setup(): size(300, 300) smooth() stroke_weight(30) background(0) def draw(): stroke(200, 20) line(mouseX - 50, mouseY - 50, 100 + mouseX - 50, 100 + mouseY - 50) line(100 + mouseX - 50, mouseY - 50, mouseX - 50, 100 + mouseY - 50)
# # PySNMP MIB module APTIS-CONFIG-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/APTIS-CONFIG-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 17:08:41 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar ...
(aptis_config, boolean) = mibBuilder.importSymbols('APTIS-MIB', 'aptis-config', 'Boolean') (aptis_modules,) = mibBuilder.importSymbols('APTIS-REG-MIB', 'aptis-modules') (octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer') (named_values,) = mibBuilde...
# $Id: genericView.py,v 1.1 2001/09/23 23:21:42 ivo Exp $ class genericView: def __init__(self, *args): pass
class Genericview: def __init__(self, *args): pass
# Kalman Filter class class kalman(object): def __init__(self, process_var,est_meas_var,post_est,post_err_est ): self.process_var = process_var self.est_meas_var = est_meas_var self.post_est = post_est # x_hat[0] = 0 self.post_err_est = post_err_est # P[0] = 1 ...
class Kalman(object): def __init__(self, process_var, est_meas_var, post_est, post_err_est): self.process_var = process_var self.est_meas_var = est_meas_var self.post_est = post_est self.post_err_est = post_err_est def update_meas(self, measurement, dt, velocity, update=True): ...
wt4_2_10 = {'192.168.122.110': [9.4588, 7.3689, 6.822, 6.431, 6.7738, 7.4588, 7.5462, 7.3574, 7.2376, 7.6079, 8.1594, 7.9374, 7.751, 7.6867, 8.2488, 8.4198, 7.9897, 7.5912, 7.2453, 7.2598, 7.1709, 7.1956, 7.1208, 7.2791, 7.2026, 7.1403, 7.2918, 7.5042, 7.4392, 7.3769, 7.3987, 7.5164, 7.6815, 7.6446, 7.583, 7.5832, 7.5...
wt4_2_10 = {'192.168.122.110': [9.4588, 7.3689, 6.822, 6.431, 6.7738, 7.4588, 7.5462, 7.3574, 7.2376, 7.6079, 8.1594, 7.9374, 7.751, 7.6867, 8.2488, 8.4198, 7.9897, 7.5912, 7.2453, 7.2598, 7.1709, 7.1956, 7.1208, 7.2791, 7.2026, 7.1403, 7.2918, 7.5042, 7.4392, 7.3769, 7.3987, 7.5164, 7.6815, 7.6446, 7.583, 7.5832, 7.55...
#list of passengers passengers_list = ["George", "Annie", "Jack", "Annie", "Henry", "Helen", "Maria", "George", "Jack", "Remo"] #set function - removes the duplicates from the list and returns a set unique_passengers = set(passengers_list) print(unique_passengers) #creating a set flight_set = {500,...
passengers_list = ['George', 'Annie', 'Jack', 'Annie', 'Henry', 'Helen', 'Maria', 'George', 'Jack', 'Remo'] unique_passengers = set(passengers_list) print(unique_passengers) flight_set = {500, 520, 600, 345, 520, 634, 600, 500, 200, 200} print(flight_set) flights_at_src = ['AI230', 'BA944', 'EM395', 'AI704', 'BA944', '...
k = int(input()) li = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51] print(li[k-1])
k = int(input()) li = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51] print(li[k - 1])
# ------------------------------ # 26. Remove Duplicates from Sorted Array # # Description: # # # Version: 2.0 # 11/12/19 by Jianfa # ------------------------------ class Solution: def removeDuplicates(self, nums: List[int]) -> int: if not nums: return 0 curr = 0 # index of ...
class Solution: def remove_duplicates(self, nums: List[int]) -> int: if not nums: return 0 curr = 0 i = 1 while i < len(nums): if nums[i] != nums[curr]: curr += 1 nums[curr] = nums[i] i += 1 return curr + 1 ...
def convertFahrToCels(fahr_num: float): try: if isinstance(fahr_num, float): cel_num = round(((fahr_num - 32) / 1.8), 2) return cel_num else: raise Exception("Fahrenheit input has to be a float.") except Exception as incorrect_input_error: print("Inval...
def convert_fahr_to_cels(fahr_num: float): try: if isinstance(fahr_num, float): cel_num = round((fahr_num - 32) / 1.8, 2) return cel_num else: raise exception('Fahrenheit input has to be a float.') except Exception as incorrect_input_error: print('Inva...
list = { "A": 0.253035073, "AV2": 0.171441136, "B": 0.517807837, "D": 0.568949504, "DASV4": 1.455884225, "DAV4": 1.233373559, "DS": 0.677649644, "DSV2": 0.400535824, "DSV2_PROMO": 0.116466481, "DSV3": 0.912222423, "DV2": 0.039335347, "DV2_PROMO": 0.601197349, "DV3": 1...
list = {'A': 0.253035073, 'AV2': 0.171441136, 'B': 0.517807837, 'D': 0.568949504, 'DASV4': 1.455884225, 'DAV4': 1.233373559, 'DS': 0.677649644, 'DSV2': 0.400535824, 'DSV2_PROMO': 0.116466481, 'DSV3': 0.912222423, 'DV2': 0.039335347, 'DV2_PROMO': 0.601197349, 'DV3': 1.033176968, 'EASV4': 0.657086839, 'EAV4': 0.957161257...
def transitive_closure(n, g): def dfs(s, v): tc[s][v]=1 for nei in g[v]: if tc[s][nei]==0: dfs(s, nei) tc = [[0 for i in range(n)] for j in range(n)] for i in range(n): dfs(i,i) return tc g = { 0: [1,2], 1: [2], 2: [0,3], 3: [] } p...
def transitive_closure(n, g): def dfs(s, v): tc[s][v] = 1 for nei in g[v]: if tc[s][nei] == 0: dfs(s, nei) tc = [[0 for i in range(n)] for j in range(n)] for i in range(n): dfs(i, i) return tc g = {0: [1, 2], 1: [2], 2: [0, 3], 3: []} print(transitive...
''' Count Divisors You have been given 3 integers - l, r and k. Find how many numbers between l and r (both inclusive) are divisible by k. You do not need to print these numbers, you just have to find their count. Input Format The first and only line of input contains 3 space separated integers l, r and k. Output Fo...
""" Count Divisors You have been given 3 integers - l, r and k. Find how many numbers between l and r (both inclusive) are divisible by k. You do not need to print these numbers, you just have to find their count. Input Format The first and only line of input contains 3 space separated integers l, r and k. Output Fo...
class Solution: def largestNumber(self, nums: List[int]) -> str: if not nums: return '' def cmp(a,b): return a+b<b+a nums = list(map(str,nums)) for i in range(len(nums)): for j in range(len(nums)-1-i): if cmp(nums[j],...
class Solution: def largest_number(self, nums: List[int]) -> str: if not nums: return '' def cmp(a, b): return a + b < b + a nums = list(map(str, nums)) for i in range(len(nums)): for j in range(len(nums) - 1 - i): if cmp(nums[j],...
net_device = { 'ip_addr':'10.5.6.6', 'vendor':'cisco', 'platform':'ios', 'username':'malford', 'password':'chicken', } bgp_fields = { 'bgp_as':'65002', 'peer_as':'20551', 'peer_ip':'10.232.232.2' } net_device.update(bgp_fields) print("These are the dictionary keys: ") for x in net_device: print(x) print('\n') p...
net_device = {'ip_addr': '10.5.6.6', 'vendor': 'cisco', 'platform': 'ios', 'username': 'malford', 'password': 'chicken'} bgp_fields = {'bgp_as': '65002', 'peer_as': '20551', 'peer_ip': '10.232.232.2'} net_device.update(bgp_fields) print('These are the dictionary keys: ') for x in net_device: print(x) print('\n') pr...
class Mass: AAMass = {'A' : 71.0371138, 'C_': 103.00918, 'C' : 160.0306481, 'D' : 115.0269429, 'E' : 129.042593, 'F' : 147.0684139, 'G' : 57.0214637, 'H' : 137.0589118, 'I' : 113.0840639, 'K...
class Mass: aa_mass = {'A': 71.0371138, 'C_': 103.00918, 'C': 160.0306481, 'D': 115.0269429, 'E': 129.042593, 'F': 147.0684139, 'G': 57.0214637, 'H': 137.0589118, 'I': 113.0840639, 'K': 128.094963, 'L': 113.0840639, 'M': 131.0404846, 'N': 114.0429274, 'P': 97.0527638, 'Q': 128.0585774, 'R': 156.101111, 'S': 87.0320...
XTRACT_CRAWLER = "http://xtractcrawler5-env.eba-akbhvznm.us-east-1.elasticbeanstalk.com/" XTRACT_CRAWLER_DEV = "http://127.0.0.1:5000/" XTRACT_SERVICE = "http://xtractservice2-env.eba-xh7cjv4i.us-east-1.elasticbeanstalk.com/" XTRACT_SERVICE_DEV = "http://127.0.0.1:5000/"
xtract_crawler = 'http://xtractcrawler5-env.eba-akbhvznm.us-east-1.elasticbeanstalk.com/' xtract_crawler_dev = 'http://127.0.0.1:5000/' xtract_service = 'http://xtractservice2-env.eba-xh7cjv4i.us-east-1.elasticbeanstalk.com/' xtract_service_dev = 'http://127.0.0.1:5000/'
server_module = 'txtemplates.echo' backend_options = [{}] backend_ids = ['default'] full_server_options = [({}, {})] full_server_ids = ['default'] # vim: set ft=python sw=4 et spell spelllang=en:
server_module = 'txtemplates.echo' backend_options = [{}] backend_ids = ['default'] full_server_options = [({}, {})] full_server_ids = ['default']
#C for row in range(7): for col in range(7): if (row==0 and col==3)or (row==0 and col==4)or (row==0 and col==5) or(row==0 and col==2) or (row==1 and col==1) or (row==2 and col==1) or (row==3 and col==1)or(row==4 and col==3) or(row==4 and col==4)or(row==4 and col==5)or(row==4 and col==2): pr...
for row in range(7): for col in range(7): if row == 0 and col == 3 or (row == 0 and col == 4) or (row == 0 and col == 5) or (row == 0 and col == 2) or (row == 1 and col == 1) or (row == 2 and col == 1) or (row == 3 and col == 1) or (row == 4 and col == 3) or (row == 4 and col == 4) or (row == 4 and col == 5...
''' Management of SELinux rules. ============================ If SELinux is available for the running system, the mode can be managed and booleans can be set. .. code-block:: yaml enforcing: selinux.mode samba_create_home_dirs: selinux.boolean: - value: True - persist: Tr...
""" Management of SELinux rules. ============================ If SELinux is available for the running system, the mode can be managed and booleans can be set. .. code-block:: yaml enforcing: selinux.mode samba_create_home_dirs: selinux.boolean: - value: True - persist: Tr...
def factorial(x): if x == 0: return(1) else: total = 1 while(x>0): total *= x x -= 1 return(total) def wilson(x): if(factorial(x-1)%x==(x-1) and x!=1): return(1) else: return(0) def main(): a = input("Enter the range in which prime numbers are to be printed. \nEnter a,b for the range [a,b]...
def factorial(x): if x == 0: return 1 else: total = 1 while x > 0: total *= x x -= 1 return total def wilson(x): if factorial(x - 1) % x == x - 1 and x != 1: return 1 else: return 0 def main(): a = input('Enter the range in wh...
class YouTubeVideo: video_id: str channelId: str title: str description: str thumbnails: dict publishedAt: str publishTime: str channelTitle: str liveBroadcastContent: str def __init__(self, original_dict, video_id): self.__dict__.update(original_dict) self.video...
class Youtubevideo: video_id: str channel_id: str title: str description: str thumbnails: dict published_at: str publish_time: str channel_title: str live_broadcast_content: str def __init__(self, original_dict, video_id): self.__dict__.update(original_dict) self...
stage = 2 optimizer = dict(lr=0.001) autocast = True zero = dict(optimizer=dict(broadcast_fp16=autocast), model=dict(reduce_fp16=autocast))
stage = 2 optimizer = dict(lr=0.001) autocast = True zero = dict(optimizer=dict(broadcast_fp16=autocast), model=dict(reduce_fp16=autocast))
N, X = map(int, input().split()) lists = [] for i in range(N): a = list(map(int, input().split())) lists.append(a[1:]) ans = 0 def dfs(n, total): global ans if n == N and total == X: ans += 1 if n >= N: return for x in lists[n]: dfs(n + 1, total * x) for i in range(len(...
(n, x) = map(int, input().split()) lists = [] for i in range(N): a = list(map(int, input().split())) lists.append(a[1:]) ans = 0 def dfs(n, total): global ans if n == N and total == X: ans += 1 if n >= N: return for x in lists[n]: dfs(n + 1, total * x) for i in range(len...
def getLongestWorkoutPerDay(workoutsData, DateManager): longestWorkoutPerDay = {} chronologicalData = DateManager.getWorkoutsDataChronologically(workoutsData) for workout in chronologicalData: workoutDate = DateManager.fetchDateFromTimestampString(workout['time']) if workoutDate not in longe...
def get_longest_workout_per_day(workoutsData, DateManager): longest_workout_per_day = {} chronological_data = DateManager.getWorkoutsDataChronologically(workoutsData) for workout in chronologicalData: workout_date = DateManager.fetchDateFromTimestampString(workout['time']) if workoutDate not...
class ParticleTexture: def __init__(self, textureID, numberOfRows): self.__textureID = textureID self.__numberOfRows = numberOfRows def getTextureID(self): return self.__textureID def getNumberOfRows(self): return self.__numberOfRows
class Particletexture: def __init__(self, textureID, numberOfRows): self.__textureID = textureID self.__numberOfRows = numberOfRows def get_texture_id(self): return self.__textureID def get_number_of_rows(self): return self.__numberOfRows
n = int(input()) a = set() for i in range(n): a.add(input()) print(len(a))
n = int(input()) a = set() for i in range(n): a.add(input()) print(len(a))
class Rentalsystem: def __init__(self): self.availableCars = ['SUV','SEDAN','HATCHBACK'] self.rentForCars = [100,50,30] def displayAvailableCars(self): print() print("Available Cars and their price for 1 day in dollars") for i in range(len(self.availableCars)):...
class Rentalsystem: def __init__(self): self.availableCars = ['SUV', 'SEDAN', 'HATCHBACK'] self.rentForCars = [100, 50, 30] def display_available_cars(self): print() print('Available Cars and their price for 1 day in dollars') for i in range(len(self.availableCars)): ...
def get_json_value(json, key: str): if not json or key not in json: return None else: return json[key]
def get_json_value(json, key: str): if not json or key not in json: return None else: return json[key]
class Solution: def minimumAbsDifference(self, arr: List[int]) -> List[List[int]]: ans = [] min = math.inf arr.sort() for i in range(len(arr) - 1): diff = arr[i + 1] - arr[i] if diff < min: min = diff ans = [] if diff == min: ans.append([arr[i], arr[i + 1]])...
class Solution: def minimum_abs_difference(self, arr: List[int]) -> List[List[int]]: ans = [] min = math.inf arr.sort() for i in range(len(arr) - 1): diff = arr[i + 1] - arr[i] if diff < min: min = diff ans = [] if ...
''' Given the root of a binary search tree (BST) with duplicates, return all the mode(s) (i.e., the most frequently occurred element) in it. If the tree has more than one mode, return them in any order. Assume a BST is defined as follows: The left subtree of a node contains only nodes with keys less than or equal to...
""" Given the root of a binary search tree (BST) with duplicates, return all the mode(s) (i.e., the most frequently occurred element) in it. If the tree has more than one mode, return them in any order. Assume a BST is defined as follows: The left subtree of a node contains only nodes with keys less than or equal to...
"Linear Search" def lin(arr): "Performs linear search" inp = input() i = 0 while i < len(arr): if arr[i] == int(inp): return "true" i += 1 if i == len(arr): return "false" print("Enter input:") print(lin([1, 4, 2, 3, 8, 4, 12]))
"""Linear Search""" def lin(arr): """Performs linear search""" inp = input() i = 0 while i < len(arr): if arr[i] == int(inp): return 'true' i += 1 if i == len(arr): return 'false' print('Enter input:') print(lin([1, 4, 2, 3, 8, 4, 12]))
def find_pivot_place(list1, first, last): #define pivot(using first element here) pivot = list1[first] #define 'left' as the element right after the pivot left = first + 1 # define 'right' as the last element right = last while True: #see if 'left' element is less than 'right' element and pivot elem...
def find_pivot_place(list1, first, last): pivot = list1[first] left = first + 1 right = last while True: while left <= right and list1[left] <= pivot: left += 1 while left <= right and list1[right] >= pivot: right -= 1 if right < left: break ...
#Author: OMKAR PATHAK #This program calculates the LCM of the two numbers entered by the user def LCM(number1, number2): '''This function calculates LCM of two numbers inputed by the user''' maximum = max(number1, number2) i = maximum while True: if (i % number1 == 0 and i % number2 == 0): ...
def lcm(number1, number2): """This function calculates LCM of two numbers inputed by the user""" maximum = max(number1, number2) i = maximum while True: if i % number1 == 0 and i % number2 == 0: lcm = i break i += maximum return lcm if __name__ == '__main__': ...
def flatten_list(array, result=None): if result is None: result = [] for element in array: print(element) if isinstance(element, list): flatten_list(element, result) else: result.append(element) return result print(flatten_list([1, 2, 3, 4, 5, [1, ...
def flatten_list(array, result=None): if result is None: result = [] for element in array: print(element) if isinstance(element, list): flatten_list(element, result) else: result.append(element) return result print(flatten_list([1, 2, 3, 4, 5, [1, 2], ...