content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
load("@wix_oss_infra//:import_external.bzl", import_external = "safe_wix_scala_maven_import_external") def dependencies(): import_external( name = "org_specs2_specs2_fp_2_12", artifact = "org.specs2:specs2-fp_2.12:4.8.3", artifact_sha256 = "777962ca58054a9ea86e294e025453ecf394c60084c28bd61...
load('@wix_oss_infra//:import_external.bzl', import_external='safe_wix_scala_maven_import_external') def dependencies(): import_external(name='org_specs2_specs2_fp_2_12', artifact='org.specs2:specs2-fp_2.12:4.8.3', artifact_sha256='777962ca58054a9ea86e294e025453ecf394c60084c28bd61956a00d16be31a7', srcjar_sha256='6...
a = int(input()) b = int(input()) c = int(input()) d = int(input()) if a == 0 and b == 0: print("INF") else: if (d - b * c / a) != 0 and (- b / a) == (- b // a): print(- b // a) else: print("NO")
a = int(input()) b = int(input()) c = int(input()) d = int(input()) if a == 0 and b == 0: print('INF') elif d - b * c / a != 0 and -b / a == -b // a: print(-b // a) else: print('NO')
# -*- coding: utf-8 -*- """ Created on Mon Dec 7 19:46:40 2020 @author: Intel """ def displayPathtoPrincess(n,grid): me_i=n//2 me_j=n//2 for i in range(n): if 'p' in grid[i]: pe_i=i for j in range(n): if 'p'==grid[i][j]: pe...
""" Created on Mon Dec 7 19:46:40 2020 @author: Intel """ def display_pathto_princess(n, grid): me_i = n // 2 me_j = n // 2 for i in range(n): if 'p' in grid[i]: pe_i = i for j in range(n): if 'p' == grid[i][j]: pe_j = j ...
# Copyright (C) 2020 Google Inc. # # This file has been licensed under Apache 2.0 license. Please see the LICENSE # file at the root of the repository. # Build rules for building ebooks. # This is the container CONTAINER = "filipfilmar/ebook-buildenv:1.1" # Use this for quick local runs. #CONTAINER = "ebook-builden...
container = 'filipfilmar/ebook-buildenv:1.1' ebook_info = provider(fields=['figures', 'markdowns']) def _script_cmd(script_path, dir_reference): return ' {script} --container={container} --dir-reference={dir_reference}'.format(script=script_path, container=CONTAINER, dir_reference=dir_referenc...
n = int(input()) coelho = rato = sapo = contador = 0 for i in range(0, n): q, t = input().split(' ') t = t.upper() q = int(q) if 1 <= q <= 15: contador += q if t == 'C': coelho += q elif t == 'R': rato += q elif t == 'S': sapo += q po...
n = int(input()) coelho = rato = sapo = contador = 0 for i in range(0, n): (q, t) = input().split(' ') t = t.upper() q = int(q) if 1 <= q <= 15: contador += q if t == 'C': coelho += q elif t == 'R': rato += q elif t == 'S': sapo += q po...
class APIError(Exception): """ raise APIError if receiving json message indicating failure. """ def __init__(self, error_code, error, request): self.error_code = error_code self.error = error self.request = request Exception.__init__(self, error) def __str__(self): ...
class Apierror(Exception): """ raise APIError if receiving json message indicating failure. """ def __init__(self, error_code, error, request): self.error_code = error_code self.error = error self.request = request Exception.__init__(self, error) def __str__(self): ...
def base_conv(n, input_base=10, output_base=10): """ Converts a number n from base input_base to base output_base. The following symbols are used to represent numbers: 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ n can be an int if input_base <= 10, and a string otherwise. ...
def base_conv(n, input_base=10, output_base=10): """ Converts a number n from base input_base to base output_base. The following symbols are used to represent numbers: 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ n can be an int if input_base <= 10, and a string otherwise. ...
#a2_t1b.py #This program is to convert Celsius to Kelvin def c_to_k(c): k = c + 273.15 #Formula to convert Celsius to Kelvin return k def f_to_c(f): fa = (f-32) * 5/9 #Formula to convert Fareheit to Celsius return fa c = 25.0 f = 100.0 k = c_to_k(c) fa = f_to_c(f) print("Celsius of " + str(c) + " is...
def c_to_k(c): k = c + 273.15 return k def f_to_c(f): fa = (f - 32) * 5 / 9 return fa c = 25.0 f = 100.0 k = c_to_k(c) fa = f_to_c(f) print('Celsius of ' + str(c) + ' is ' + str(k) + ' in Kelvin') print('Farenheit of ' + str(f) + ' is ' + str(fa) + ' in Celsius')
"""This module contains the GeneFlow LocalWorkflow class.""" class LocalWorkflow: """ A class that represents the Local Workflow objects. """ def __init__( self, job, config, parsed_job_work_uri ): """ Instantiate LocalWorkflow class....
"""This module contains the GeneFlow LocalWorkflow class.""" class Localworkflow: """ A class that represents the Local Workflow objects. """ def __init__(self, job, config, parsed_job_work_uri): """ Instantiate LocalWorkflow class. """ self._job = job self._con...
# -*- coding: utf-8 -*- def main(): s, t, u = map(str, input().split()) if len(s) == 5 and len(t) == 7 and len(u) == 5: print('valid') else: print('invalid') if __name__ == '__main__': main()
def main(): (s, t, u) = map(str, input().split()) if len(s) == 5 and len(t) == 7 and (len(u) == 5): print('valid') else: print('invalid') if __name__ == '__main__': main()
def buttonClick(button): JS(""" var doc = button.ownerDocument; if (doc != null) { var evt = doc.createEvent('MouseEvents'); evt.initMouseEvent('click', true, true, null, 0, 0, 0, 0, 0, false, false, false, false, 0, null); button.d...
def button_click(button): js("\n var doc = button.ownerDocument;\n if (doc != null) {\n var evt = doc.createEvent('MouseEvents');\n evt.initMouseEvent('click', true, true, null, 0, 0,\n 0, 0, 0, false, false, false, false, 0, null);\n but...
""" Demonstration of numbers in Python """ # Python has an integer type called int print("int") print("---") print(0) print(1) print(-3) print(70383028364830) print("") # Python has a real number type called float print("float") print("-----") print(0.0) print(7.35) print(-43.2) print("") # Limited precision print...
""" Demonstration of numbers in Python """ print('int') print('---') print(0) print(1) print(-3) print(70383028364830) print('') print('float') print('-----') print(0.0) print(7.35) print(-43.2) print('') print('Precision') print('---------') print(4.563728838323318) print(1.2345678901234567) print('') print('Scientifi...
# Natural Language Toolkit: Language Models # # Copyright (C) 2001-2008 University of Pennsylvania # Author: Steven Bird <sb@csse.unimelb.edu.au> # URL: <http://nltk.sf.net> # For license information, see LICENSE.TXT class ModelI(object): """ A processing interface for assigning a probability to the next word....
class Modeli(object): """ A processing interface for assigning a probability to the next word. """ def __init__(self): """Create a new language model.""" raise not_implemented_error() def train(self, text): """Train the model on the text.""" raise not_implemented_er...
def aaa(): # trick sphinx to build link in doc pass # retired ibmqx2_c_to_tars =\ { 0: [1, 2], 1: [2], 2: [], 3: [2, 4], 4: [2] } # 6 edges # retired ibmqx4_c_to_tars =\ { 0: [], 1: [0], 2: [0, 1, 4], 3: [2, 4], 4: [] } # 6 edges # retired ibmq16Rus_c_to_tars = \ { ...
def aaa(): pass ibmqx2_c_to_tars = {0: [1, 2], 1: [2], 2: [], 3: [2, 4], 4: [2]} ibmqx4_c_to_tars = {0: [], 1: [0], 2: [0, 1, 4], 3: [2, 4], 4: []} ibmq16_rus_c_to_tars = {0: [], 1: [0, 2], 2: [3], 3: [4, 14], 4: [], 5: [4], 6: [5, 7, 11], 7: [10], 8: [7], 9: [8, 10], 10: [], 11: [10], 12: [5, 11, 13], 13: [4, 14],...
class Donation_text: # Shown as a message across the top of the page on return from a donation # used in views.py:new_donation() thank_you = ( "Thank you for your donation. " "You may need to refresh this page to see the donation." ) confirmation_email_subject = ( 'Thank y...
class Donation_Text: thank_you = 'Thank you for your donation. You may need to refresh this page to see the donation.' confirmation_email_subject = 'Thank you for donating to the Triple Crown for Heart! ' confirmation_email_opening = 'Thank you for your donation of ' confirmation_email_closing = '.\n\nF...
class Yaratik(object): def move_left(self): print('Moving left...') def move_right(self): print('Moving left...') class Ejderha(Yaratik): def Ates_puskurtme(self): print('ates puskurtum!') class Zombie(Yaratik): def Isirmak(self): print('Isirdim simdi!') enemy =...
class Yaratik(object): def move_left(self): print('Moving left...') def move_right(self): print('Moving left...') class Ejderha(Yaratik): def ates_puskurtme(self): print('ates puskurtum!') class Zombie(Yaratik): def isirmak(self): print('Isirdim simdi!') enemy = yar...
class Solution: def nextGreatestLetter(self, letters: list, target: str) -> str: if target < letters[0] or target >= letters[-1]: return letters[0] left, right = 0, len(letters) - 1 while left < right: mid = left + (right - left) // 2 if letters[mid] > tar...
class Solution: def next_greatest_letter(self, letters: list, target: str) -> str: if target < letters[0] or target >= letters[-1]: return letters[0] (left, right) = (0, len(letters) - 1) while left < right: mid = left + (right - left) // 2 if letters[mid...
my_set = {1, 3, 5} my_dict = {'name': 'Jose', 'age': 90} another_dict = {1: 15, 2: 75, 3: 150} lottery_players = [ { 'name': 'Rolf', 'numbers': (13, 45, 66, 23, 22) }, { 'name': 'John', 'numbers': (14, 56, 80, 23, 22) } ] universities = [ { 'name': 'Oxford',...
my_set = {1, 3, 5} my_dict = {'name': 'Jose', 'age': 90} another_dict = {1: 15, 2: 75, 3: 150} lottery_players = [{'name': 'Rolf', 'numbers': (13, 45, 66, 23, 22)}, {'name': 'John', 'numbers': (14, 56, 80, 23, 22)}] universities = [{'name': 'Oxford', 'location': 'UK'}, {'name': 'MIT', 'location': 'US'}]
""" Various generic env utilties. """ def center_crop_img(img, crop_zoom): """ crop_zoom is amount to "zoom" into the image. E.g. 2.0 would cut out half of the width, half of the height, and only give the center. """ raw_height, raw_width = img.shape[:2] center = raw_height // 2, raw_width // 2 cro...
""" Various generic env utilties. """ def center_crop_img(img, crop_zoom): """ crop_zoom is amount to "zoom" into the image. E.g. 2.0 would cut out half of the width, half of the height, and only give the center. """ (raw_height, raw_width) = img.shape[:2] center = (raw_height // 2, raw_width // 2) ...
# -*- coding: utf-8 -*- def docstring_property(class_doc): """Property attribute for docstrings. Took from: https://gist.github.com/bfroehle/4041015 >>> class A(object): ... '''Main docstring''' ... def __init__(self, x): ... self.x = x ... @docstring_property(__doc__)...
def docstring_property(class_doc): """Property attribute for docstrings. Took from: https://gist.github.com/bfroehle/4041015 >>> class A(object): ... '''Main docstring''' ... def __init__(self, x): ... self.x = x ... @docstring_property(__doc__) ... def __doc__(s...
class PaintEventArgs(EventArgs,IDisposable): """ Provides data for the System.Windows.Forms.Control.Paint event. PaintEventArgs(graphics: Graphics,clipRect: Rectangle) """ def Instance(self): """ This function has been arbitrarily put into the stubs""" return PaintEventArgs() def Dispose(self):...
class Painteventargs(EventArgs, IDisposable): """ Provides data for the System.Windows.Forms.Control.Paint event. PaintEventArgs(graphics: Graphics,clipRect: Rectangle) """ def instance(self): """ This function has been arbitrarily put into the stubs""" return paint_event_args() def...
# Copyright (c) 2006- Facebook # Distributed under the Thrift Software License # # See accompanying file LICENSE or visit the Thrift site at: # http://developers.facebook.com/thrift/ class TType: STOP = 0 VOID = 1 BOOL = 2 BYTE = 3 I08 = 3 DOUBLE = 4 I16 = 6 I32 = 8 I64 = 10 STR...
class Ttype: stop = 0 void = 1 bool = 2 byte = 3 i08 = 3 double = 4 i16 = 6 i32 = 8 i64 = 10 string = 11 utf7 = 11 struct = 12 map = 13 set = 14 list = 15 utf8 = 16 utf16 = 17 class Tmessagetype: call = 1 reply = 2 exception = 3 class Tpr...
class Solution: def XXX(self, x: int) -> int: def solve(x): a = list(map(int,str(x))) p = {} d=0 for ind, val in enumerate(a): p[ind] = val for i, v in p.items(): d += v*(10**i) if (2**31 - 1>= d >= -(2**...
class Solution: def xxx(self, x: int) -> int: def solve(x): a = list(map(int, str(x))) p = {} d = 0 for (ind, val) in enumerate(a): p[ind] = val for (i, v) in p.items(): d += v * 10 ** i if 2 ** 31 - 1 ...
#------ game constants -----# #players WHITE = 0 BLACK = 1 BOTH = 2 #color for onTurnLabel PLAYER_COLOR = ["white", "black"] #figures PAWN = 1 KNIGHT = 2 BISHOP = 3 ROOK = 4 QUEEN = 5 KING = 6 FIGURE_NAME = [ "", "pawn", "knight", "bishop", "rook", "queen", "king" ] #used in move 32bit for prom...
white = 0 black = 1 both = 2 player_color = ['white', 'black'] pawn = 1 knight = 2 bishop = 3 rook = 4 queen = 5 king = 6 figure_name = ['', 'pawn', 'knight', 'bishop', 'rook', 'queen', 'king'] prom_knight = 0 prom_bishop = 1 prom_rook = 2 prom_queen = 3 (a, b, c, d, e, f, g, h) = range(8) (a1, b1, c1, d1, e1, f1, g1, ...
class BST: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right @staticmethod def array2BST(array): ''' array:sorted array ''' n = len(array) if n == 0: return None m = n//2 left,...
class Bst: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right @staticmethod def array2_bst(array): """ array:sorted array """ n = len(array) if n == 0: return None m = n //...
TANGO_PALLETE = [ '2e2e34343636', 'cccc00000000', '4e4e9a9a0606', 'c4c4a0a00000', '34346565a4a4', '757550507b7b', '060698989a9a', 'd3d3d7d7cfcf', '555557575353', 'efef29292929', '8a8ae2e23434', 'fcfce9e94f4f', '72729f9fcfcf', 'adad7f7fa8a8', '34...
tango_pallete = ['2e2e34343636', 'cccc00000000', '4e4e9a9a0606', 'c4c4a0a00000', '34346565a4a4', '757550507b7b', '060698989a9a', 'd3d3d7d7cfcf', '555557575353', 'efef29292929', '8a8ae2e23434', 'fcfce9e94f4f', '72729f9fcfcf', 'adad7f7fa8a8', '3434e2e2e2e2', 'eeeeeeeeecec'] def parse_tango_color(c): r = int(c[:4][:2...
def gen(): i = 0 while 1: yield i i += 1 g = gen() try: g.pend_throw except AttributeError: print("SKIP") raise SystemExit print(next(g)) print(next(g)) g.pend_throw(ValueError()) v = None try: v = next(g) except Exception as e: print("raised", repr(e)) print("ret was:"...
def gen(): i = 0 while 1: yield i i += 1 g = gen() try: g.pend_throw except AttributeError: print('SKIP') raise SystemExit print(next(g)) print(next(g)) g.pend_throw(value_error()) v = None try: v = next(g) except Exception as e: print('raised', repr(e)) print('ret was:', v) ...
# Copyright (c) 2021 Food-X Technologies # # This file is part of foodx_devops_tools. # # You should have received a copy of the MIT License along with # foodx_devops_tools. If not, see <https://opensource.org/licenses/MIT>. """Azure related utilities."""
"""Azure related utilities."""
_base_ = [ '../../../_base_/datasets/imagenet/swin_sz224_4xbs256.py', '../../../_base_/default_runtime.py', ] # model settings model = dict( type='MixUpClassification', pretrained=None, alpha=0.2, mix_mode="cutmix", mix_args=dict( attentivemix=dict(grid_size=32, top_k=None, beta=8),...
_base_ = ['../../../_base_/datasets/imagenet/swin_sz224_4xbs256.py', '../../../_base_/default_runtime.py'] model = dict(type='MixUpClassification', pretrained=None, alpha=0.2, mix_mode='cutmix', mix_args=dict(attentivemix=dict(grid_size=32, top_k=None, beta=8), automix=dict(mask_adjust=0, lam_margin=0), fmix=dict(decay...
# -*- coding: utf-8 -*- __about__ = """ This project demonstrates a social networking site. It provides profiles, friends, photos, blogs, tribes, wikis, tweets, bookmarks, swaps, locations and user-to-user messaging. In 0.5 this was called "complete_project". """
__about__ = '\nThis project demonstrates a social networking site. It provides profiles,\nfriends, photos, blogs, tribes, wikis, tweets, bookmarks, swaps,\nlocations and user-to-user messaging.\n\nIn 0.5 this was called "complete_project".\n'
# Level: Hard def isMatch(s: str, p: str) -> bool: if not p: return not s n_s = len(s) n_p = len(p) j = 0 i = -1 while i < n_s-1: i = i+ 1 if j >= n_p: return False if p[j] == '*': while s[i]==s[i-1]: i += 1 j...
def is_match(s: str, p: str) -> bool: if not p: return not s n_s = len(s) n_p = len(p) j = 0 i = -1 while i < n_s - 1: i = i + 1 if j >= n_p: return False if p[j] == '*': while s[i] == s[i - 1]: i += 1 j += 1 ...
####################### # Dennis MUD # # locate_item.py # # Copyright 2018-2020 # # Michael D. Reiley # ####################### # ********** # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to # deal i...
name = 'locate item' categories = ['items'] aliases = ['find item'] usage = 'locate item <item_id>' description = 'Find out what room the item <item_id> is in, or who is holding it.\n\nYou can only locate an item that you own.\nWizards can locate any item.\n\nEx. `locate item 4`' def command(console, args): if not...
class Metric(object): """Base class for all metrics. From: https://github.com/pytorch/tnt/blob/master/torchnet/meter/meter.py """ def reset(self): pass def add(self): pass def value(self): pass
class Metric(object): """Base class for all metrics. From: https://github.com/pytorch/tnt/blob/master/torchnet/meter/meter.py """ def reset(self): pass def add(self): pass def value(self): pass
# Take number, and convert integer to string # Calculate and return number of digits def get_num_digits(num): # Convert int to str num_str = str(num) # Calculate number of digits digits = len(num_str) return digits # Define main function def main(): # Prompt user for an int...
def get_num_digits(num): num_str = str(num) digits = len(num_str) return digits def main(): number = int(input('Enter an integer: ')) num_digits = get_num_digits(number) print(f'The number of digits in number {number} is {num_digits}.') main()
#Atoi stands for ASCII to Integer Conversion def atoi(string): res = 0 # Iterate through all characters of # input and update result for i in range(len(string)): res = res * 10 + (ord(string[i]) - ord('0')) return res #Adjustment contains rule of three for calculating an integer given an...
def atoi(string): res = 0 for i in range(len(string)): res = res * 10 + (ord(string[i]) - ord('0')) return res def adjustment(a, b): return a * b / 100
def bypass_incompatible_branch(job): return (job.settings.bypass_incompatible_branch or job.author_bypass.get('bypass_incompatible_branch', False)) def bypass_peer_approval(job): return (job.settings.bypass_peer_approval or job.author_bypass.get('bypass_peer_approval', False)) def b...
def bypass_incompatible_branch(job): return job.settings.bypass_incompatible_branch or job.author_bypass.get('bypass_incompatible_branch', False) def bypass_peer_approval(job): return job.settings.bypass_peer_approval or job.author_bypass.get('bypass_peer_approval', False) def bypass_leader_approval(job): ...
class Heap: def __init__(self): self.items = dict() # key - (value, index) self.indexes = [] # index - key // to know indexes # Usefull functions def swap(self, i, j): x = self.indexes[i] # key of 1 item y = self.indexes[j] # key of 2 item # swa...
class Heap: def __init__(self): self.items = dict() self.indexes = [] def swap(self, i, j): x = self.indexes[i] y = self.indexes[j] self.indexes[i] = y self.indexes[j] = x temp = self.items[x][1] self.items.update({x: (self.items[x][0], self.item...
class Solution(object): def rearrangeString(self, str, k): """ :type str: str :type k: int :rtype: str """ ## greedy: count keeps the # of chars, valid keeps the leftmost valid index of a char. res=[] # count # of chars d=coll...
class Solution(object): def rearrange_string(self, str, k): """ :type str: str :type k: int :rtype: str """ res = [] d = collections.defaultdict(int) for c in str: d[c] += 1 v = collections.defaultdict(int) for i in range(l...
''' All the reserved, individual words used in MAlice. ''' A = "a" ALICE = "Alice" AND = "and" ATE = "ate" BECAME = "became" BECAUSE = "because" BUT = "but" CLOSED = "closed" COMMA = "," CONTAINED = "contained" DOT = "." DRANK = "drank" EITHER = "either" ENOUGH = "enough" EVENTUALLY = "eventually" FOUND = "found" H...
""" All the reserved, individual words used in MAlice. """ a = 'a' alice = 'Alice' and = 'and' ate = 'ate' became = 'became' because = 'because' but = 'but' closed = 'closed' comma = ',' contained = 'contained' dot = '.' drank = 'drank' either = 'either' enough = 'enough' eventually = 'eventually' found = 'found' ha...
def migrate(): print('migrating to version 2')
def migrate(): print('migrating to version 2')
test = { 'name': 'q2b3', 'points': 5, 'suites': [ { 'cases': [ { 'code': '>>> ' 'histories_2b[2].model.count_params()\n' '119260', 'hidden': False, ...
test = {'name': 'q2b3', 'points': 5, 'suites': [{'cases': [{'code': '>>> histories_2b[2].model.count_params()\n119260', 'hidden': False, 'locked': False}, {'code': ">>> histories_2b[2].model.layers[1].activation.__name__\n'sigmoid'", 'hidden': False, 'locked': False}, {'code': '>>> histories_2b[2].model.layers[1].units...
# Time: O(n*2^n) # Space: O(2^n) class Solution(object): def canPartitionKSubsets(self, nums, k): """ :type nums: List[int] :type k: int :rtype: bool """ def dfs(nums, target, used, todo, lookup): if lookup[used] is None: targ = (todo-1)%...
class Solution(object): def can_partition_k_subsets(self, nums, k): """ :type nums: List[int] :type k: int :rtype: bool """ def dfs(nums, target, used, todo, lookup): if lookup[used] is None: targ = (todo - 1) % target + 1 ...
#!/usr/bin/env python # License: Apache-2.0 # Copyright (C) 2020 Mikhail f. Shiryaev class Column(object): """ Represents ClickHouse column """ def __init__( self, database: str, table: str, name: str, type: str, default_kind: str, default_expr...
class Column(object): """ Represents ClickHouse column """ def __init__(self, database: str, table: str, name: str, type: str, default_kind: str, default_expression: str, comment: str, compression_codec: str, is_in_partition_key: bool, is_in_sorting_key: bool, is_in_primary_key: bool, is_in_sampling_ke...
def solve(n, red , blue): rcount = bcount = 0 for i in range(n): if int(red[i]) > int(blue[i]): rcount = rcount +1 elif int(red[i]) < int(blue[i]): bcount = bcount + 1 print( 'RED' if rcount>bcount else ('BLUE' if bcount>rcount else 'EQUAL')) if __name__ == "__ma...
def solve(n, red, blue): rcount = bcount = 0 for i in range(n): if int(red[i]) > int(blue[i]): rcount = rcount + 1 elif int(red[i]) < int(blue[i]): bcount = bcount + 1 print('RED' if rcount > bcount else 'BLUE' if bcount > rcount else 'EQUAL') if __name__ == '__main__...
class a: def __init__(self,da): self.da = da return def go(self): dd() return None def dd(): print('ok') return None aa = a(1) aa.go()
class A: def __init__(self, da): self.da = da return def go(self): dd() return None def dd(): print('ok') return None aa = a(1) aa.go()
""" These methods can be called inside WebCAT to determine which tests are loaded for a given section/exam pair. This allows a common WebCAT submission site to support different project tests """ def section(): # Instructor section (instructor to change before distribution) #return 8527 #return 8528 r...
""" These methods can be called inside WebCAT to determine which tests are loaded for a given section/exam pair. This allows a common WebCAT submission site to support different project tests """ def section(): return 8529 def exam(): return 'A'
""" PermCheck Check whether array A is a permutation. https://codility.com/demo/results/demoANZ7M2-GFU/ Task description A non-empty zero-indexed array A consisting of N integers is given. A permutation is a sequence containing each element from 1 to N once, and only once. For example, array A such that: A[0] = 4...
""" PermCheck Check whether array A is a permutation. https://codility.com/demo/results/demoANZ7M2-GFU/ Task description A non-empty zero-indexed array A consisting of N integers is given. A permutation is a sequence containing each element from 1 to N once, and only once. For example, array A such that: A[0] = 4...
''' Created on Dec 27, 2019 @author: duane ''' DOLLAR = ord('$') LBRACE = ord('{') RBRACE = ord('}') LPAREN = ord('(') RPAREN = ord(')') class IStrFindResult(object): OK = 0 NOTFOUND = 1 SYNTAX = 2 def __init__(self): self.result = IStrFindResult.SYNTAX self.lhs = 0 self.rh...
""" Created on Dec 27, 2019 @author: duane """ dollar = ord('$') lbrace = ord('{') rbrace = ord('}') lparen = ord('(') rparen = ord(')') class Istrfindresult(object): ok = 0 notfound = 1 syntax = 2 def __init__(self): self.result = IStrFindResult.SYNTAX self.lhs = 0 self.rhs ...
P, R = input().split() if P == '0': print('C') elif R == '0': print('B') else: print('A')
(p, r) = input().split() if P == '0': print('C') elif R == '0': print('B') else: print('A')
md_template_d144 = """verbosity=0 xcFunctional=PBE FDtype=4th [Mesh] nx=160 ny=80 nz=80 [Domain] ox=0. oy=0. oz=0. lx=42.4813 ly=21.2406 lz=21.2406 [Potentials] pseudopotential=pseudo.D_tm_pbe [Poisson] solver=@ max_steps_initial=@50 max_steps=@50 reset=@ bcx=periodic bcy=periodic bcz=periodic [Run] type=MD [MD] type=@...
md_template_d144 = 'verbosity=0\nxcFunctional=PBE\nFDtype=4th\n[Mesh]\nnx=160\nny=80\nnz=80\n[Domain]\nox=0.\noy=0.\noz=0.\nlx=42.4813\nly=21.2406\nlz=21.2406\n[Potentials]\npseudopotential=pseudo.D_tm_pbe\n[Poisson]\nsolver=@\nmax_steps_initial=@50\nmax_steps=@50\nreset=@\nbcx=periodic\nbcy=periodic\nbcz=periodic\n[Ru...
""" [E] Given a sorted array, create a new array containing squares of all the number of the input array in the sorted order. Input: [-2, -1, 0, 2, 3] Output: [0, 1, 4, 4, 9] """ # Time: O(N) Space: O(n) def make_squares(arr): n = len(arr) squares = [0 for x in range(n)] highestSquareIdx = n - 1 left, r...
""" [E] Given a sorted array, create a new array containing squares of all the number of the input array in the sorted order. Input: [-2, -1, 0, 2, 3] Output: [0, 1, 4, 4, 9] """ def make_squares(arr): n = len(arr) squares = [0 for x in range(n)] highest_square_idx = n - 1 (left, right) = (0, n - 1...
# Copyright 2020 The Bazel Authors. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable la...
"""Rules for importing and registering a local JDK.""" load(':default_java_toolchain.bzl', 'JVM8_TOOLCHAIN_CONFIGURATION', 'default_java_toolchain') def _detect_java_version(repository_ctx, java_bin): properties_out = repository_ctx.execute([java_bin, '-XshowSettings:properties']).stderr strip_properties = [pr...
""" Here you find either new implemented modules or alternate implementations of already modules. This directory is intended to have a second implementation beside the main implementation to have a discussion which implementation to favor on the long run. """
""" Here you find either new implemented modules or alternate implementations of already modules. This directory is intended to have a second implementation beside the main implementation to have a discussion which implementation to favor on the long run. """
"""Registry utilities to handle formats for gmso Topology.""" class UnsupportedFileFormatError(Exception): """Exception to be raised whenever the file loading or saving is not supported.""" class Registry: """A registry to incorporate a callable with a file extension.""" def __init__(self): sel...
"""Registry utilities to handle formats for gmso Topology.""" class Unsupportedfileformaterror(Exception): """Exception to be raised whenever the file loading or saving is not supported.""" class Registry: """A registry to incorporate a callable with a file extension.""" def __init__(self): self....
dosyaadi = input("Enter file name: ") dosyaadi = str(dosyaadi + ".txt") with open(dosyaadi, 'r') as file : dosyaicerigi = file.read() silinecek = str(input("Enter the text that you wish to delete: ")) dosyaicerigi = dosyaicerigi.replace(silinecek, '') with open(dosyaadi, 'w') as file: file.write(dosyai...
dosyaadi = input('Enter file name: ') dosyaadi = str(dosyaadi + '.txt') with open(dosyaadi, 'r') as file: dosyaicerigi = file.read() silinecek = str(input('Enter the text that you wish to delete: ')) dosyaicerigi = dosyaicerigi.replace(silinecek, '') with open(dosyaadi, 'w') as file: file.write(dosyaicerigi) ...
""" decoded AUTH_HEADER (newlines added for readability): { "identity": { "account_number": "1234", "internal": { "org_id": "5678" }, "type": "User", "user": { "email": "test@example.com", "first_name": "Firstname", "is_active":...
""" decoded AUTH_HEADER (newlines added for readability): { "identity": { "account_number": "1234", "internal": { "org_id": "5678" }, "type": "User", "user": { "email": "test@example.com", "first_name": "Firstname", "is_active":...
# -*- coding: utf-8 -*- """ Created on Wed Feb 26 22:23:07 2020 @author: Neal LONG Try to construct URL with string.format """ base_url = "http://quotes.money.163.com/service/gszl_{:>06}.html?type={}" stock = "000002" api_type = 'cp' print("http://quotes.money.163.com/service/gszl_"+stock+".html?type="...
""" Created on Wed Feb 26 22:23:07 2020 @author: Neal LONG Try to construct URL with string.format """ base_url = 'http://quotes.money.163.com/service/gszl_{:>06}.html?type={}' stock = '000002' api_type = 'cp' print('http://quotes.money.163.com/service/gszl_' + stock + '.html?type=' + api_type) print(base_url.format(...
''' DNA++ (c) DNA++ 2017 All rights reserved. @author: neilswainston '''
""" DNA++ (c) DNA++ 2017 All rights reserved. @author: neilswainston """
"""Mock responses for recommendations.""" SEARCH_REQ = { "criteria": { "policy_type": ['reputation_override'], "status": ['NEW', 'REJECTED', 'ACCEPTED'], "hashes": ['111', '222'] }, "rows": 50, "sort": [ { "field": "impact_score", "order": "DESC" ...
"""Mock responses for recommendations.""" search_req = {'criteria': {'policy_type': ['reputation_override'], 'status': ['NEW', 'REJECTED', 'ACCEPTED'], 'hashes': ['111', '222']}, 'rows': 50, 'sort': [{'field': 'impact_score', 'order': 'DESC'}]} search_resp = {'results': [{'recommendation_id': '91e9158f-23cc-47fd-af7f-8...
class Solution: def invertTree(self, root: Optional[TreeNode]) -> Optional[TreeNode]: if root: root.left,root.right = self.invertTree(root.right),self.invertTree(root.left) return root return None
class Solution: def invert_tree(self, root: Optional[TreeNode]) -> Optional[TreeNode]: if root: (root.left, root.right) = (self.invertTree(root.right), self.invertTree(root.left)) return root return None
def assert_not_none(actual_result, message=""): if not message: message = f"{actual_result} resulted with None" assert actual_result, message def assert_equal(actual_result, expected_result, message=""): if not message: message = f"{actual_result} is not equal to expected " \ ...
def assert_not_none(actual_result, message=''): if not message: message = f'{actual_result} resulted with None' assert actual_result, message def assert_equal(actual_result, expected_result, message=''): if not message: message = f'{actual_result} is not equal to expected result {expected_r...
""" This is the doc for the Grid Diagnostics module. These functions are based on the grid diagnostics from the GEneral Meteorological PAcKage (GEMPAK). Note that the names are case sensitive and some are named slightly different from GEMPAK functions to avoid conflicts with Jython built-ins (e.g. st...
""" This is the doc for the Grid Diagnostics module. These functions are based on the grid diagnostics from the GEneral Meteorological PAcKage (GEMPAK). Note that the names are case sensitive and some are named slightly different from GEMPAK functions to avoid conflicts with Jython built-ins (e.g. st...
# 2019 advent day 3 MOVES = { 'R': (lambda x: (x[0], x[1] + 1)), 'L': (lambda x: (x[0], x[1] - 1)), 'U': (lambda x: (x[0] + 1, x[1])), 'D': (lambda x: (x[0] - 1, x[1])), } def build_route(directions: list) -> list: current_location = (0, 0) route = [] for d in directions: directio...
moves = {'R': lambda x: (x[0], x[1] + 1), 'L': lambda x: (x[0], x[1] - 1), 'U': lambda x: (x[0] + 1, x[1]), 'D': lambda x: (x[0] - 1, x[1])} def build_route(directions: list) -> list: current_location = (0, 0) route = [] for d in directions: (direction, amount) = (d[0], int(d[1:])) for _ in...
class Solution(object): def minPathSum(self, grid): """ :type grid: List[List[int]] :rtype: int """ m, n = len(grid), len(grid[0]) dp = [[0] * n for _ in range(m)] for i in range(m): for j in range(n): if i == 0 and j == 0: ...
class Solution(object): def min_path_sum(self, grid): """ :type grid: List[List[int]] :rtype: int """ (m, n) = (len(grid), len(grid[0])) dp = [[0] * n for _ in range(m)] for i in range(m): for j in range(n): if i == 0 and j == 0: ...
budget = float(input()) nights = int(input()) price_night = float(input()) percent_extra = int(input()) if nights > 7: price_night = price_night - (price_night * 0.05) sum = nights * price_night total_sum = sum + (budget * percent_extra / 100) if total_sum <= budget: print(f"Ivanovi will be left ...
budget = float(input()) nights = int(input()) price_night = float(input()) percent_extra = int(input()) if nights > 7: price_night = price_night - price_night * 0.05 sum = nights * price_night total_sum = sum + budget * percent_extra / 100 if total_sum <= budget: print(f'Ivanovi will be left with {budget - tota...
class Skidoo(object): ''' a mapping which claims to contain all keys, each with a value of 23; item setting and deletion are no-ops; you can also call an instance with arbitrary positional args, result is 23. ''' __metaclass__ = MetaInterfaceChecker __implements__ = IMinimalMapping, ICallabl...
class Skidoo(object): """ a mapping which claims to contain all keys, each with a value of 23; item setting and deletion are no-ops; you can also call an instance with arbitrary positional args, result is 23. """ __metaclass__ = MetaInterfaceChecker __implements__ = (IMinimalMapping, ICallab...
#!/usr/bin/env python # coding: UTF-8 # # @package Actor # @author Ariadne Pinheiro # @date 26/08/2020 # # Actor class, which is the base class for Disease objects. # ## class Actor: # Holds the value of the next "free" id. __ID = 0 ## # Construct a new Actor object. # - Sets the initial values of...
class Actor: __id = 0 def __init__(self): self.__locX = 0 self.__locY = 0 self.__world = None self.__actorID = Actor.__ID Actor.__ID += 1 self.__itCounter = 0 def get_id(self): return self.__actorID def iteration(self): return self.__itC...
NAMES_SAML2_PROTOCOL = "urn:oasis:names:tc:SAML:2.0:protocol" NAMES_SAML2_ASSERTION = "urn:oasis:names:tc:SAML:2.0:assertion" NAMEID_FORMAT_UNSPECIFIED = "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified" BINDINGS_HTTP_POST = "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" DATE_TIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ" ...
names_saml2_protocol = 'urn:oasis:names:tc:SAML:2.0:protocol' names_saml2_assertion = 'urn:oasis:names:tc:SAML:2.0:assertion' nameid_format_unspecified = 'urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified' bindings_http_post = 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST' date_time_format = '%Y-%m-%dT%H:%M:%SZ' ...
class BaseSSO: async def get_redirect_url(self): """Returns redirect url for facebook.""" raise NotImplementedError("Provider not implemented") async def verify(self, request): """ Fetches user details using code received in the request. :param request: starlette req...
class Basesso: async def get_redirect_url(self): """Returns redirect url for facebook.""" raise not_implemented_error('Provider not implemented') async def verify(self, request): """ Fetches user details using code received in the request. :param request: starlette req...
def write(message: str): print("org.allnix", message) def read() -> str: """Returns a string""" return "org.allnix"
def write(message: str): print('org.allnix', message) def read() -> str: """Returns a string""" return 'org.allnix'
groupSize = input() groups = list(map(int,input().split(' '))) tmpArray1 = set() tmpArray2 = set() for i in groups: if i in tmpArray1: tmpArray2.discard(i) else: tmpArray1.add(i) tmpArray2.add(i) for i in tmpArray2: print(i)
group_size = input() groups = list(map(int, input().split(' '))) tmp_array1 = set() tmp_array2 = set() for i in groups: if i in tmpArray1: tmpArray2.discard(i) else: tmpArray1.add(i) tmpArray2.add(i) for i in tmpArray2: print(i)
#!/usr/bin/python3 #------------------------------------------------------------------------------ # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def levelOrder(self, root): ...
class Solution: def level_order(self, root): """ :type root: TreeNode :rtype: List[List[int]] """ if not root: return [] stack = [(root, 0)] result = [] while stack: (node, level) = stack.pop(0) if level == len(resu...
""" Your module description """ """ this is my second py code for my second lecture """ #print ('hello world') # this is a single line commment # this is my second line comment #print(type("123.")) #print ("Hello World".upper()) #print("Hello World".lower()) #print("hello" + "world" + ".") #print(2**3) #my_st...
""" Your module description """ '\nthis is my second py code\n\nfor my second lecture\n' my_int = 2 my_float = 3.0 print(my_int + my_float)
class Calculations: def __init__(self, first, second): self.first = first self.second = second def add(self): print(self.first + self.second) def subtract(self): print(self.first - self.second) def multiply(self): print(self.first * self.second) ...
class Calculations: def __init__(self, first, second): self.first = first self.second = second def add(self): print(self.first + self.second) def subtract(self): print(self.first - self.second) def multiply(self): print(self.first * self.second) def divid...
n, k = map(int, input().split()) w = list(map(int, input().split())) r = sum(map(lambda x: (x+k-1)//k, w)) print((r+1)//2)
(n, k) = map(int, input().split()) w = list(map(int, input().split())) r = sum(map(lambda x: (x + k - 1) // k, w)) print((r + 1) // 2)
# -*- coding: utf-8 -*- def main(): a = input() # See: # https://www.slideshare.net/chokudai/abc007 if a == 'a': print('-1') else: print('a') if __name__ == '__main__': main()
def main(): a = input() if a == 'a': print('-1') else: print('a') if __name__ == '__main__': main()
class Constants(object): LOGGER_CONF = "common/mapr_conf/logger.yml" USERNAME = "mapr" GROUPNAME = "mapr" USERID = 5000 GROUPID = 5000 ADMIN_USERNAME = "custadmin" ADMIN_GROUPNAME = "custadmin" ADMIN_USERID = 7000 ADMIN_GROUPID = 7000 ADMIN_PASS = "mapr" MYSQL_USER = "admin"...
class Constants(object): logger_conf = 'common/mapr_conf/logger.yml' username = 'mapr' groupname = 'mapr' userid = 5000 groupid = 5000 admin_username = 'custadmin' admin_groupname = 'custadmin' admin_userid = 7000 admin_groupid = 7000 admin_pass = 'mapr' mysql_user = 'admin' ...
# input N, M = map(int, input().split()) Ds = [*map(int, input().split())] # compute dp = [False] * (N+1) for ni in range(N+1): if ni == 0: dp[ni] = True for D in Ds: if ni >= D: dp[ni] = dp[ni] or dp[ni-D] # output print("Yes" if dp[-1] else "No")
(n, m) = map(int, input().split()) ds = [*map(int, input().split())] dp = [False] * (N + 1) for ni in range(N + 1): if ni == 0: dp[ni] = True for d in Ds: if ni >= D: dp[ni] = dp[ni] or dp[ni - D] print('Yes' if dp[-1] else 'No')
# sorting n=int(input()) array=list(map(int,input().split())) i=0 count=[] counter=0 while i<len(array): min=i start=i+1 while(start<len(array)): if array[start]<array[min]: min=start start+=1 if i!=min: array[i],array[min]=array[min],array[i] count.append(i) ...
n = int(input()) array = list(map(int, input().split())) i = 0 count = [] counter = 0 while i < len(array): min = i start = i + 1 while start < len(array): if array[start] < array[min]: min = start start += 1 if i != min: (array[i], array[min]) = (array[min], array[i]...
class GeomCombinationSet(APIObject, IDisposable, IEnumerable): """ A set that contains GeomCombination objects. GeomCombinationSet() """ def Clear(self): """ Clear(self: GeomCombinationSet) Removes every item GeomCombination the set,rendering it empty. """ pass ...
class Geomcombinationset(APIObject, IDisposable, IEnumerable): """ A set that contains GeomCombination objects. GeomCombinationSet() """ def clear(self): """ Clear(self: GeomCombinationSet) Removes every item GeomCombination the set,rendering it empty. """ pass def contains(...
#Basics a = "hello" a += " I'm a dog" print(a) print(len(a)) print(a[1:]) #Output: ello I'm a dog print(a[:5]) #Output: hello(index 5 is not included) print(a[2:5])#Output: llo(index 2 is included) print(a[::2])#Step size #string is immutable so you can't assign a[1]= b x = a.upper() print(x) x = a.capitalize() prin...
a = 'hello' a += " I'm a dog" print(a) print(len(a)) print(a[1:]) print(a[:5]) print(a[2:5]) print(a[::2]) x = a.upper() print(x) x = a.capitalize() print(x) x = a.split('e') print(x) x = a.split() print(x) x = a.strip() print(x) x = a.replace('l', 'xxx') print(x) x = 'Insert another string here: {}'.format('insert me!...
#Copyright (c) 2017 Andre Santos # #Permission is hereby granted, free of charge, to any person obtaining a copy #of this software and associated documentation files (the "Software"), to deal #in the Software without restriction, including without limitation the rights #to use, copy, modify, merge, publish, distribute...
class Codeentity(object): """Base class for all programming entities. All code objects have a file name, a line number, a column number, a programming scope (e.g. the function or code block they belong to) and a parent object that should have some variable or collection holding this...
def is_even(i: int) -> bool: if i == 1: return False elif i == 2: return True elif i == 3: return False elif i == 4: return True elif i == 5: ... # Never do that! Use one of these instead... is_even = lambda i : i % 2 == 0 is_even = lambda i : not i & 1 is_o...
def is_even(i: int) -> bool: if i == 1: return False elif i == 2: return True elif i == 3: return False elif i == 4: return True elif i == 5: ... is_even = lambda i: i % 2 == 0 is_even = lambda i: not i & 1 is_odd = lambda i: not is_even(i)
""" Contains the QuantumCircuit class boom. """ class QuantumCircuit(object): # pylint: disable=useless-object-inheritance """ Implements a quantum circuit. - - - WRITE DOCUMENTATION HERE - - - """ def __init__(self): """ Initialise a QuantumCircuit object """ pass def add_ga...
""" Contains the QuantumCircuit class boom. """ class Quantumcircuit(object): """ Implements a quantum circuit. - - - WRITE DOCUMENTATION HERE - - - """ def __init__(self): """ Initialise a QuantumCircuit object """ pass def add_gate(self, gate): """ Add a gate to th...
""" Module: 'ubinascii' on esp32 1.10.0 """ # MCU: (sysname='esp32', nodename='esp32', release='1.10.0', version='v1.10 on 2019-01-25', machine='ESP32 module with ESP32') # Stubber: 1.2.0 def a2b_base64(): pass def b2a_base64(): pass def crc32(): pass def hexlify(): pass def unhexlify(): pass
""" Module: 'ubinascii' on esp32 1.10.0 """ def a2b_base64(): pass def b2a_base64(): pass def crc32(): pass def hexlify(): pass def unhexlify(): pass
__title__ = 'har2case' __description__ = 'Convert HAR(HTTP Archive) to YAML/JSON testcases for HttpRunner.' __url__ = 'https://github.com/HttpRunner/har2case' __version__ = '0.2.0' __author__ = 'debugtalk' __author_email__ = 'mail@debugtalk.com' __license__ = 'Apache-2.0' __copyright__ = 'Copyright 2017 debugtalk'
__title__ = 'har2case' __description__ = 'Convert HAR(HTTP Archive) to YAML/JSON testcases for HttpRunner.' __url__ = 'https://github.com/HttpRunner/har2case' __version__ = '0.2.0' __author__ = 'debugtalk' __author_email__ = 'mail@debugtalk.com' __license__ = 'Apache-2.0' __copyright__ = 'Copyright 2017 debugtalk'
def pictureInserter(og,address,list): j=0 for i in og: file1 = open(address+'/'+i, "a") x="\ncover::https://image.tmdb.org/t/p/original/"+list[j] file1.writelines(x) file1.close() j=j+1
def picture_inserter(og, address, list): j = 0 for i in og: file1 = open(address + '/' + i, 'a') x = '\ncover::https://image.tmdb.org/t/p/original/' + list[j] file1.writelines(x) file1.close() j = j + 1
class Solution: def removeOuterParentheses(self, s: str) -> str: ans = [] ct = 0 for ch in s: if ch == '(': ct += 1 if ct != 1: ans.append(ch) else: ct -= 1 if ct != 0: ...
class Solution: def remove_outer_parentheses(self, s: str) -> str: ans = [] ct = 0 for ch in s: if ch == '(': ct += 1 if ct != 1: ans.append(ch) else: ct -= 1 if ct != 0: ...
####################################################################################################################### # Given a string, find the length of the longest substring which has no repeating characters. # # Input: String="aabccbb" # Output: 3 # Explanation: The longest substring without any repeating charact...
def longest_substring_no_repeating_char(input_str: str) -> int: window_start = 0 is_present = [None for i in range(26)] max_window = 0 for i in range(len(input_str)): char_ord = ord(input_str[i]) - 97 if is_present[char_ord] is not None: window_start = max(window_start, is_pr...
# -*- coding: UTF-8 -*- """ This file is part of Pondus, a personal weight manager. Copyright (C) 2011 Eike Nicklas <eike@ephys.de> This program is free software licensed under the MIT license. For details see LICENSE or http://www.opensource.org/licenses/mit-license.php """ __all__ = ['csv_backend', 'sportstracker...
""" This file is part of Pondus, a personal weight manager. Copyright (C) 2011 Eike Nicklas <eike@ephys.de> This program is free software licensed under the MIT license. For details see LICENSE or http://www.opensource.org/licenses/mit-license.php """ __all__ = ['csv_backend', 'sportstracker_backend', 'xml_backend', ...
""" The DataHandlers subpackage is designed to manipulate data, by allowing different data types to be opened, created, saved and updated. The subpackage is further divided into modules grouped by a common theme. Classes for data that are already on disk normally follows the following pattern: `instance=ClassName(file_...
""" The DataHandlers subpackage is designed to manipulate data, by allowing different data types to be opened, created, saved and updated. The subpackage is further divided into modules grouped by a common theme. Classes for data that are already on disk normally follows the following pattern: `instance=ClassName(file_...
class Solution(object): def powerfulIntegers(self, x, y, bound): """ :type x: int :type y: int :type bound: int :rtype: List[int] """ # Find max exponent base = max(x, y) if x == 1 or y == 1 else min(x, y) exponent = 1 if base != 1: ...
class Solution(object): def powerful_integers(self, x, y, bound): """ :type x: int :type y: int :type bound: int :rtype: List[int] """ base = max(x, y) if x == 1 or y == 1 else min(x, y) exponent = 1 if base != 1: while base ** exp...
# ------------------------------ # Binary Tree Level Order Traversal # # Description: # Given a binary tree, return the level order traversal of its nodes' values. (ie, from # left to right, level by level). # # For example: # Given binary tree [3,9,20,null,null,15,7], # 3 # / \ # 9 20 # / \ # 15 ...
class Solution: def level_order(self, root: TreeNode) -> List[List[int]]: if not root: return [] res = [] queue = [root] while queue: temp = [] children = [] for node in queue: temp.append(node.val) if n...
def take_beer(fridge, number=1): if "beer" not in fridge: raise Exception("No beer at all:(") if number > fridge["beer"]: raise Exception("Not enough beer:(") fridge["beer"] -= number if __name__ == "__main__": fridge = { "beer": 2, "milk": 1, "meat": 3, }...
def take_beer(fridge, number=1): if 'beer' not in fridge: raise exception('No beer at all:(') if number > fridge['beer']: raise exception('Not enough beer:(') fridge['beer'] -= number if __name__ == '__main__': fridge = {'beer': 2, 'milk': 1, 'meat': 3} print('I wanna drink 1 bottle ...
camera_width = 640 camera_height = 480 film_back_width = 1.417 film_back_height = 0.945 x_center = 320 y_center = 240 P_1 = (-0.023, -0.261, 2.376) p_11 = P_1[0] p_12 = P_1[1] p_13 = P_1[2] P_2 = (0.659, -0.071, 2.082) p_21 = P_2[0] p_22 = P_2[1] p_23 = P_2[2] p_1_prime = (52, 163) x_1 = p_1_prime[0] y_1 = p_1_pr...
camera_width = 640 camera_height = 480 film_back_width = 1.417 film_back_height = 0.945 x_center = 320 y_center = 240 p_1 = (-0.023, -0.261, 2.376) p_11 = P_1[0] p_12 = P_1[1] p_13 = P_1[2] p_2 = (0.659, -0.071, 2.082) p_21 = P_2[0] p_22 = P_2[1] p_23 = P_2[2] p_1_prime = (52, 163) x_1 = p_1_prime[0] y_1 = p_1_prime[1]...
def main(): val=int(input("input a num")) if val<10: print("A") elif val<20: print("B") elif val<30: print("C") else: print("D") main()
def main(): val = int(input('input a num')) if val < 10: print('A') elif val < 20: print('B') elif val < 30: print('C') else: print('D') main()
__all__ = ['cross_validation', 'metrics', 'datasets', 'recommender']
__all__ = ['cross_validation', 'metrics', 'datasets', 'recommender']
def is_leap(year): leap=False if year%400==0: leap=True elif year%4==0 and year%100!=0: leap=True else: leap=False return leap year = int(input())
def is_leap(year): leap = False if year % 400 == 0: leap = True elif year % 4 == 0 and year % 100 != 0: leap = True else: leap = False return leap year = int(input())
"""Contains utility functions.""" BIN_MODE_ARGS = {'mode', 'buffering', } TEXT_MODE_ARGS = {'mode', 'buffering', 'encoding', 'errors', 'newline'} def split_args(args): """Splits args into two groups: open args and other args. Open args are used by ``open`` function. Other args are used by ``load``/``dum...
"""Contains utility functions.""" bin_mode_args = {'mode', 'buffering'} text_mode_args = {'mode', 'buffering', 'encoding', 'errors', 'newline'} def split_args(args): """Splits args into two groups: open args and other args. Open args are used by ``open`` function. Other args are used by ``load``/``dump`` ...
print("Press q to quit") quit = False while quit is False: in_val = input("Please enter a positive integer.\n > ") if in_val is 'q': quit = True elif int(in_val) % 3 == 0 and int(in_val) % 5 == 0: print("FizzBuzz") elif int(in_val) % 5 == 0: print("Buzz") elif int(in_val) % ...
print('Press q to quit') quit = False while quit is False: in_val = input('Please enter a positive integer.\n > ') if in_val is 'q': quit = True elif int(in_val) % 3 == 0 and int(in_val) % 5 == 0: print('FizzBuzz') elif int(in_val) % 5 == 0: print('Buzz') elif int(in_val) % 3...