content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
class ScrollProperties(object): """ Encapsulates properties related to scrolling. """ def Instance(self): """ This function has been arbitrarily put into the stubs""" return ScrollProperties() @staticmethod def __new__(self,*args): #cannot find CLR constructor """ __new__(cls: type,container: Scrolla...
class Scrollproperties(object): """ Encapsulates properties related to scrolling. """ def instance(self): """ This function has been arbitrarily put into the stubs""" return scroll_properties() @staticmethod def __new__(self, *args): """ __new__(cls: type,container: ScrollableC...
# -- coding: utf-8 -- # Created by LoginRadius Development Team # Copyright 2019 LoginRadius Inc. All rights reserved. # class MultiFactorAuthenticationApi: def __init__(self, lr_object): """ :param lr_object: this is the reference to the parent LoginRadius object. """ self._lr_ob...
class Multifactorauthenticationapi: def __init__(self, lr_object): """ :param lr_object: this is the reference to the parent LoginRadius object. """ self._lr_object = lr_object def mfa_configure_by_access_token(self, access_token, sms_template2_f_a=None): """This API is...
"""Not sure why memory limit exceeded, but this solution works""" class Solution(object): def wordBreak(self, s, wordDict): """ :type s: str :type wordDict: List[str] :rtype: List[str] """ def postProcess(combos, s): if combos is None: re...
"""Not sure why memory limit exceeded, but this solution works""" class Solution(object): def word_break(self, s, wordDict): """ :type s: str :type wordDict: List[str] :rtype: List[str] """ def post_process(combos, s): if combos is None: ...
class IAMPolicies(): def __init__(self, iam): self.client = iam def _marker_handler(self, marker=None, scope='All'): if marker: response = self.client.list_policies( Scope=scope, OnlyAttached=True, PolicyUsageFilter='PermissionsPolicy...
class Iampolicies: def __init__(self, iam): self.client = iam def _marker_handler(self, marker=None, scope='All'): if marker: response = self.client.list_policies(Scope=scope, OnlyAttached=True, PolicyUsageFilter='PermissionsPolicy', Marker=marker) else: respons...
runtime_project='core' editor_project='core-Editor' runtime_project_file='Assembly-CSharp' editor_project_file='Assembly-CSharp-Editor' define='ANDROID' MONO="/Applications/Unity/MonoDevelop.app/Contents/Frameworks/Mono.framework/Versions/Current/bin/mono" MDTOOL="/Applications/Unity/MonoDevelop.app/Contents/MacOS/lib...
runtime_project = 'core' editor_project = 'core-Editor' runtime_project_file = 'Assembly-CSharp' editor_project_file = 'Assembly-CSharp-Editor' define = 'ANDROID' mono = '/Applications/Unity/MonoDevelop.app/Contents/Frameworks/Mono.framework/Versions/Current/bin/mono' mdtool = '/Applications/Unity/MonoDevelop.app/Conte...
L = 0 heatmap = [] while True: try: line = [int(x) for x in input()] # Pad heatmap with 9s heat = [9] + line + [9] L = len(heat) heatmap.extend(heat) except EOFError: break index = 0 # Pad 9s in top and bottom heatmap = heatmap + (L*[9]) bigmap = (L*[9]) + ...
l = 0 heatmap = [] while True: try: line = [int(x) for x in input()] heat = [9] + line + [9] l = len(heat) heatmap.extend(heat) except EOFError: break index = 0 heatmap = heatmap + L * [9] bigmap = L * [9] + heatmap + L * [9] total = [] for (index, value) in enumerate(hea...
# Copyright 2019 the rules_bison authors. # # 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...
load('@rules_bison//bison/internal:versions.bzl', _VERSION_URLS='VERSION_URLS') _gnulib_version = '788db09a9f88abbef73c97e8d7291c40455336d8' _gnulib_sha256 = '4350696d531852118f3735a0e2d1091746388392c27d582f0cc241b6a39fe493' _url_base = 'github.com/jmillikin/rules_bison/releases/download/v0.1/bison-gnulib-{}.tar.xz'.fo...
test = { 'name': 'q1_19', 'points': 1, 'suites': [ { 'cases': [ { 'code': r""" >>> -1 <= observed_diff_proportion <= 1 True """, 'hidden': False, 'locked': False }, { 'code': r""" >>> # The observed d...
test = {'name': 'q1_19', 'points': 1, 'suites': [{'cases': [{'code': '\n >>> -1 <= observed_diff_proportion <= 1\n True\n ', 'hidden': False, 'locked': False}, {'code': '\n >>> # The observed difference in proportion should be about 0.219;\n >>> np.round(observed_diff_propor...
# Enter your code for "Hello with attitude" here. name = input("What is your name? ") print("So you call yourself '" + name + "' huh?")
name = input('What is your name? ') print("So you call yourself '" + name + "' huh?")
# https://www.codewars.com/kata/59e49b2afc3c494d5d00002a/train/python def sort_vowels(s): if isinstance(s, int) or s == None: return '' vovels = ['a', 'e', 'u', 'i', 'o'] output = [] for letter in s: if vovels.count(letter.lower()) > 0: output.append(f'|{let...
def sort_vowels(s): if isinstance(s, int) or s == None: return '' vovels = ['a', 'e', 'u', 'i', 'o'] output = [] for letter in s: if vovels.count(letter.lower()) > 0: output.append(f'|{letter}') else: output.append(f'{letter}|') return '\n'.join(output...
#!/usr/bin/python3 # The MDPs consists of a range of integers 0..stateMax which represent # the states of the MDP, a set of actions. The rewards and transition # probabilities are accessed with some of the functions below defined # for the Python classes that represent MDPs. # # - The __init__ constructor builds the ...
class Gridmdp: def __init__(self, xs, ys, cells, teleport=False): self.xSize = xs self.ySize = ys self.stateMax = xs * ys - 1 self.grid = cells self.teleport = teleport north = 1 south = 2 west = 3 east = 4 actions = [NORTH, SOUTH, WEST, EAST] def tu...
W = int(input()) N, K = map(int, input().split()) dp = [{} for _ in range(K + 1)] dp[0][0] = 0 for _ in range(N): A, B = map(int, input().split()) for i in range(K - 1, -1, -1): for j in dp[i]: if j + A <= W: dp[i + 1].setdefault(j + A, 0) dp[i + 1][j + A] = ...
w = int(input()) (n, k) = map(int, input().split()) dp = [{} for _ in range(K + 1)] dp[0][0] = 0 for _ in range(N): (a, b) = map(int, input().split()) for i in range(K - 1, -1, -1): for j in dp[i]: if j + A <= W: dp[i + 1].setdefault(j + A, 0) dp[i + 1][j + A]...
# This file is part of the DMComm project by BladeSabre. License: MIT. class ProngOutput: """Description of the outputs for the RP2040 prong circuit. :param pin_drive_signal: The first pin to use for signal output. Note that `pin_drive_low=pin_drive_signal+1` due to the rules of PIO. :param pin_weak_pull: The pi...
class Prongoutput: """Description of the outputs for the RP2040 prong circuit. :param pin_drive_signal: The first pin to use for signal output. Note that `pin_drive_low=pin_drive_signal+1` due to the rules of PIO. :param pin_weak_pull: The pin to use for the weak pull-up / pull-down. """ def __init__(sel...
class RenderInterface(object): def render(self): raise NotImplementedError("Class %s doesn't implement render()" % (self.__class__.__name__)) class ViewportInterface(object): def to_dict(self): raise NotImplementedError("Class %s doesn't implement to_dict()" % (self.__class__.__name__)) d...
class Renderinterface(object): def render(self): raise not_implemented_error("Class %s doesn't implement render()" % self.__class__.__name__) class Viewportinterface(object): def to_dict(self): raise not_implemented_error("Class %s doesn't implement to_dict()" % self.__class__.__name__) ...
num1 = int(input('digite um valor')) num2 = int(input('digite um valor')) s = num1 + num2 print('A soma entre {} e {} vale {}'.format(num1, num2, s))
num1 = int(input('digite um valor')) num2 = int(input('digite um valor')) s = num1 + num2 print('A soma entre {} e {} vale {}'.format(num1, num2, s))
def modify_phoneme_script_to_create_grapheme_script(original_dataset_path, grapheme_dataset_path): with open(original_dataset_path, 'r', encoding='utf-8-sig') as f: lines = f.readlines() new_lines = [] for line in lines: split_result = line.split('|') wav_path = split_result[0] ...
def modify_phoneme_script_to_create_grapheme_script(original_dataset_path, grapheme_dataset_path): with open(original_dataset_path, 'r', encoding='utf-8-sig') as f: lines = f.readlines() new_lines = [] for line in lines: split_result = line.split('|') wav_path = split_result[0] ...
# Solution def add_one(arr): output = 1; for i in range(len(arr), 0, -1): output = output + arr[i - 1] borrow = output//10 if borrow == 0: arr[i - 1] = output break else: arr[i - 1] = output % 10 output = borrow arr = [borrow] ...
def add_one(arr): output = 1 for i in range(len(arr), 0, -1): output = output + arr[i - 1] borrow = output // 10 if borrow == 0: arr[i - 1] = output break else: arr[i - 1] = output % 10 output = borrow arr = [borrow] + arr i...
def interpolation_search(arr, key): low = 0 high = len(arr) - 1 while arr[high] != arr[low] and key >= arr[low] and key <= arr[high]: mid = int(low + ((key - arr[low]) * (high - low) / (arr[high] - arr[low]))) if arr[mid] == key: return mid elif arr[mid] < key: ...
def interpolation_search(arr, key): low = 0 high = len(arr) - 1 while arr[high] != arr[low] and key >= arr[low] and (key <= arr[high]): mid = int(low + (key - arr[low]) * (high - low) / (arr[high] - arr[low])) if arr[mid] == key: return mid elif arr[mid] < key: ...
# encoding: utf-8 # module Tekla.Structures.Model.History calls itself History # from Tekla.Structures.Model,Version=2017.0.0.0,Culture=neutral,PublicKeyToken=2f04dbe497b71114 # by generator 1.145 # no doc # no imports # no functions # classes class ModelHistory(object): # no doc @staticmethod ...
class Modelhistory(object): @staticmethod def get_current_modification_stamp(): """ GetCurrentModificationStamp() -> ModificationStamp """ pass @staticmethod def get_deleted_objects(ModStamp): """ GetDeletedObjects(ModStamp: ModificationStamp) -> ModelObjectEnumerator """ ...
# dividebyzero.py """Simple exception handling example.""" while True: # attempt to convert and divide values try: number1 = int(input('Enter numerator: ')) number2 = int(input('Enter denominator: ')) result = number1 / number2 except ValueError: # tried to convert non-numeric valu...
"""Simple exception handling example.""" while True: try: number1 = int(input('Enter numerator: ')) number2 = int(input('Enter denominator: ')) result = number1 / number2 except ValueError: print('You must enter two integers\n') except ZeroDivisionError: print('Attemp...
try: with open('../../.password/google-maps/api', 'r') as fp: key = fp.readlines() key = ''.join(key) except: # Insert your API key here key = 'AIzaSyDxydKN7Yt54JNmVw9opg9EcibCghjetgw'
try: with open('../../.password/google-maps/api', 'r') as fp: key = fp.readlines() key = ''.join(key) except: key = 'AIzaSyDxydKN7Yt54JNmVw9opg9EcibCghjetgw'
#SOLUTION FOR P20 '''P20 (*) Remove the K'th element from a list. Example: * (remove-at '(a b c d) 2) (A C D)''' my_list = ['a','b','c','d','e'] pos= int(input('Element to remove = ')) if pos <= len(my_list): #CHECK IF INPUT IS IN RANGE my_list.pop(pos-1) #REMOVE THE ELEMENT AT GIVEN INDE...
"""P20 (*) Remove the K'th element from a list. Example: * (remove-at '(a b c d) 2) (A C D)""" my_list = ['a', 'b', 'c', 'd', 'e'] pos = int(input('Element to remove = ')) if pos <= len(my_list): my_list.pop(pos - 1) print(my_list) else: print('Invalid input ')
class PairSet(object): __slots__ = '_data', def __init__(self): self._data = set() def __contains__(self, item): return item in self._data def has(self, a, b): return (a, b) in self._data def add(self, a, b): self._data.add((a, b)) self._data.add((b, a)) ...
class Pairset(object): __slots__ = ('_data',) def __init__(self): self._data = set() def __contains__(self, item): return item in self._data def has(self, a, b): return (a, b) in self._data def add(self, a, b): self._data.add((a, b)) self._data.add((b, a))...
class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def count_unival_subtrees(self, root: TreeNode) -> int: self.count = 0 self.is_unival(root) return self.count def is_unival(self, root: TreeNode) -> bool...
class Treenode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def count_unival_subtrees(self, root: TreeNode) -> int: self.count = 0 self.is_unival(root) return self.count def is_unival(self, root: TreeNode) -> bool...
class Node: def __init__(self, data): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None def push(self, new_data): new_node = Node(new_data) new_node.next = self.head self.head = new_node def getNth(self, ll...
class Node: def __init__(self, data): self.data = data self.next = None class Linkedlist: def __init__(self): self.head = None def push(self, new_data): new_node = node(new_data) new_node.next = self.head self.head = new_node def get_nth(self, llist, ...
# Configuration file for the Sphinx documentation builder. # # This file only contains a selection of the most common options. For a full # list see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html # -- Path setup -------------------------------------------------------------- # If ex...
project = 'elasticsearch-objects-operator' copyright = '2020, 90poe & elasticsearch-objects-operator development tean' author = 'elasticsearch-objects-operator development team' extensions = ['recommonmark', 'sphinx_markdown_tables'] templates_path = ['_templates'] exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'...
def draw_line(tick_length, tick_label=""): line = "-" * tick_length if tick_label: line += " " + tick_label print(line) def draw_interval(center_length): if center_length > 0: draw_interval(center_length - 1) draw_line(center_length) draw_interval(center_length - 1) d...
def draw_line(tick_length, tick_label=''): line = '-' * tick_length if tick_label: line += ' ' + tick_label print(line) def draw_interval(center_length): if center_length > 0: draw_interval(center_length - 1) draw_line(center_length) draw_interval(center_length - 1) def...
class TrainConfig(typing.NamedTuple): T: int train_size: int batch_size: int loss_func: typing.Callable class TrainData(typing.NamedTuple): feats: np.ndarray targs: np.ndarray DaRnnNet = collections.namedtuple("DaRnnNet", ["encoder", "decoder", "enc_opt", "dec_opt"])
class Trainconfig(typing.NamedTuple): t: int train_size: int batch_size: int loss_func: typing.Callable class Traindata(typing.NamedTuple): feats: np.ndarray targs: np.ndarray da_rnn_net = collections.namedtuple('DaRnnNet', ['encoder', 'decoder', 'enc_opt', 'dec_opt'])
class SqsWorkerBaseException(Exception): """ All worker exceptions should derived from this base exception """ class WorkerAbortSilently(SqsWorkerBaseException): """ Called when the worker finds a condition that requires to abort the task, but without reporting as an actual code error ""...
class Sqsworkerbaseexception(Exception): """ All worker exceptions should derived from this base exception """ class Workerabortsilently(SqsWorkerBaseException): """ Called when the worker finds a condition that requires to abort the task, but without reporting as an actual code error """ ...
__author__ = 'matti' class Config(object): DEBUG = False TESTING = False SQLALCHEMY_DATABASE_URI = 'postgresql://postgres:testipassu@localhost/gachimuchio' class DebugConfig(Config): DEBUG = True
__author__ = 'matti' class Config(object): debug = False testing = False sqlalchemy_database_uri = 'postgresql://postgres:testipassu@localhost/gachimuchio' class Debugconfig(Config): debug = True
phrase = "Awana Academy" print("Awana\nAcademy") print("Awana\"Academy") print("Awana\Academy") print(phrase + " is cool") print(phrase.capitalize()) print(phrase.lower()) print(phrase.upper()) print(phrase.isupper()) print(phrase.upper().isupper()) print(len(phrase)) print(phrase[0]) print(phrase.index("A"...
phrase = 'Awana Academy' print('Awana\nAcademy') print('Awana"Academy') print('Awana\\Academy') print(phrase + ' is cool') print(phrase.capitalize()) print(phrase.lower()) print(phrase.upper()) print(phrase.isupper()) print(phrase.upper().isupper()) print(len(phrase)) print(phrase[0]) print(phrase.index('A')) print(phr...
#!/usr/bin/env python3 with open('AUTHORS', 'r') as authors_file: authors = list(sorted([x.strip() for x in authors_file])) with open('Qiskit.bib', 'w') as fd: fd.write("@misc{ Qiskit,\n") fd.write(' author = {%s},\n' % ' and '.join(authors)) fd.write(' title = {Qiskit: the Quantum Informa...
with open('AUTHORS', 'r') as authors_file: authors = list(sorted([x.strip() for x in authors_file])) with open('Qiskit.bib', 'w') as fd: fd.write('@misc{ Qiskit,\n') fd.write(' author = {%s},\n' % ' and '.join(authors)) fd.write(' title = {Qiskit: the Quantum Information Science Kit},\n') ...
# Copyright 2019, Oath Inc. # Licensed under the terms of the Apache 2.0 license. See the LICENSE file in the project root for terms """ Screwdrivercd wrappers and utilities to perform code validation """ __all__ = ['validate_dependencies', 'validate_package_quality', 'validate_style', 'validate_type', 'validate_unitt...
""" Screwdrivercd wrappers and utilities to perform code validation """ __all__ = ['validate_dependencies', 'validate_package_quality', 'validate_style', 'validate_type', 'validate_unittest']
#while loop temp = 0 while(temp < 20): temp+=1 if(temp>10): print(temp,"> 10") print(temp) # for loops colors = ['yellow','white','blue','magenta','red'] for color in colors: print(color) print(range(10)) for index in range(10): print(index)
temp = 0 while temp < 20: temp += 1 if temp > 10: print(temp, '> 10') print(temp) colors = ['yellow', 'white', 'blue', 'magenta', 'red'] for color in colors: print(color) print(range(10)) for index in range(10): print(index)
# alias to Bazel module `toolchains/cc` load("@rules_nixpkgs_cc//:foreign_cc.bzl", _nixpkgs_foreign_cc_configure = "nixpkgs_foreign_cc_configure") nixpkgs_foreign_cc_configure = _nixpkgs_foreign_cc_configure
load('@rules_nixpkgs_cc//:foreign_cc.bzl', _nixpkgs_foreign_cc_configure='nixpkgs_foreign_cc_configure') nixpkgs_foreign_cc_configure = _nixpkgs_foreign_cc_configure
def get_just_smaller(arr): just_smaller_array = [-1] * len(arr) stack = [] for i in range(len(arr) - 1, -1, -1): elem = arr[i] while len(stack) > 0 and elem < arr[stack[-1]]: index = stack.pop() just_smaller_array[index] = i stack.append(i) return just_s...
def get_just_smaller(arr): just_smaller_array = [-1] * len(arr) stack = [] for i in range(len(arr) - 1, -1, -1): elem = arr[i] while len(stack) > 0 and elem < arr[stack[-1]]: index = stack.pop() just_smaller_array[index] = i stack.append(i) return just_sma...
""" CONTAINER WITH MOST WATER Given n non-negative integers a1, a2, ..., an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of the line i is at (i, ai) and (i, 0). Find two lines, which, together with the x-axis forms a container, such that the container c...
""" CONTAINER WITH MOST WATER Given n non-negative integers a1, a2, ..., an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of the line i is at (i, ai) and (i, 0). Find two lines, which, together with the x-axis forms a container, such that the container c...
class CredentialsNotFound(Exception): """Credential files not found""" class MultipleFilesError(Exception): """More than one file matching the name given""" class NotFoundError(Exception): """Item not Found""" class FileExists(Exception): """File already exists""" class FolderExists(Exception): ...
class Credentialsnotfound(Exception): """Credential files not found""" class Multiplefileserror(Exception): """More than one file matching the name given""" class Notfounderror(Exception): """Item not Found""" class Fileexists(Exception): """File already exists""" class Folderexists(Exception): ...
class Empty(Exception): pass class ArrayStack: def __init__(self): self._data = [] def __len__(self): return len(self._data) def is_empty(self): return len(self._data) == 0 def push(self, e): self._data.append(e) def top(self): if self.is_empty()...
class Empty(Exception): pass class Arraystack: def __init__(self): self._data = [] def __len__(self): return len(self._data) def is_empty(self): return len(self._data) == 0 def push(self, e): self._data.append(e) def top(self): if self.is_empty(): ...
class WorklogError(ValueError): pass class CommandError(WorklogError): pass class GitError(WorklogError): pass
class Worklogerror(ValueError): pass class Commanderror(WorklogError): pass class Giterror(WorklogError): pass
# https://www.freecodecamp.org/learn/scientific-computing-with-python/scientific-computing-with-python-projects/time-calculator # https://replit.com/@harmonify/time-calculator#time_calculator.py def add_time(base: str, addon: str, dow: str = "") -> str: DAYS_OF_WEEK = ("Monday", "Tuesday", "Wednesday", ...
def add_time(base: str, addon: str, dow: str='') -> str: days_of_week = ('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday') base_arr = base.split() (base_hour, base_minute) = map(int, base_arr[0].split(':')) meridiem = base_arr[1] (addon_hour, addon_minute) = map(int, addo...
# 3.6 Excel Spreadsheet - Column Number to Column Name def excel_column_number_to_name(column_number): output = '' index = column_number - 1 while index >= 0: character = chr((index % 26) + ord('A')) output = output + character index = (index / 26) - 1 return output[::-1]
def excel_column_number_to_name(column_number): output = '' index = column_number - 1 while index >= 0: character = chr(index % 26 + ord('A')) output = output + character index = index / 26 - 1 return output[::-1]
class collision(): def rectangle(x, y, target_x, target_y, width=32, height=32, target_width=32, target_height=32): # Assuming width/height is *dangerous* since this library might give false-positives. if x >= target_x and (x + width) <= (target_x + target_width): if y >= target_y an...
class Collision: def rectangle(x, y, target_x, target_y, width=32, height=32, target_width=32, target_height=32): if x >= target_x and x + width <= target_x + target_width: if y >= target_y and y + height <= target_y + target_height: return True return False
""" Copyright (c) 2014, Anders S. Christensen, All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the ...
""" Copyright (c) 2014, Anders S. Christensen, All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the ...
# THIS FILE IS GENERATED FROM pytsrepr SETUP.PY short_version = '0.0.1' version = '0.0.1' full_version = '0.0.1.dev0+Unknown' git_revision = 'Unknown' release = False if not release: version = full_version
short_version = '0.0.1' version = '0.0.1' full_version = '0.0.1.dev0+Unknown' git_revision = 'Unknown' release = False if not release: version = full_version
#!/usr/bin/python class Employee: empCount = 0 def __init__(self, name, salary, age): self.name = name self.salary = salary self.age = age Employee.empCount += 1 def displayCount(self): print ("Total Employee %d" % Employee.empCount) def displayEmployee(self): print...
class Employee: emp_count = 0 def __init__(self, name, salary, age): self.name = name self.salary = salary self.age = age Employee.empCount += 1 def display_count(self): print('Total Employee %d' % Employee.empCount) def display_employee(self): print('N...
class Solution(object): def maxDistance(self, grid): """ :type grid: List[List[int]] :rtype: int """ N, M = len(grid), len(grid[0]) if grid else 0 def around(r,c, val): """return valid cells around (r, c) whose values are equal to val""" for (r...
class Solution(object): def max_distance(self, grid): """ :type grid: List[List[int]] :rtype: int """ (n, m) = (len(grid), len(grid[0]) if grid else 0) def around(r, c, val): """return valid cells around (r, c) whose values are equal to val""" ...
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Section 4: Region Borders """ def B23p_T(T): """function B23p_T = B23p_T(T) Section 4.1 Boundary between region 2 and 3. Release on the IAPWS Industrial formulation 1997 for the Thermodynamic Properties of Water and Steam 1997 Section 4 Auxiliary Equati...
""" Section 4: Region Borders """ def b23p_t(T): """function B23p_T = B23p_T(T) Section 4.1 Boundary between region 2 and 3. Release on the IAPWS Industrial formulation 1997 for the Thermodynamic Properties of Water and Steam 1997 Section 4 Auxiliary Equation for the Boundary between Regions 2 and 3 ...
class minHeap: harr=[] def parent(self,i): return (i-1)/2 def left(self,i): return ((2*i)+1) def right(self,i): return ((2*i)*2) def getMin(self): return self.harr[0] def replaceMax(self,x): self.harr[0]=x minHeapify(0) def __init__(self,arr,...
class Minheap: harr = [] def parent(self, i): return (i - 1) / 2 def left(self, i): return 2 * i + 1 def right(self, i): return 2 * i * 2 def get_min(self): return self.harr[0] def replace_max(self, x): self.harr[0] = x min_heapify(0) def...
class Vet: animals = [] space = 5 def __init__(self, name): self.name = name self.animals = [] def register_animal(self, animal): if self.space <= len(self.animals): return f"Not enough space" self.animals.append(animal) Vet.animals.append(animal) ...
class Vet: animals = [] space = 5 def __init__(self, name): self.name = name self.animals = [] def register_animal(self, animal): if self.space <= len(self.animals): return f'Not enough space' self.animals.append(animal) Vet.animals.append(animal) ...
def solution(A): return 1 if __name__ == '__main__': print ('Start tests..') assert solution([1, 5, 2, 1, 4, 0]) == 1 print ('passed!')
def solution(A): return 1 if __name__ == '__main__': print('Start tests..') assert solution([1, 5, 2, 1, 4, 0]) == 1 print('passed!')
def generate_key_table(key): table=[] all_chars=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'] for char in key: if char not in table: if char=='i': if 'j' not in table and 'i' not in table: table.append(char) elif char=='j': if 'i' not i...
def generate_key_table(key): table = [] all_chars = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] for char in key: if char not in table: if char == 'i': if 'j' not in table and 'i' not in...
# https://www.hackerrank.com/challenges/30-sorting/problem # Inputs standard_input = """3 3 2 1""" num = int(input()) # 3 l = [int(s) for s in input().split()] # 3 2 1 swap_count = 0 for i in range(num): for j in range(num - i - 1): if l[j] > l[j + 1]: tmp = l[j] l[j] = l[j + 1...
standard_input = '3\n3 2 1' num = int(input()) l = [int(s) for s in input().split()] swap_count = 0 for i in range(num): for j in range(num - i - 1): if l[j] > l[j + 1]: tmp = l[j] l[j] = l[j + 1] l[j + 1] = tmp swap_count += 1 print(f'Array is sorted in {swap...
# -*- coding: utf-8 -*- def import_oauth_class(m): m = m.split('.') c = m.pop(-1) module = __import__('.'.join(m), fromlist=[c]) return getattr(module, c)
def import_oauth_class(m): m = m.split('.') c = m.pop(-1) module = __import__('.'.join(m), fromlist=[c]) return getattr(module, c)
"""GrayScale package initialization module. The GrayScale package is designed to work with shades of gray, namely, it checks whether a color is a shade of gray and how many values need to be added to its components to make it so. The shades are taken from the RGB palette, and the color codes are written in a 16-digit ...
"""GrayScale package initialization module. The GrayScale package is designed to work with shades of gray, namely, it checks whether a color is a shade of gray and how many values need to be added to its components to make it so. The shades are taken from the RGB palette, and the color codes are written in a 16-digit ...
# coding=utf-8 """Fixtures for testing gmusicapi_wrapper.""" TEST_SONGS_1 = [ {'artist': 'Muse', 'album': 'Black Holes and Revelations', 'year': 2006, 'track_number': 1, 'title': 'Take a Bow'}, {'artist': 'Muse', 'album': 'Black Holes and Revelations', 'year': 2006, 'track_number': 2, 'title': 'Starlight'} ] TEST_...
"""Fixtures for testing gmusicapi_wrapper.""" test_songs_1 = [{'artist': 'Muse', 'album': 'Black Holes and Revelations', 'year': 2006, 'track_number': 1, 'title': 'Take a Bow'}, {'artist': 'Muse', 'album': 'Black Holes and Revelations', 'year': 2006, 'track_number': 2, 'title': 'Starlight'}] test_songs_2 = [{'artist': ...
def init(): global white global black global red global green global fill global blue global yellow white = [255, 255, 255] black = [0, 0, 0] red = [204, 0, 0] green = [0, 153, 0] fill = [48, 48, 48] blue = [15, 176, 255] yellow = [255, 241, 27]
def init(): global white global black global red global green global fill global blue global yellow white = [255, 255, 255] black = [0, 0, 0] red = [204, 0, 0] green = [0, 153, 0] fill = [48, 48, 48] blue = [15, 176, 255] yellow = [255, 241, 27]
""" Source: Stack Abuse Exponential search depends on binary search to perform the final comparison of values. The algorithm works by: - Determining the range where the element we're looking for is likely to be - Using binary search for the range to find the exact index of the item """ def ExponentialSearch(lys, val)...
""" Source: Stack Abuse Exponential search depends on binary search to perform the final comparison of values. The algorithm works by: - Determining the range where the element we're looking for is likely to be - Using binary search for the range to find the exact index of the item """ def exponential_search(lys, val...
""" Binary Tree Cameras You are given the root of a binary tree. We install cameras on the tree nodes where each camera at a node can monitor its parent, itself, and its immediate children. Return the minimum number of cameras needed to monitor all nodes of the tree. Example 1: Input: root = [0,0,null,0,0] Outp...
""" Binary Tree Cameras You are given the root of a binary tree. We install cameras on the tree nodes where each camera at a node can monitor its parent, itself, and its immediate children. Return the minimum number of cameras needed to monitor all nodes of the tree. Example 1: Input: root = [0,0,null,0,0] Outp...
class Main: def __init__(self): self.li = [] for i in range(0, 2): self.li.append(int(input())) self.salary = float(input()) def totalSalary(self): return self.li[1] * self.salary def output(self): print("NUMBER = {num}".format(num=self.li[0])) p...
class Main: def __init__(self): self.li = [] for i in range(0, 2): self.li.append(int(input())) self.salary = float(input()) def total_salary(self): return self.li[1] * self.salary def output(self): print('NUMBER = {num}'.format(num=self.li[0])) ...
# see https://www.codewars.com/kata/556196a6091a7e7f58000018/solutions/python def largest_pair_sum(numbers): return sorted(numbers)[-1] + sorted(numbers)[-2] print(largest_pair_sum([10,14,2,23,19]) == 42) print(largest_pair_sum([-100,-29,-24,-19,19]) == 0) print(largest_pair_sum([1,2,3,4,6,-1,2]) == 10) print(l...
def largest_pair_sum(numbers): return sorted(numbers)[-1] + sorted(numbers)[-2] print(largest_pair_sum([10, 14, 2, 23, 19]) == 42) print(largest_pair_sum([-100, -29, -24, -19, 19]) == 0) print(largest_pair_sum([1, 2, 3, 4, 6, -1, 2]) == 10) print(largest_pair_sum([-10, -8, -16, -18, -19]) == -18)
ckpt_path = '../ckpts' data_path = '../../data' graph_path = '../graphs' num_trains = { 'mnist': 60000, 'cifar': 50000, 'fmnist': 60000 } num_tests = { 'mnist': 10000, 'cifar': 10000, 'fmnist': 10000 } input_sizes = { 'mnist': 28*28, 'cifar': 3*32*32, 'fmnist': 28*28 } output_siz...
ckpt_path = '../ckpts' data_path = '../../data' graph_path = '../graphs' num_trains = {'mnist': 60000, 'cifar': 50000, 'fmnist': 60000} num_tests = {'mnist': 10000, 'cifar': 10000, 'fmnist': 10000} input_sizes = {'mnist': 28 * 28, 'cifar': 3 * 32 * 32, 'fmnist': 28 * 28} output_sizes = {'mnist': 10, 'cifar': 10, 'fmnis...
"""Python3 Code to solve problem 1254: Number of closed islands. https://leetcode.com/problems/number-of-closed-islands/ """ def close_island(grid): if not grid or len(grid) == 0: return 0 height, width = len(grid), len(grid[0]) count = 0 for x in range(height): for y in range(wi...
"""Python3 Code to solve problem 1254: Number of closed islands. https://leetcode.com/problems/number-of-closed-islands/ """ def close_island(grid): if not grid or len(grid) == 0: return 0 (height, width) = (len(grid), len(grid[0])) count = 0 for x in range(height): for y in range(wi...
#Y = Species("Y",U_Y) class Species: def __init__(self, name, U): self.name = name #Y.name = "Y" self.U = U #Y.U = U_Y self.behaviour = None def get_U(self): return self.U #Y.get_U returns U_Y #Y.set_U(U) def set_U(self, U): self.U =...
class Species: def __init__(self, name, U): self.name = name self.U = U self.behaviour = None def get_u(self): return self.U def set_u(self, U): self.U = U def get_name(self): return self.name def set_behaviour(self, behaviour): self.behav...
display = [[False for i in range(50)] for j in range(6)] commands = [] while True: try: line = input() except: break if not line: break commands.append(line) for command in commands: if command[:4] == 'rect': i, j = command.find(' '), command.find('x') a = command[i+1 : j] ...
display = [[False for i in range(50)] for j in range(6)] commands = [] while True: try: line = input() except: break if not line: break commands.append(line) for command in commands: if command[:4] == 'rect': (i, j) = (command.find(' '), command.find('x')) a =...
''' https://www.hackerrank.com/challenges/python-mutations/problem ''' def mutate_string(s, p, ch): if p < 0 or p >= len(s): return s return s[:p] + ch + s[p+1:] ''' Reverse String -------------- Problem: Given a string, reverse the characters order so that the last at first, ...
""" https://www.hackerrank.com/challenges/python-mutations/problem """ def mutate_string(s, p, ch): if p < 0 or p >= len(s): return s return s[:p] + ch + s[p + 1:] "\n Reverse String\n --------------\n\n Problem:\n Given a string, reverse the characters order so that the last at fir...
class ReskinPacket: def __init__(self): self.type = "RESKIN" self.skinID = 0 def write(self, writer): writer.writeInt32(self.skinID) def read(self, reader): self.skinID = reader.readerInt32()
class Reskinpacket: def __init__(self): self.type = 'RESKIN' self.skinID = 0 def write(self, writer): writer.writeInt32(self.skinID) def read(self, reader): self.skinID = reader.readerInt32()
class Stack: # Construct an empty Stack object. def __init__(self): self._a = [] # Items # Return True if self is empty, and False otherwise. def is_empty(self): return len(self._a) == 0 # Push object item onto the top of self. def push(self, item): self...
class Stack: def __init__(self): self._a = [] def is_empty(self): return len(self._a) == 0 def push(self, item): self._a += [item] def pop(self): return self._a.pop()
""" A library containing utilities for additive manufacturing. """ def dimension(dim: float, tol: int = 0, step: float = 0.4) -> float: """ Given a dimension, this function will round down to the next multiple of the dimension. An additional parameter `tol` can be specified to add `tol` additional ste...
""" A library containing utilities for additive manufacturing. """ def dimension(dim: float, tol: int=0, step: float=0.4) -> float: """ Given a dimension, this function will round down to the next multiple of the dimension. An additional parameter `tol` can be specified to add `tol` additional steps to...
def rectangle_area(w, h): return w * h width = int(input()) height = int(input()) print(rectangle_area(width, height))
def rectangle_area(w, h): return w * h width = int(input()) height = int(input()) print(rectangle_area(width, height))
class IUserManager: def logIn(self, userId, password): raise NotImplementedError def SignUp(self, userId, password): raise NotImplementedError
class Iusermanager: def log_in(self, userId, password): raise NotImplementedError def sign_up(self, userId, password): raise NotImplementedError
display_name = "Myriad Worlds" library_name = "myriad" version = "0.5" author = "Duncan McGreggor, Paul McGuire" author_email = "oubiwann@twistedmatrix.com" license = "MIT" url = "http://github.com/oubiwann/myriad-worlds" description = "Myriad Worlds Game Server" long_description = ("An experiment in generating worlds,...
display_name = 'Myriad Worlds' library_name = 'myriad' version = '0.5' author = 'Duncan McGreggor, Paul McGuire' author_email = 'oubiwann@twistedmatrix.com' license = 'MIT' url = 'http://github.com/oubiwann/myriad-worlds' description = 'Myriad Worlds Game Server' long_description = 'An experiment in generating worlds, ...
def setup_routes(app, handler): app.router.add_get( '/browsers/{version}', handler.browsers, name='browsers', )
def setup_routes(app, handler): app.router.add_get('/browsers/{version}', handler.browsers, name='browsers')
# McrpType.py def typedproperty(name, expected_type): private_name = '_'+name @property def prop(self): return getattr(self, private_name) @prop.setter def prop(self, value): if not isinstance(value, expected_type): raise TypeError('Expected type {}'.format(exp...
def typedproperty(name, expected_type): private_name = '_' + name @property def prop(self): return getattr(self, private_name) @prop.setter def prop(self, value): if not isinstance(value, expected_type): raise type_error('Expected type {}'.format(expected_type)) ...
# # PySNMP MIB module TVD-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/TVD-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 21:20: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 2019, 09:23:15)...
(octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (single_value_constraint, value_size_constraint, value_range_constraint, constraints_union, constraints_intersection) ...
''' * Colors for terminal ''' class COLORS: # Regular colors Black = "\033[0;30m" Red = "\033[0;31m" Green = "\033[0;32m" Yellow = "\033[0;33m" Blue = "\033[0;34m" Purple = "\033[0;35m" Cyan = "\033[0;36m" White = "\033[0;37m" ...
""" * Colors for terminal """ class Colors: black = '\x1b[0;30m' red = '\x1b[0;31m' green = '\x1b[0;32m' yellow = '\x1b[0;33m' blue = '\x1b[0;34m' purple = '\x1b[0;35m' cyan = '\x1b[0;36m' white = '\x1b[0;37m' on__black = '\x1b[40m' on__red = '\x1b[41m' on__green = '\x1b...
# me - this DAT # par - the Par object that has changed # val - the current value # prev - the previous value # # Make sure the corresponding toggle is enabled in the Parameter Execute DAT. def onValueChange(par, prev): # use par.eval() to get current value parent.save.Par_functions(par) return # Called at end of...
def on_value_change(par, prev): parent.save.Par_functions(par) return def on_values_changed(changes): for c in changes: par = c.par prev = c.prev return def on_pulse(par): parent.save.Par_functions(par) return def on_expression_change(par, val, prev): return def on_export...
# Formatting configuration for locale sh_YU languages={'el': u'Gr\u010dki', 'en': 'Engleski', 'co': 'Korzikanski', 'af': 'Afrikanerski', 'sw': 'Svahili', 'ca': 'Katalonski', 'it': 'Italijanski', 'cs': u'\u010ce\u0161ki', 'ar': 'Arapski', 'mk': 'Makedonski', 'ga': 'Irski', 'eu': 'Baskijski', 'et': 'Estonski', 'zh': 'Ki...
languages = {'el': u'Grčki', 'en': 'Engleski', 'co': 'Korzikanski', 'af': 'Afrikanerski', 'sw': 'Svahili', 'ca': 'Katalonski', 'it': 'Italijanski', 'cs': u'Češki', 'ar': 'Arapski', 'mk': 'Makedonski', 'ga': 'Irski', 'eu': 'Baskijski', 'et': 'Estonski', 'zh': 'Kineski', 'id': 'Indonezijski', 'es': u'Španski', 'ru': 'Rus...
print(f"{'='*12} BRANT'STORE {'='*12}") price = float(input('How much the product costs? $')) print('''Choose the form of payment: [1] Cash/check [2] Credit Card''') payment = int(input('What is the payment method? ')) if payment == 1: price -= price * 0.1 print(f'The price will be ${price:.2f}') elif payment ...
print(f"{'=' * 12} BRANT'STORE {'=' * 12}") price = float(input('How much the product costs? $')) print('Choose the form of payment:\n[1] Cash/check\n[2] Credit Card') payment = int(input('What is the payment method? ')) if payment == 1: price -= price * 0.1 print(f'The price will be ${price:.2f}') elif payment...
class Solution: def replaceSpaces(self, S: str, length: int) -> str: cnt = 0 S = list(S) cnt += sum((1 for c in S[:length] if c == ' ')) newLen = length + 2 * cnt #print(length, newLen) S = S[:newLen] for i in range(length - 1, -1, -1): if S[i] ==...
class Solution: def replace_spaces(self, S: str, length: int) -> str: cnt = 0 s = list(S) cnt += sum((1 for c in S[:length] if c == ' ')) new_len = length + 2 * cnt s = S[:newLen] for i in range(length - 1, -1, -1): if S[i] == ' ': S[newLe...
# DFLOW LIBRARY: # dflow matrices module # with zeros and ones # functions def zeros(rows, columns): return [[0]*columns]*rows def ones(rows, columns): return [[1]*columns]*rows
def zeros(rows, columns): return [[0] * columns] * rows def ones(rows, columns): return [[1] * columns] * rows
def merge(L, R, arr): nl = len(L) nr = len(R) i, j, k = 0, 0, 0 while i < nl and j < nr: if L[i] <= R[j]: arr[k] = L[i] k += 1 i += 1 else: arr[k] = R[j] k += 1 j += 1 def exhaust(index, maxIndex, arrIndex, ar...
def merge(L, R, arr): nl = len(L) nr = len(R) (i, j, k) = (0, 0, 0) while i < nl and j < nr: if L[i] <= R[j]: arr[k] = L[i] k += 1 i += 1 else: arr[k] = R[j] k += 1 j += 1 def exhaust(index, maxIndex, arrIndex, ...
""" Created on Wed Jul 22 22:27:09 2020 @author: wallissoncarvalho This file is based on https://github.com/mullenkamp/nasadap """ mission_product_dict = { 'gpm': { 'base_url': 'https://gpm1.gesdisc.eosdis.nasa.gov:443', 'process_level': 'GPM_L3', 'version': 6, 'products': { ...
""" Created on Wed Jul 22 22:27:09 2020 @author: wallissoncarvalho This file is based on https://github.com/mullenkamp/nasadap """ mission_product_dict = {'gpm': {'base_url': 'https://gpm1.gesdisc.eosdis.nasa.gov:443', 'process_level': 'GPM_L3', 'version': 6, 'products': {'3IMERGHHE': '{mission}_{product}.{version:02}...
# AUTOGENERATED BY NBDEV! DO NOT EDIT! __all__ = ["index", "modules", "custom_doc_links", "git_url"] index = {"article_holder": "00_loadarticles.ipynb", "CoverageTrendsLoader": "00_loadarticles.ipynb", "dailysourcepermalinksLoader": "00_loadarticles.ipynb", "describer": "01_descriptive_anal...
__all__ = ['index', 'modules', 'custom_doc_links', 'git_url'] index = {'article_holder': '00_loadarticles.ipynb', 'CoverageTrendsLoader': '00_loadarticles.ipynb', 'dailysourcepermalinksLoader': '00_loadarticles.ipynb', 'describer': '01_descriptive_analysis.ipynb', 'predicter': '02_predictive_analysis.ipynb', 'get_mse':...
class ShellException(Exception): def __init__(self, msg): self._msg = msg def __str__(self): return repr(self._msg) class ParseException(Exception): def __init__(self, msg): self._msg = msg def __str__(self): return repr(self._msg) class TreeException(Exception): ...
class Shellexception(Exception): def __init__(self, msg): self._msg = msg def __str__(self): return repr(self._msg) class Parseexception(Exception): def __init__(self, msg): self._msg = msg def __str__(self): return repr(self._msg) class Treeexception(Exception): ...
#!/usr/bin/env python # -*- coding : utf-8 -*- message = "hello python" def say(): print(message)
message = 'hello python' def say(): print(message)
''' Created on 18.05.2018 @author: yvo ''' class DataReader(object): ''' Generic main class of all data reader objects used for the GLAMOS data interface. An inherited data reader object can be specialised for file, database or web-services ... As main object common to all inherited objects ...
""" Created on 18.05.2018 @author: yvo """ class Datareader(object): """ Generic main class of all data reader objects used for the GLAMOS data interface. An inherited data reader object can be specialised for file, database or web-services ... As main object common to all inherited objects ...
class Solution(object): def isValidSerialization(self, preorder): """ :type preorder: str :rtype: bool """ count = 1 for num in preorder.split(','): if not count: return False elif num != '#': count += 1 ...
class Solution(object): def is_valid_serialization(self, preorder): """ :type preorder: str :rtype: bool """ count = 1 for num in preorder.split(','): if not count: return False elif num != '#': count += 1 ...
def addBorder(picture): pictureWithBorder = [] pictureWithBorder.append('*'*(len(picture[0])+2)) for i in range(len(picture)): pictureWithBorder.append('*' + picture[i] + '*') pictureWithBorder.append('*'*(len(picture[0])+2)) return pictureWithBorder
def add_border(picture): picture_with_border = [] pictureWithBorder.append('*' * (len(picture[0]) + 2)) for i in range(len(picture)): pictureWithBorder.append('*' + picture[i] + '*') pictureWithBorder.append('*' * (len(picture[0]) + 2)) return pictureWithBorder
x = 5 for i in range(1,10, 2): for j in reversed(range(x, x+3)): print("I={} J={}".format(i,j)) x = x + 2
x = 5 for i in range(1, 10, 2): for j in reversed(range(x, x + 3)): print('I={} J={}'.format(i, j)) x = x + 2
key = 5 message = open("encrypted.txt", "r") encrypted = message.read() message.close() print(encrypted) print("DECRYPTED: ", " ") decrypt = [] for i in range(0, len(encrypted)): decrypt.append(ord(encrypted[i]) - key) #decrypt[i] = decrypt[i] - key for i in range(0, len(decrypt)): decrypt[i] = chr(decry...
key = 5 message = open('encrypted.txt', 'r') encrypted = message.read() message.close() print(encrypted) print('DECRYPTED: ', ' ') decrypt = [] for i in range(0, len(encrypted)): decrypt.append(ord(encrypted[i]) - key) for i in range(0, len(decrypt)): decrypt[i] = chr(decrypt[i]) decrypted = open('decrypted.tx...
#from enum import Enum # Enum only in Python >= 3.4 #class Operator(Enum): class Operator(object): And = 0 Equal = 1 GreaterEqual = 2 Greater = 3 LessEqual = 4 Less = 5 NotEqual = 6 Or = 7 Between = 8 Contains = 9 EndsWith = 10 Is = 11 IsNot = 12 Like = 13 Ma...
class Operator(object): and = 0 equal = 1 greater_equal = 2 greater = 3 less_equal = 4 less = 5 not_equal = 6 or = 7 between = 8 contains = 9 ends_with = 10 is = 11 is_not = 12 like = 13 matches = 14 starts_with = 15 add = 16 sub = 17 mul = 18 ...
""" Offer a significant performance boost; it is most effective in situations where the cost of initializing a class instance is high, the rate of instantiation of a class is high, and the number of instantiations in use at any one time is low. """ class ReusablePool: """ Manage Reusable objects for use by Cl...
""" Offer a significant performance boost; it is most effective in situations where the cost of initializing a class instance is high, the rate of instantiation of a class is high, and the number of instantiations in use at any one time is low. """ class Reusablepool: """ Manage Reusable objects for use by Cli...
__author__ = "IceArrow256" __version__ = '4' def union(first, second): result = set() for i in first: result.add(i) for i in second: if i not in result: result.add(i) return result def intersection(first, second): result = set() for i in first: if i in sec...
__author__ = 'IceArrow256' __version__ = '4' def union(first, second): result = set() for i in first: result.add(i) for i in second: if i not in result: result.add(i) return result def intersection(first, second): result = set() for i in first: if i in secon...
__all__ = ["InvalidUnrestrictedGrammarFormatException"] class InvalidUnrestrictedGrammarFormatException(Exception): pass
__all__ = ['InvalidUnrestrictedGrammarFormatException'] class Invalidunrestrictedgrammarformatexception(Exception): pass
def greet(firstName='', middleName='', lastName=''): print('Hello, ' + lastName + ', ' + middleName + ' ' + firstName) greet('Michael', 'G', 'Bay') # supplying parameters in a specific sequence greet('Michael', 'G') # skipping lastName parameter greet() # skipping all parameters # specifying the custom sequen...
def greet(firstName='', middleName='', lastName=''): print('Hello, ' + lastName + ', ' + middleName + ' ' + firstName) greet('Michael', 'G', 'Bay') greet('Michael', 'G') greet() greet(middleName='J', lastName='Damodaran', firstName='Ramkumar')
# Maze in a 85x85 grid # Nodes: 1231 # Edges: 1280 adjList = [ [41, 1], [27, 0], [55, 3], [57, 4, 2], [87, 3], [22, 6], [59, 7, 5], [60, 6], [30, 9], [32, 8], [44, 11], [46, 10], [47, 13], [34, 12], [77, 15], [36, 14], [89, 17], [67, 18, 16], ...
adj_list = [[41, 1], [27, 0], [55, 3], [57, 4, 2], [87, 3], [22, 6], [59, 7, 5], [60, 6], [30, 9], [32, 8], [44, 11], [46, 10], [47, 13], [34, 12], [77, 15], [36, 14], [89, 17], [67, 18, 16], [40, 17], [28], [53, 21], [54, 20], [5], [33, 24], [43, 23], [49, 26], [50, 25], [1, 28], [19, 27], [61, 30], [8, 29], [63, 32],...
global N N = 4 def printSolution(board): for i in range(N): for j in range(N): print (board[i][j], end = " ") print() def isSafe(board, row, col): # Check this row on left side for i in range(col): if board[row][i] == 1: return False # Check upper diagonal on left side for i, j in zip(range(row, -1...
global N n = 4 def print_solution(board): for i in range(N): for j in range(N): print(board[i][j], end=' ') print() def is_safe(board, row, col): for i in range(col): if board[row][i] == 1: return False for (i, j) in zip(range(row, -1, -1), range(col, -1, -1...
""" Pointers do not exist in Python. If you want to know why i recommend reading this article: https://realpython.com/pointers-in-python/ """
""" Pointers do not exist in Python. If you want to know why i recommend reading this article: https://realpython.com/pointers-in-python/ """
marks = int(input("What is you marks in Math: ")) def show_grade(grade): print(f"You got: {grade}") if marks >= 80: show_grade("A+") elif marks >= 70: show_grade("A") elif marks >= 60: show_grade("A-") elif marks >= 50: show_grade("B") elif marks >= 40: show_grade("C") else: show_grade("...
marks = int(input('What is you marks in Math: ')) def show_grade(grade): print(f'You got: {grade}') if marks >= 80: show_grade('A+') elif marks >= 70: show_grade('A') elif marks >= 60: show_grade('A-') elif marks >= 50: show_grade('B') elif marks >= 40: show_grade('C') else: show_grade('F')...