content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
# This module is from mx/DateTime/LazyModule.py and is # distributed under the terms of the eGenix.com Public License Agreement # https://www.egenix.com/products/eGenix.com-Public-License-1.1.0.pdf """ Helper to enable simple lazy module import. 'Lazy' means the actual import is deferred until an attribute ...
""" Helper to enable simple lazy module import. 'Lazy' means the actual import is deferred until an attribute is requested from the module's namespace. This has the advantage of allowing all imports to be done at the top of a script (in a prominent and visible place) without having a great impact o...
stack = [] stack.append('a') stack.append('b') stack.append('c') print('Initial stack') print(stack) print('\nElements poped from stack:') print(stack.pop()) print(stack.pop()) print(stack.pop()) print('\nStack after elements are poped:') print(stack)
stack = [] stack.append('a') stack.append('b') stack.append('c') print('Initial stack') print(stack) print('\nElements poped from stack:') print(stack.pop()) print(stack.pop()) print(stack.pop()) print('\nStack after elements are poped:') print(stack)
"""Static values for one way import.""" SUPPORTED_FORMATS = (".svg", ".jpeg", ".jpg", ".png", ".tiff", ".tif") HTML_LINK = '<link rel="{rel}" type="{type}" href="{href}" />' ICON_TYPES = ( {"image_fmt": "ico", "rel": None, "dimensions": (64, 64), "prefix": "favicon"}, {"image_fmt": "png", "rel": "icon", "dim...
"""Static values for one way import.""" supported_formats = ('.svg', '.jpeg', '.jpg', '.png', '.tiff', '.tif') html_link = '<link rel="{rel}" type="{type}" href="{href}" />' icon_types = ({'image_fmt': 'ico', 'rel': None, 'dimensions': (64, 64), 'prefix': 'favicon'}, {'image_fmt': 'png', 'rel': 'icon', 'dimensions': (1...
def findLongestSubSeq(str): n = len(str) dp = [[0 for k in range(n+1)] for l in range(n+1)] for i in range(1, n+1): for j in range(1, n+1): # If characters match and indices are not same if (str[i-1] == str[j-1] and i != j): dp[i][j] = 1 + dp[i-1][j-1] # If characters do not match else:...
def find_longest_sub_seq(str): n = len(str) dp = [[0 for k in range(n + 1)] for l in range(n + 1)] for i in range(1, n + 1): for j in range(1, n + 1): if str[i - 1] == str[j - 1] and i != j: dp[i][j] = 1 + dp[i - 1][j - 1] else: dp[i][j] = max(...
""" [8/8/2012] Challenge #86 [easy] (run-length encoding) https://www.reddit.com/r/dailyprogrammer/comments/xxbbo/882012_challenge_86_easy_runlength_encoding/ Run-Length encoding is a simple form of compression that detects 'runs' of repeated instances of a symbol in a string and compresses them to a list of pairs of...
""" [8/8/2012] Challenge #86 [easy] (run-length encoding) https://www.reddit.com/r/dailyprogrammer/comments/xxbbo/882012_challenge_86_easy_runlength_encoding/ Run-Length encoding is a simple form of compression that detects 'runs' of repeated instances of a symbol in a string and compresses them to a list of pairs of...
@singleton class Database: def __init__(self): print('Loading database')
@singleton class Database: def __init__(self): print('Loading database')
#!/usr/bin/env python3 def get_case_data(): return [int(i) for i in input().split()] # Using recursive implementation def get_gcd(a, b): return get_gcd(b, a % b) if b != 0 else a def print_number_or_ok_if_equals(number, guess): print("OK" if number == guess else number) number_of_cases = int(input()) for case in...
def get_case_data(): return [int(i) for i in input().split()] def get_gcd(a, b): return get_gcd(b, a % b) if b != 0 else a def print_number_or_ok_if_equals(number, guess): print('OK' if number == guess else number) number_of_cases = int(input()) for case in range(number_of_cases): (first_integer, seco...
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def verticalTraversal(self, root: TreeNode) -> List[List[int]]: res = defaultdict(list) q = ...
class Solution: def vertical_traversal(self, root: TreeNode) -> List[List[int]]: res = defaultdict(list) q = [(root, 0)] min_col = max_col = 0 while q: q.sort(key=lambda x: (x[1], x[0].val)) min_col = min(min_col, q[0][1]) max_col = max(max_col, q...
# -*- coding: utf-8 -*- def main(): s = input() mod = '' for i in range(3): if s[i] == '1': mod += '9' elif s[i] == '9': mod += '1' print(mod) if __name__ == '__main__': main()
def main(): s = input() mod = '' for i in range(3): if s[i] == '1': mod += '9' elif s[i] == '9': mod += '1' print(mod) if __name__ == '__main__': main()
class Node: def __init__(self,data): self.data=data self.next=None arr=[5,8,20] brr=[4,11,15] #inserting elements in first list list1=Node(arr[0]) root1=list1 for i in arr[1::]: temp=Node(i) list1.next=temp list1=list1.next #inserting elements in second list lis...
class Node: def __init__(self, data): self.data = data self.next = None arr = [5, 8, 20] brr = [4, 11, 15] list1 = node(arr[0]) root1 = list1 for i in arr[1:]: temp = node(i) list1.next = temp list1 = list1.next list2 = node(brr[0]) root2 = list2 for i in brr[1:]: temp = node(i) ...
# Write your solution for 1.4 here! def is_prime(x): if x > 1: for i in range(2,x): if (x % i) == 0: print(x,"is not a prime number") print(i,"times",x//i,"is",x) else: print(x,"is not a prime number") is_prime(5)
def is_prime(x): if x > 1: for i in range(2, x): if x % i == 0: print(x, 'is not a prime number') print(i, 'times', x // i, 'is', x) else: print(x, 'is not a prime number') is_prime(5)
class PluginMount(type): """Generic plugin mount point (= entry point) for pydifact plugins. .. note:: Plugins that have an **__omitted__** attriute are not added to the list! """ # thanks to Marty Alchin! def __init__(cls, name, bases, attrs): if not hasattr(cls, "plugins"): ...
class Pluginmount(type): """Generic plugin mount point (= entry point) for pydifact plugins. .. note:: Plugins that have an **__omitted__** attriute are not added to the list! """ def __init__(cls, name, bases, attrs): if not hasattr(cls, 'plugins'): cls.plugins = [] ...
if __name__ == "__main__": print((lambda x,r : [r:=r+1 for i in x.split('\n\n') if all(map(lambda x : x in i,['byr','iyr','eyr','hgt','hcl','ecl','pid']))][-1])(open("i").read(),0)) def main_debug(inp): # 204 inp = inp.split('\n\n') rep = 0 for i in inp: if all(map(lambda x : x in i,['byr','iyr...
if __name__ == '__main__': print((lambda x, r: [(r := (r + 1)) for i in x.split('\n\n') if all(map(lambda x: x in i, ['byr', 'iyr', 'eyr', 'hgt', 'hcl', 'ecl', 'pid']))][-1])(open('i').read(), 0)) def main_debug(inp): inp = inp.split('\n\n') rep = 0 for i in inp: if all(map(lambda x: x in i, ['...
def flatten(iterable, result=None): if result == None: result = [] for it in iterable: if type(it) in (list, set, tuple): flatten(it, result) else: result.append(it) return [i for i in result if i is not None]
def flatten(iterable, result=None): if result == None: result = [] for it in iterable: if type(it) in (list, set, tuple): flatten(it, result) else: result.append(it) return [i for i in result if i is not None]
def palindromo(palavra: str) -> bool: if len(palavra) <= 1: return True primeira_letra = palavra[0] ultima_letra = palavra[-1] if primeira_letra != ultima_letra: return False return palindromo(palavra[1:-1]) nome_do_arquivo = input('Digite o nome do entrada de entrada: ') with open...
def palindromo(palavra: str) -> bool: if len(palavra) <= 1: return True primeira_letra = palavra[0] ultima_letra = palavra[-1] if primeira_letra != ultima_letra: return False return palindromo(palavra[1:-1]) nome_do_arquivo = input('Digite o nome do entrada de entrada: ') with open(n...
def main(): isNumber = False while not isNumber: try: size = int(input('Height: ')) if size > 0 and size <= 8: isNumber = True break except ValueError: isNumber = False build(size, size) def build(size, counter): sp...
def main(): is_number = False while not isNumber: try: size = int(input('Height: ')) if size > 0 and size <= 8: is_number = True break except ValueError: is_number = False build(size, size) def build(size, counter): spa...
#URLs ROOTURL = 'https://www.reuters.com/companies/' FXRATESURL = 'https://www.reuters.com/markets/currencies' #ADDURLs INCSTAT_ANN_URL = '/financials/income-statement-annual/' INCSTAT_QRT_URL = '/financials/income-statement-quarterly/' BS_ANN_URL = '/financials/balance-sheet-annual/' BS_QRT_URL = '/financials/balance...
rooturl = 'https://www.reuters.com/companies/' fxratesurl = 'https://www.reuters.com/markets/currencies' incstat_ann_url = '/financials/income-statement-annual/' incstat_qrt_url = '/financials/income-statement-quarterly/' bs_ann_url = '/financials/balance-sheet-annual/' bs_qrt_url = '/financials/balance-sheet-quarterly...
DEFAULT_PORT = 9000 DEFAULT_SECURE_PORT = 9440 DBMS_MIN_REVISION_WITH_TEMPORARY_TABLES = 50264 DBMS_MIN_REVISION_WITH_TOTAL_ROWS_IN_PROGRESS = 51554 DBMS_MIN_REVISION_WITH_BLOCK_INFO = 51903 # Legacy above. DBMS_MIN_REVISION_WITH_CLIENT_INFO = 54032 DBMS_MIN_REVISION_WITH_SERVER_TIMEZONE = 54058 DBMS_MIN_REVISION_WIT...
default_port = 9000 default_secure_port = 9440 dbms_min_revision_with_temporary_tables = 50264 dbms_min_revision_with_total_rows_in_progress = 51554 dbms_min_revision_with_block_info = 51903 dbms_min_revision_with_client_info = 54032 dbms_min_revision_with_server_timezone = 54058 dbms_min_revision_with_quota_key_in_cli...
class Solution(object): def maxProfit(self, prices): """ :type prices: List[int] :rtype: int """ res=0 prev=None for x in prices: res += x-prev if prev!=None and prev<x else 0 prev = x return res
class Solution(object): def max_profit(self, prices): """ :type prices: List[int] :rtype: int """ res = 0 prev = None for x in prices: res += x - prev if prev != None and prev < x else 0 prev = x return res
input_file = open("input.txt", "r") entriesArray = input_file.read().split("\n") depth_measure_increase = 0 for i in range(3, len(entriesArray), 1): first_window = int(entriesArray[i-1]) + int(entriesArray[i-2]) + int(entriesArray[i-3]) second_window = int(entriesArray[i]) + int(entriesArray[i-1]) + int(entrie...
input_file = open('input.txt', 'r') entries_array = input_file.read().split('\n') depth_measure_increase = 0 for i in range(3, len(entriesArray), 1): first_window = int(entriesArray[i - 1]) + int(entriesArray[i - 2]) + int(entriesArray[i - 3]) second_window = int(entriesArray[i]) + int(entriesArray[i - 1]) + in...
class Solution: def reverseString(self, s: List[str]) -> None: """ Do not return anything, modify s in-place instead. """ l , r = 0 , len(s)-1 while l<r: s[l] , s[r] = s[r] , s[l] l +=1 r -=1 return s
class Solution: def reverse_string(self, s: List[str]) -> None: """ Do not return anything, modify s in-place instead. """ (l, r) = (0, len(s) - 1) while l < r: (s[l], s[r]) = (s[r], s[l]) l += 1 r -= 1 return s
def multiplicationTable(size): return [[j*i for j in range(1, size+1)] for i in range(1, size+1)] x = multiplicationTable(5) print(x) print() for i in x: print(i)
def multiplication_table(size): return [[j * i for j in range(1, size + 1)] for i in range(1, size + 1)] x = multiplication_table(5) print(x) print() for i in x: print(i)
def getFrequencyDictForText(sentence): fullTermsDict = multidict.MultiDict() tmpDict = {} # making dictionary for counting word frequencies for text in sentence.split(" "): # remove irrelevant words if re.match("a|the|an|the|to|in|for|of|or|by|with|is|on|that|but|from|than|be", text): ...
def get_frequency_dict_for_text(sentence): full_terms_dict = multidict.MultiDict() tmp_dict = {} for text in sentence.split(' '): if re.match('a|the|an|the|to|in|for|of|or|by|with|is|on|that|but|from|than|be', text): continue val = tmpDict.get(text, 0) tmpDict[text.lower(...
class BoxaugError(Exception): pass
class Boxaugerror(Exception): pass
# short hand if a=23 b=4 if a > b: print("a is greater than b") # short hand if print("a is greater ") if a > b else print("b is greater ") #pass statements b=300 if b > a: pass
a = 23 b = 4 if a > b: print('a is greater than b') print('a is greater ') if a > b else print('b is greater ') b = 300 if b > a: pass
if args.algo in ['a2c', 'acktr']: values, action_log_probs, dist_entropy, conv_list = actor_critic.evaluate_actions(Variable(rollouts.states[:-1].view(-1, *obs_shape)), Variable(rollouts.actions.view(-1, action_shape))) # pre-process values = values.view(args.num_steps, num_processes_total, 1) action_lo...
if args.algo in ['a2c', 'acktr']: (values, action_log_probs, dist_entropy, conv_list) = actor_critic.evaluate_actions(variable(rollouts.states[:-1].view(-1, *obs_shape)), variable(rollouts.actions.view(-1, action_shape))) values = values.view(args.num_steps, num_processes_total, 1) action_log_probs = action...
''' Given an array consists of non-negative integers, your task is to count the number of triplets chosen from the array that can make triangles if we take them as side lengths of a triangle. Example 1: Input: [2,2,3,4] Output: 3 Explanation: Valid combinations are: 2,3,4 (using the first 2) 2,3,4 (using the second 2)...
""" Given an array consists of non-negative integers, your task is to count the number of triplets chosen from the array that can make triangles if we take them as side lengths of a triangle. Example 1: Input: [2,2,3,4] Output: 3 Explanation: Valid combinations are: 2,3,4 (using the first 2) 2,3,4 (using the second 2)...
a = [0x77, 0x60, 0x76, 0x66, 0x72, 0x77, 0x7D, 0x73, 0x60, 0x3D, 0x64, 0x60, 0x39, 0x52, 0x66, 0x3B, 0x73, 0x7A, 0x23, 0x7D, 0x73, 0x4A, 0x70, 0x78, 0x6A, 0x46, 0x69, 0x2B, 0x76, 0x68, 0x41, 0x77, 0x41, 0x42, 0x49, 0x4A, 0x4A, 0x42, 0x40, 0x48, 0x5A, 0x5A, 0x45, 0x41, 0x59, 0x03, 0x5A, 0x4A, 0x51, 0x5C, 0x4F] flag = ''...
a = [119, 96, 118, 102, 114, 119, 125, 115, 96, 61, 100, 96, 57, 82, 102, 59, 115, 122, 35, 125, 115, 74, 112, 120, 106, 70, 105, 43, 118, 104, 65, 119, 65, 66, 73, 74, 74, 66, 64, 72, 90, 90, 69, 65, 89, 3, 90, 74, 81, 92, 79] flag = '' for i in range(len(a)): flag += chr(a[i] ^ i) print(flag)
""" Datos de entrada: Nombre --> str --> A Compra --> float --> B Datos de salida: Total --> float --> C Nombre --> str --> A Compra --> float --> B Descuento --> float --> D """ # Entrada A = str(input("\nDigite tu nombre ")) B = float(input("Digite el valor de tu compra ")) # Caja negra if B < 50000: D...
""" Datos de entrada: Nombre --> str --> A Compra --> float --> B Datos de salida: Total --> float --> C Nombre --> str --> A Compra --> float --> B Descuento --> float --> D """ a = str(input('\nDigite tu nombre ')) b = float(input('Digite el valor de tu compra ')) if B < 50000: d = 0 elif 50000 <= B < 1000...
# This code is provoded by MDS DSCI 531/532 def mds_special(): font = "Arial" axisColor = "#000000" gridColor = "#DEDDDD" return { "config": { "title": { "fontSize": 24, "font": font, "anchor": "star...
def mds_special(): font = 'Arial' axis_color = '#000000' grid_color = '#DEDDDD' return {'config': {'title': {'fontSize': 24, 'font': font, 'anchor': 'start', 'fontColor': '#000000'}, 'view': {'height': 300, 'width': 400}, 'axisX': {'domain': True, 'gridColor': gridColor, 'domainWidth': 1, 'grid': False,...
# Writing a method class Shape: def __init__(self, name, sides, colour=None): self.name = name self.sides = sides self.colour = colour def get_info(self): return '{} {} with {} sides'.format(self.colour, self.name, ...
class Shape: def __init__(self, name, sides, colour=None): self.name = name self.sides = sides self.colour = colour def get_info(self): return '{} {} with {} sides'.format(self.colour, self.name, self.sides) s = shape('square', 4, 'green') print(s.get_info()) class Shape: ...
""" A very simple class to make running tests a bit simpler. There are much stronger frameworks possible; this is a KISS framework. Authors: David Mutchler, Valerie Galluzzi, Mark Hays, Amanda Stouder, and their colleagues. """ class SimpleTestCase(object): """ A SimpleTestCase is a test to run. It...
""" A very simple class to make running tests a bit simpler. There are much stronger frameworks possible; this is a KISS framework. Authors: David Mutchler, Valerie Galluzzi, Mark Hays, Amanda Stouder, and their colleagues. """ class Simpletestcase(object): """ A SimpleTestCase is a test to run. It ...
class Solution: def findSmallestSetOfVertices(self, n: int, edges: List[List[int]]) -> List[int]: degree = [0] * n for u, v in edges: degree[v] = 1 return [i for i, d in enumerate(degree) if d == 0]
class Solution: def find_smallest_set_of_vertices(self, n: int, edges: List[List[int]]) -> List[int]: degree = [0] * n for (u, v) in edges: degree[v] = 1 return [i for (i, d) in enumerate(degree) if d == 0]
#!/usr/bin/env python DEBUG = True SECRET_KEY = 'super-ultra-secret-key' DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': ':memory:', } } INSTALLED_APPS = [ 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.staticfiles', 'django_ta...
debug = True secret_key = 'super-ultra-secret-key' databases = {'default': {'ENGINE': 'django.db.backends.sqlite3', 'NAME': ':memory:'}} installed_apps = ['django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.staticfiles', 'django_tables2', 'django_tables2_column_shifter', 'django_tables2_column_shifter...
# classical (x, y) position vectors class Pos: def __init__(self, x, y): self.x = x self.y = y def __add__(self, other): return(Pos(self.x + other.x, self.y + other.y)) def __eq__(self, other): return( (self.x == other.x) and (self.y == other.y)) def __mul__(self, factor): return(Pos(factor * sel...
class Pos: def __init__(self, x, y): self.x = x self.y = y def __add__(self, other): return pos(self.x + other.x, self.y + other.y) def __eq__(self, other): return self.x == other.x and self.y == other.y def __mul__(self, factor): return pos(factor * self.x, f...
# model settings model = dict( type='Recognizer3D', backbone=dict( type='C3D', # pretrained= # noqa: E251 # 'https://download.openmmlab.com/mmaction/recognition/c3d/c3d_sports1m_pretrain_20201016-dcc47ddc.pth', # noqa: E501 pretrained= # noqa: E251 './work_dirs/fatigue...
model = dict(type='Recognizer3D', backbone=dict(type='C3D', pretrained='./work_dirs/fatigue_c3d/c3d_sports1m_pretrain_20201016-dcc47ddc.pth', style='pytorch', conv_cfg=dict(type='Conv3d'), norm_cfg=None, act_cfg=dict(type='ReLU'), dropout_ratio=0.5, init_std=0.005), cls_head=dict(type='I3DHead', num_classes=2, in_chann...
# # @lc app=leetcode id=55 lang=python # # [55] Jump Game # # https://leetcode.com/problems/jump-game/description/ # # algorithms # Medium (31.35%) # Total Accepted: 241.1K # Total Submissions: 767.2K # Testcase Example: '[2,3,1,1,4]' # # Given an array of non-negative integers, you are initially positioned at the ...
''' class Solution(object): def solver(self, nums, start_pos, stop_pos): if start_pos == len(nums)-1: return True for i in range(start_pos, stop_pos+1): res = self.solver(nums, i, min(len(nums)-1, start_pos+nums[start_pos])) if res: return res retu...
class HelperProcessRequest: """ This class allows agents to express their need for a helper process that may be shared with other agents. """ def __init__(self, python_file_path: str, key: str, executable: str = None): """ :param python_file_path: The file that should be loaded and insp...
class Helperprocessrequest: """ This class allows agents to express their need for a helper process that may be shared with other agents. """ def __init__(self, python_file_path: str, key: str, executable: str=None): """ :param python_file_path: The file that should be loaded and inspec...
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def lowestCommonAncestor(self, root: 'TreeNode', p: 'TreeNode', q: 'TreeNode') -> 'TreeNode': if root is None: return...
class Solution: def lowest_common_ancestor(self, root: 'TreeNode', p: 'TreeNode', q: 'TreeNode') -> 'TreeNode': if root is None: return None stack = deque([root]) parent = {root: None} while stack: node = stack.pop() if node.left: ...
def variance_of_sample_proportion(a,b,c,d,e,f,g,h,j,k): try: a = int(a) b = int(b) c = int(c) d = int(d) e = int(e) f = int(f) g = int(g) h = int(h) j = int(j) k = int(k) sample = [a,b,c,d,e,f,g,h,j,k] # Count how many ...
def variance_of_sample_proportion(a, b, c, d, e, f, g, h, j, k): try: a = int(a) b = int(b) c = int(c) d = int(d) e = int(e) f = int(f) g = int(g) h = int(h) j = int(j) k = int(k) sample = [a, b, c, d, e, f, g, h, j, k] ...
class FlatList(list): """ This class inherits from list and has the same interface as a list-type. However, there is a 'data'-attribute introduced, that is required for the encoding of the list! The fields of the encoding-Schema must match the fields of the Object to be encoded! """ @property ...
class Flatlist(list): """ This class inherits from list and has the same interface as a list-type. However, there is a 'data'-attribute introduced, that is required for the encoding of the list! The fields of the encoding-Schema must match the fields of the Object to be encoded! """ @property ...
class ITypeHintingFactory(object): def make_param_provider(self): """ :rtype: rope.base.oi.type_hinting.providers.interfaces.IParamProvider """ raise NotImplementedError def make_return_provider(self): """ :rtype: rope.base.oi.type_hinting.providers.interfaces.I...
class Itypehintingfactory(object): def make_param_provider(self): """ :rtype: rope.base.oi.type_hinting.providers.interfaces.IParamProvider """ raise NotImplementedError def make_return_provider(self): """ :rtype: rope.base.oi.type_hinting.providers.interfaces.I...
class Stack: def __init__(self): self.stack = [] self.current_minimum = float('inf') def push(self, item): if not self.stack: self.stack.append(item) self.current_minimum = item else: if item >= self.current_minimum: self.stack...
class Stack: def __init__(self): self.stack = [] self.current_minimum = float('inf') def push(self, item): if not self.stack: self.stack.append(item) self.current_minimum = item elif item >= self.current_minimum: self.stack.append(item) ...
# -*- coding: utf-8 -*- # Return the contents of a file def load_file(filename): with open(filename, "r") as f: return f.read() # Write contents to a file def write_file(filename, content): with open(filename, "w+") as f: f.write(content) # Append contents to a file def append_file(filename, content): ...
def load_file(filename): with open(filename, 'r') as f: return f.read() def write_file(filename, content): with open(filename, 'w+') as f: f.write(content) def append_file(filename, content): with open(filename, 'a+') as f: f.write(content)
def main(): t: tuple[i32, str] t = (1, 2) main()
def main(): t: tuple[i32, str] t = (1, 2) main()
# Config SIZES = { 'basic': 299 } NUM_CHANNELS = 3 NUM_CLASSES = 2 GENERATOR_BATCH_SIZE = 32 TOTAL_EPOCHS = 50 STEPS_PER_EPOCH = 100 VALIDATION_STEPS = 50 BASE_DIR = 'C:\\Users\\guilo\\mba-tcc\\data\\'
sizes = {'basic': 299} num_channels = 3 num_classes = 2 generator_batch_size = 32 total_epochs = 50 steps_per_epoch = 100 validation_steps = 50 base_dir = 'C:\\Users\\guilo\\mba-tcc\\data\\'
def test_split(): assert split(10) == 2 def test_string(): city = "String" assert type(city) == str def test_float(): price = 3.45 assert type(price) == float def test_int(): high_score = 1 assert type(high_score) == int def test_boolean(): is_having_fun = True assert type(is...
def test_split(): assert split(10) == 2 def test_string(): city = 'String' assert type(city) == str def test_float(): price = 3.45 assert type(price) == float def test_int(): high_score = 1 assert type(high_score) == int def test_boolean(): is_having_fun = True assert type(is_hav...
""" ID: tony_hu1 PROG: milk2 LANG: PYTHON3 """ def read_in(infile): a = [] with open(infile) as filename: for line in filename: a.append(line.rstrip()) return a def milk_cows_main(flines): total = [] num_cows = int(flines[0]) for i in range(num_cows): b = fline...
""" ID: tony_hu1 PROG: milk2 LANG: PYTHON3 """ def read_in(infile): a = [] with open(infile) as filename: for line in filename: a.append(line.rstrip()) return a def milk_cows_main(flines): total = [] num_cows = int(flines[0]) for i in range(num_cows): b = flines[i +...
A = 'A' B = 'B' RULE_ACTION = { 1: 'Suck', 2: 'Right', 3: 'Left', 4: 'NoOp' } rules = { (A, 'Dirty'): 1, (B, 'Dirty'): 1, (A, 'Clean'): 2, (B, 'Clean'): 3, (A, B, 'Clean'): 4 } # Ex. rule (if location == A && Dirty then 1) Environment = { A: 'Dirty', B: 'Dirty', 'Curre...
a = 'A' b = 'B' rule_action = {1: 'Suck', 2: 'Right', 3: 'Left', 4: 'NoOp'} rules = {(A, 'Dirty'): 1, (B, 'Dirty'): 1, (A, 'Clean'): 2, (B, 'Clean'): 3, (A, B, 'Clean'): 4} environment = {A: 'Dirty', B: 'Dirty', 'Current': A} def interpret_input(input): return input def rule_match(state, rules): rule = rules....
def convert(s): s_split = s.split(' ') return s_split def niceprint(s): for i, elm in enumerate(s): print('Element #', i + 1, ' = ', elm, sep='') return None c1 = 10 c2 = 's'
def convert(s): s_split = s.split(' ') return s_split def niceprint(s): for (i, elm) in enumerate(s): print('Element #', i + 1, ' = ', elm, sep='') return None c1 = 10 c2 = 's'
# Source : https://leetcode.com/problems/reverse-string-ii/#/description # Author : Han Zichi # Date : 2017-04-23 class Solution(object): def reverseStr(self, s, k): """ :type s: str :type k: int :rtype: str """ l = len(s) tmp = [] for i in range(0...
class Solution(object): def reverse_str(self, s, k): """ :type s: str :type k: int :rtype: str """ l = len(s) tmp = [] for i in range(0, l, k * 2): tmp.append(s[i:i + k * 2]) ans = '' for item in tmp: if k <= le...
# 1. def print_greeting(name, age_in_years, address): age_in_days = age_in_years * 365 age_in_years_1000_days_ago = (age_in_days - 1000) / 365 print("My name is " + name + " and I am " + str(age_in_years) + " years old (that's " + str(age_in_days) + " days). 1000 days ago, I was " ...
def print_greeting(name, age_in_years, address): age_in_days = age_in_years * 365 age_in_years_1000_days_ago = (age_in_days - 1000) / 365 print('My name is ' + name + ' and I am ' + str(age_in_years) + " years old (that's " + str(age_in_days) + ' days). 1000 days ago, I was ' + str(age_in_years_1000_days_ag...
# # PySNMP MIB module ASCEND-MIBIPSECSPD-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ASCEND-MIBIPSECSPD-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 17:11:32 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (d...
(configuration,) = mibBuilder.importSymbols('ASCEND-MIB', 'configuration') (octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_size_constraint, single_value_constr...
#!/usr/bin/env python # coding: utf-8 # In[2]: def utopianTree(cycles): h=1 for cyc_no in range(cycles): if (cyc_no%2==0): h=h*2 elif (cyc_no): h+=1 return h if __name__=='__main__': n=int(input()) for itr in range(n): cycles=int(input()) pr...
def utopian_tree(cycles): h = 1 for cyc_no in range(cycles): if cyc_no % 2 == 0: h = h * 2 elif cyc_no: h += 1 return h if __name__ == '__main__': n = int(input()) for itr in range(n): cycles = int(input()) print(utopian_tree(cycles))
# Copyright 2020 InterDigital Communications, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or ...
def rename_key(key): """Rename state_dict key.""" if '.downsample.bias' in key or '.downsample.weight' in key: return key.replace('downsample', 'skip') return key def load_pretrained(state_dict): """Convert state_dict keys.""" state_dict = {rename_key(k): v for (k, v) in state_dict.items()}...
def divisors(integer): aux = [i for i in range(2, integer) if integer % i == 0] if len(aux) == 0: return "{} is prime".format(integer) else: return aux
def divisors(integer): aux = [i for i in range(2, integer) if integer % i == 0] if len(aux) == 0: return '{} is prime'.format(integer) else: return aux
# coding: utf-8 pyslim_version = '0.700' slim_file_version = '0.7' # other file versions that require no modification compatible_slim_file_versions = ['0.7']
pyslim_version = '0.700' slim_file_version = '0.7' compatible_slim_file_versions = ['0.7']
""" Created on Sat Aug 27 12:52:52 2021 AI and deep learnin with Python Data types and operators Quiz Zip and Enumerate """ # Problem 1: """Use zip to write a for loop that creates a string specifying the label and coordinates of each point and appends it to the list points. Each string should be format...
""" Created on Sat Aug 27 12:52:52 2021 AI and deep learnin with Python Data types and operators Quiz Zip and Enumerate """ 'Use zip to write a for loop that creates a string specifying the label \nand coordinates of each point and appends it to the list points. \nEach string should be formatted as label: x, y, z. For...
def format_as_vsys(amount): abs_amount = abs(amount) whole = int(abs_amount / 100000000) fraction = abs_amount % 100000000 if amount < 0: whole *= -1 return f'{whole}.{str(fraction).rjust(8, "0")}'
def format_as_vsys(amount): abs_amount = abs(amount) whole = int(abs_amount / 100000000) fraction = abs_amount % 100000000 if amount < 0: whole *= -1 return f"{whole}.{str(fraction).rjust(8, '0')}"
class Solution: def canVisitAllRooms(self, rooms): stack = [0] visited = set(stack) while stack: curr = stack.pop() for room in rooms[curr]: if room not in visited: stack.append(room) visited.add(room) ...
class Solution: def can_visit_all_rooms(self, rooms): stack = [0] visited = set(stack) while stack: curr = stack.pop() for room in rooms[curr]: if room not in visited: stack.append(room) visited.add(room) ...
__author__ = 'spersinger' class Configuration: @staticmethod def run(): Configuration.enforce_ttl = True Configuration.ttl = 60 Configuration.run()
__author__ = 'spersinger' class Configuration: @staticmethod def run(): Configuration.enforce_ttl = True Configuration.ttl = 60 Configuration.run()
##### # https://github.com/sushiswap/sushiswap-subgraph # https://dev.sushi.com/api/overview # https://github.com/sushiswap/sushiswap-analytics/blob/c6919d56523b4418d174224a6b8964982f2a7948/src/core/api/index.js # CP_API_TOKEN = os.environ.get("cp_api_token") #"https://gateway.thegraph.com/api/c8eae2e5ac9d2e9d5d5459c33...
url = {'sushiexchange': 'https://api.thegraph.com/subgraphs/name/sushiswap/exchange', 'sushibar': 'https://api.thegraph.com/subgraphs/name/matthewlilley/bar', 'aave': 'https://api.thegraph.com/subgraphs/name/aave/protocol-v2'}
""" Telemac-Mascaret exceptions """ class TelemacException(Exception): """ Generic exception class for all of Telemac-Mascaret Exceptions """ pass class MascaretException(TelemacException): """ Generic exception class for all of Telemac-Mascaret Exceptions """ pass
""" Telemac-Mascaret exceptions """ class Telemacexception(Exception): """ Generic exception class for all of Telemac-Mascaret Exceptions """ pass class Mascaretexception(TelemacException): """ Generic exception class for all of Telemac-Mascaret Exceptions """ pass
# -*- coding: utf-8 -*- commands = { 'start_AfterAuthorized': u'Welcome to remoteSsh_bot\n\n' u'If you known password - use /on\n' u'else - connect to admin', 'start_BeforeAuthorized': u'Hello!\n' ...
commands = {'start_AfterAuthorized': u'Welcome to remoteSsh_bot\n\nIf you known password - use /on\nelse - connect to admin', 'start_BeforeAuthorized': u'Hello!\nIf you want information about this bot - use /information\nIf you want command list - use /help', 'help_AfterAuthorized': u'If you known password - use /on\ne...
# -*- coding: utf-8 -*- """ Created on Mon Feb 5 14:31:36 2018 @author: User """ # part 1-e def multlist(m1, m2): lenof = len(m1) newl = [] for i in range(lenof): newl.append( m1[i]* m2[i]) print(None) m1=[1, 2, 23, 104] m2=[-3, 2, 0, 6] multlist(m1, m2) # part 1-a #def cr...
""" Created on Mon Feb 5 14:31:36 2018 @author: User """ def multlist(m1, m2): lenof = len(m1) newl = [] for i in range(lenof): newl.append(m1[i] * m2[i]) print(None) m1 = [1, 2, 23, 104] m2 = [-3, 2, 0, 6] multlist(m1, m2)
''' ''' def main(): info('Pump Microbone') close(description="Jan Inlet") if is_closed('F'): open(description= 'Microbone to CO2 Laser') else: close(name="T", description="Microbone to CO2 Laser") sleep(1) close(description= 'CO2 Laser to Roughing') #close(description...
""" """ def main(): info('Pump Microbone') close(description='Jan Inlet') if is_closed('F'): open(description='Microbone to CO2 Laser') else: close(name='T', description='Microbone to CO2 Laser') sleep(1) close(description='CO2 Laser to Roughing') open(description='Microbone...
def findDecision(obj): #obj[0]: Driving_to, obj[1]: Passanger, obj[2]: Weather, obj[3]: Temperature, obj[4]: Time, obj[5]: Coupon, obj[6]: Coupon_validity, obj[7]: Gender, obj[8]: Age, obj[9]: Maritalstatus, obj[10]: Children, obj[11]: Education, obj[12]: Occupation, obj[13]: Income, obj[14]: Bar, obj[15]: Coffeehouse,...
def find_decision(obj): if obj[11] > 1: if obj[12] > 3: if obj[13] > 1: if obj[9] <= 1: if obj[16] > 1.0: if obj[10] <= 0: return 'True' elif obj[10] > 0: i...
bil = 0 count = 0 hasil = 0 while(bil <= 100): if(bil % 2 == 1): count += 1 hasil += bil print(bil) bil += 1 print('Banyaknya bilangan ganjil :', count) print('Jumlah seluruh bilangan :', hasil)
bil = 0 count = 0 hasil = 0 while bil <= 100: if bil % 2 == 1: count += 1 hasil += bil print(bil) bil += 1 print('Banyaknya bilangan ganjil :', count) print('Jumlah seluruh bilangan :', hasil)
def mapping_Luo(t=1): names = [ 'Yao_6_2', 'AB_TMA_2', 'ABA_TMA_2', 'ABAB_TMA_2', 'ABABA_TMA_2', 'ABABA_IPrMeP_2'] xlocs = [ 21400, 5500, -7200, -11700, -17200, -30700] ylocs = [ 0, 0, 0, 0, ...
def mapping__luo(t=1): names = ['Yao_6_2', 'AB_TMA_2', 'ABA_TMA_2', 'ABAB_TMA_2', 'ABABA_TMA_2', 'ABABA_IPrMeP_2'] xlocs = [21400, 5500, -7200, -11700, -17200, -30700] ylocs = [0, 0, 0, 0, 0, 0] zlocs = [2700, 2700, 2700, 2700, 2700, 2700] x_range = [[0, 500, 21], [0, 500, 21], [0, 500, 21], [0, 500...
# -*- coding: utf-8 -*- """ Created on Mon Feb 12 21:55:16 2018 @author: User """ def by_courses(file): lol = [] name_dict = {} f = open(file, 'r') all_details = f.read() lol.append([all_details]) f.close() all_details = [line for line in all_details.split('\n') if line.strip()...
""" Created on Mon Feb 12 21:55:16 2018 @author: User """ def by_courses(file): lol = [] name_dict = {} f = open(file, 'r') all_details = f.read() lol.append([all_details]) f.close() all_details = [line for line in all_details.split('\n') if line.strip() != ''] for each in all_details:...
def alpha_numeric(m): return re.sub('[^A-Za-z0-9]+', ' ', m) def uri_from_fields(fields): string = '_'.join(alpha_numeric(f.strip().lower()) for f in fields) if len(string) == len(fields)-1: return '' return string def splitLocation(location): return re.search('[NS]',location).start() def getLatitude(s,l): ...
def alpha_numeric(m): return re.sub('[^A-Za-z0-9]+', ' ', m) def uri_from_fields(fields): string = '_'.join((alpha_numeric(f.strip().lower()) for f in fields)) if len(string) == len(fields) - 1: return '' return string def split_location(location): return re.search('[NS]', location).start(...
def solve(input, days): # Lanternfish with internal timer t are the number of lanternfish with timer t+1 after a day for day in range(days): aux = input[0] input[0] = input[1] input[1] = input[2] input[2] = input[3] input[3] = input[4] input[4] = input[5] ...
def solve(input, days): for day in range(days): aux = input[0] input[0] = input[1] input[1] = input[2] input[2] = input[3] input[3] = input[4] input[4] = input[5] input[5] = input[6] input[6] = input[7] + aux input[7] = input[8] input[8...
def funcao1(funcao, *args, **kwargs): return funcao(*args, **kwargs) def funcao2(nome): return f'Oi {nome}' def funcao3(nome, saudacao): return f'{saudacao} {nome}' executando = funcao1(funcao2, 'Luiz') print(executando) executando = funcao1(funcao3, 'Luiz', saudacao='Bom dia') print(executando)
def funcao1(funcao, *args, **kwargs): return funcao(*args, **kwargs) def funcao2(nome): return f'Oi {nome}' def funcao3(nome, saudacao): return f'{saudacao} {nome}' executando = funcao1(funcao2, 'Luiz') print(executando) executando = funcao1(funcao3, 'Luiz', saudacao='Bom dia') print(executando)
true = True; false = False; true1 = "True"; false1 = "False"; true2 = true; ''' I was trying to check if keyword is case sensitive which it is not but here the above defined variable value is taken which is bool This technique can be used to define case insensitive keywords at start to py program.''' false2 = false; pr...
true = True false = False true1 = 'True' false1 = 'False' true2 = true ' I was trying to check if keyword is case sensitive which it is not but here the above defined variable value is taken which is bool\nThis technique can be used to define case insensitive keywords at start to py program.' false2 = false print(true,...
## input = 1,2,3,4 ## output = ['1','2','3','4'], ('1','2','3','4') def abc(): values = input() print("----") print(values) print("----") x = values.split(",") print(x) y = tuple(x) print("===") print(y) if __name__ == "__main__": abc()
def abc(): values = input() print('----') print(values) print('----') x = values.split(',') print(x) y = tuple(x) print('===') print(y) if __name__ == '__main__': abc()
#!/usr/bin/env python3 FILENAME = "/tmp/passed" bmks = [] with open(FILENAME, "r") as f: for l in f: [m, a] = l.split(" ") t = (m, a.strip()) bmks.append(t) def quote(s): return '"{}"'.format(s) indent = " " output = '{}[ {}\n{}]'.format(indent, f'\n{indent}, '.join(f'("{m}", "{a}"...
filename = '/tmp/passed' bmks = [] with open(FILENAME, 'r') as f: for l in f: [m, a] = l.split(' ') t = (m, a.strip()) bmks.append(t) def quote(s): return '"{}"'.format(s) indent = ' ' output = '{}[ {}\n{}]'.format(indent, f'\n{indent}, '.join((f'("{m}", "{a}")' for (m, a) in bmks)), i...
class Solution: def ladderLength(self, beginWord: str, endWord: str, wordList: List[str]) -> int: """BFS. """ words = set(wordList) if endWord not in words: return 0 layer = set([beginWord]) res = 1 while layer: nlayer = set() ...
class Solution: def ladder_length(self, beginWord: str, endWord: str, wordList: List[str]) -> int: """BFS. """ words = set(wordList) if endWord not in words: return 0 layer = set([beginWord]) res = 1 while layer: nlayer = set() ...
{ "includes": [ "../common.gypi" ], "targets": [ { "target_name": "libgdal_ogr_vrt_frmt", "type": "static_library", "sources": [ "../gdal/ogr/ogrsf_frmts/vrt/ogrvrtlayer.cpp", "../gdal/ogr/ogrsf_frmts/vrt/ogrvrtdriver.cpp", "../gdal/ogr/ogrsf_frmts/vrt/ogrvrtdatasource.cpp" ], "include...
{'includes': ['../common.gypi'], 'targets': [{'target_name': 'libgdal_ogr_vrt_frmt', 'type': 'static_library', 'sources': ['../gdal/ogr/ogrsf_frmts/vrt/ogrvrtlayer.cpp', '../gdal/ogr/ogrsf_frmts/vrt/ogrvrtdriver.cpp', '../gdal/ogr/ogrsf_frmts/vrt/ogrvrtdatasource.cpp'], 'include_dirs': ['../gdal/ogr/ogrsf_frmts/vrt']}]...
class Compose(object): """Composes several transforms together for object detection. Args: transforms (list of ``Transform`` objects): list of transforms to compose. """ def __init__(self, transforms): self.transforms = transforms def __call__(self, image, target): for t i...
class Compose(object): """Composes several transforms together for object detection. Args: transforms (list of ``Transform`` objects): list of transforms to compose. """ def __init__(self, transforms): self.transforms = transforms def __call__(self, image, target): for t i...
def subarraysCountBySum(a, k, s): ans=0 n=len(a) t=0 ii=1 while(k+t<=n): tmp=[] for i in range(t,ii+t): tmp.append(a[i]) print(tmp) ii+=1 if len(tmp)<=k and sum(tmp)==s: ans+=1 t+=1 else: break return ans a=list(ma...
def subarrays_count_by_sum(a, k, s): ans = 0 n = len(a) t = 0 ii = 1 while k + t <= n: tmp = [] for i in range(t, ii + t): tmp.append(a[i]) print(tmp) ii += 1 if len(tmp) <= k and sum(tmp) == s: ans += 1 t += 1 else:...
def main(request, response): response.headers.set(b"Content-Type", b"text/plain") response.status = 200 response.content = request.headers.get(b"Content-Type") response.close_connection = True
def main(request, response): response.headers.set(b'Content-Type', b'text/plain') response.status = 200 response.content = request.headers.get(b'Content-Type') response.close_connection = True
fruits = ['banana', 'orange', 'mango', 'lemon'] fruit = str(input('Enter a fruit: ')).strip().lower() if fruit not in fruits: fruits.append(fruit) print(fruits) else: print(f'{fruit} already in the list')
fruits = ['banana', 'orange', 'mango', 'lemon'] fruit = str(input('Enter a fruit: ')).strip().lower() if fruit not in fruits: fruits.append(fruit) print(fruits) else: print(f'{fruit} already in the list')
amount = 20 num=1 def setup(): size(640, 640) stroke(0, 150, 255, 100) def draw(): global num, amount fill(0, 40) rect(-1, -1, width+1, height+1) maxX = map(mouseX, 0, width, 1, 250) translate(width/2, height/2) for i in range(0,360,amount): x = sin(radians(i+num)) * maxX ...
amount = 20 num = 1 def setup(): size(640, 640) stroke(0, 150, 255, 100) def draw(): global num, amount fill(0, 40) rect(-1, -1, width + 1, height + 1) max_x = map(mouseX, 0, width, 1, 250) translate(width / 2, height / 2) for i in range(0, 360, amount): x = sin(radians(i + num...
class EmailValidator(object): """Abstract email validator to subclass from. You should not instantiate an EmailValidator, as it merely provides the interface for is_email, not an implementation. """ def is_email(self, address, diagnose=False): """Interface for is_email method. K...
class Emailvalidator(object): """Abstract email validator to subclass from. You should not instantiate an EmailValidator, as it merely provides the interface for is_email, not an implementation. """ def is_email(self, address, diagnose=False): """Interface for is_email method. Ke...
# Copyright (c) Microsoft Corporation. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in wri...
async def test_listeners(page, server): log = [] def print_response(response): log.append(response) page.on('response', print_response) await page.goto(f'{server.PREFIX}/input/textarea.html') assert len(log) > 0 page.remove_listener('response', print_response) log = [] await pag...
class Backend(object): # should be implemented all methods def set(self, name, value): raise NotImplementedError() def get(self, name): raise NotImplementedError() def delete(self, name): raise NotImplementedError() def set_fields(self): raise NotImplementedError()...
class Backend(object): def set(self, name, value): raise not_implemented_error() def get(self, name): raise not_implemented_error() def delete(self, name): raise not_implemented_error() def set_fields(self): raise not_implemented_error() def fields(self): ...
number_of_days = int(input()) type_of_room = str(input()) rating = str(input()) room_for_one_person = 18.00 apartment = 25.00 president_apartment = 35.00 apartment_discount = 0 president_apartment_discount = 0 total_price_for_a_room = 0 total_price_for_apartment = 0 total_price_for_presidential_apartment = 0 addition...
number_of_days = int(input()) type_of_room = str(input()) rating = str(input()) room_for_one_person = 18.0 apartment = 25.0 president_apartment = 35.0 apartment_discount = 0 president_apartment_discount = 0 total_price_for_a_room = 0 total_price_for_apartment = 0 total_price_for_presidential_apartment = 0 additional_di...
LIST_WORKFLOWS_GQL = ''' query workflowList { workflowList { edges{ node { id name objectType initialPrefetch initialState { id name } initialTransition { id name } } } } } ''' LIST_STATES_GQL...
list_workflows_gql = '\nquery workflowList {\n workflowList {\n edges{\n node {\n id\n name\n objectType\n initialPrefetch\n initialState {\n id\n name\n }\n initialTransition {\n id\n name\n }\n }\n }\n }\n}\n...
""" # Sample code to perform I/O: name = input() # Reading input from STDIN print('Hi, %s.' % name) # Writing output to STDOUT # Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail """ # Write your code here x = ['0', '1', '8'] t = int(int(input())) f...
""" # Sample code to perform I/O: name = input() # Reading input from STDIN print('Hi, %s.' % name) # Writing output to STDOUT # Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail """ x = ['0', '1', '8'] t = int(int(input())) for _ in range(t): n ...
""" if __name__ == '__main__': for _ in range(int(input())): name = input() score = float(input()) """ # pythonNestedLists.py #!/usr/bin/env python N = int(input()) students = list() for i in range(N): students.append([input(), float(input())]) scores = set([students[x][1] for x in range(N)]...
""" if __name__ == '__main__': for _ in range(int(input())): name = input() score = float(input()) """ n = int(input()) students = list() for i in range(N): students.append([input(), float(input())]) scores = set([students[x][1] for x in range(N)]) scores = list(scores) scores.sort() students =...
with open("text.txt", "w") as my_file: my_file.write("Tretas dos Bronzetas") if my_file.closed == False: my_file.close() print(my_file.closed)
with open('text.txt', 'w') as my_file: my_file.write('Tretas dos Bronzetas') if my_file.closed == False: my_file.close() print(my_file.closed)
test = { 'name': 'Mutability', 'points': 0, 'suites': [ { 'type': 'wwpp', 'cases': [ { 'code': """ >>> lst = [5, 6, 7, 8] >>> lst.append(6) Nothing >>> lst [5, 6, 7, 8, 6] >>> lst.insert(0, 9) >>> lst ...
test = {'name': 'Mutability', 'points': 0, 'suites': [{'type': 'wwpp', 'cases': [{'code': '\n >>> lst = [5, 6, 7, 8]\n >>> lst.append(6)\n Nothing\n >>> lst\n [5, 6, 7, 8, 6]\n >>> lst.insert(0, 9)\n >>> lst\n [9, 5, 6, 7, 8, 6]\n >>> x = ...
DESCRIBE_VMS = [ { "id": "/subscriptions/00-00-00-00/resourceGroups/TestRG/providers/Microsoft.Compute/virtualMachines/TestVM", "type": "Microsoft.Compute/virtualMachines", "location": "West US", "resource_group": "TestRG", "name": "TestVM", "plan": { "pro...
describe_vms = [{'id': '/subscriptions/00-00-00-00/resourceGroups/TestRG/providers/Microsoft.Compute/virtualMachines/TestVM', 'type': 'Microsoft.Compute/virtualMachines', 'location': 'West US', 'resource_group': 'TestRG', 'name': 'TestVM', 'plan': {'product': 'Standard'}, 'handware_profile': {'vm_size': 'Standard_D2s_v...
''' Pattern Enter number of rows: 5 1 21 321 4321 54321 ''' print('Number Pattern:') number_rows=int(input('Enter number of rows: ')) for row in range(1,number_rows+1): for column in range(row,0,-1): if column < 10: print(f'0{column}',end=' ') else: print(column,end=' ') print()
""" Pattern Enter number of rows: 5 1 21 321 4321 54321 """ print('Number Pattern:') number_rows = int(input('Enter number of rows: ')) for row in range(1, number_rows + 1): for column in range(row, 0, -1): if column < 10: print(f'0{column}', end=' ') else: print(column, end=...
class Solution: def isStrobogrammatic(self, num: str) -> bool: dic = {'1': '1', '6': '9', '8': '8', '9': '6', '0': '0'} l, r = 0, len(num)-1 while l <= r: if num[l] not in dic or dic[num[l]] != num[r]: return False l += 1 r -= 1 ret...
class Solution: def is_strobogrammatic(self, num: str) -> bool: dic = {'1': '1', '6': '9', '8': '8', '9': '6', '0': '0'} (l, r) = (0, len(num) - 1) while l <= r: if num[l] not in dic or dic[num[l]] != num[r]: return False l += 1 r -= 1 ...
# Runtime: 128 ms # Beats 99.53% of Python submissions # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def insertIntoBST(self, root, val): """ :type root: TreeNode ...
class Solution: def insert_into_bst(self, root, val): """ :type root: TreeNode :type val: int :rtype: TreeNode """ curr_root = root if not curr_root: root = tree_node(val) return root while curr_root: if curr_root.v...
""" Iterate List of list vertically tags : Twitter, array """ class Solution(): def vertical_iterator(self, arr): ans = [] arr_len = len(arr) col = 0 while True: is_empty = True for x in range(arr_len): if col < len(arr[x]): ...
""" Iterate List of list vertically tags : Twitter, array """ class Solution: def vertical_iterator(self, arr): ans = [] arr_len = len(arr) col = 0 while True: is_empty = True for x in range(arr_len): if col < len(arr[x]): ...
# -*- coding: utf-8 -*- name = 'usd' version = '20.02' requires = [ 'alembic-1.5', 'boost-1.55', 'tbb-4.4.6', 'opensubdiv-3.2', 'ilmbase-2.2', 'jinja-2', 'jemalloc-4', 'openexr-2.2', 'pyilmbase-2.2', 'materialx', 'oiio-1.8', 'ptex-2.0', 'PyOpenGL', 'embree_lib'...
name = 'usd' version = '20.02' requires = ['alembic-1.5', 'boost-1.55', 'tbb-4.4.6', 'opensubdiv-3.2', 'ilmbase-2.2', 'jinja-2', 'jemalloc-4', 'openexr-2.2', 'pyilmbase-2.2', 'materialx', 'oiio-1.8', 'ptex-2.0', 'PyOpenGL', 'embree_lib', 'glew', 'renderman-22.6', 'ocio-1.0.9'] build_requires = ['pyside-1.2'] private_bu...
contador = 1 while contador <= 9: for contador2 in range(7, 4, -1): print(f'I={contador} J={contador2}') contador += 2
contador = 1 while contador <= 9: for contador2 in range(7, 4, -1): print(f'I={contador} J={contador2}') contador += 2
# Advent of Code - Day 4 valid_passport_data = { 'ecl', 'pid', 'eyr', 'hcl', 'byr', 'iyr', 'hgt', } count_required_data = len(valid_passport_data) def ecl_rule(value): return value in {'amb', 'blu', 'brn', 'gry', 'grn', 'hzl', 'oth'} def pid_rule(value): try: int(value) isnumber = True...
valid_passport_data = {'ecl', 'pid', 'eyr', 'hcl', 'byr', 'iyr', 'hgt'} count_required_data = len(valid_passport_data) def ecl_rule(value): return value in {'amb', 'blu', 'brn', 'gry', 'grn', 'hzl', 'oth'} def pid_rule(value): try: int(value) isnumber = True except: isnumber = Fals...