content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
# Can 31 dominoes cover all but two opposite corners of a chess board? def dominoes(): # Each dominoe must cover one black and one white square. # But there are different numbers of black and white squares. # Read up on such parity arguments here: # http://ihxrelation.blogspot.com/2015/10/tiling-problems.html ...
def dominoes(): return False
def merger_first_into_second(arr1, arr2): p1 = len(arr1) - 1 runner = len(arr2) - 1 # Assuming arr2 is the padded p2 = len(arr2) - len(arr1) - 1 while p1 >= 0 or p2 >= 0 and p1 != runner and p2 != runner: if p1 >= 0 and p2 >= 0: if arr1[p1] > arr2[p2]: arr2[runne...
def merger_first_into_second(arr1, arr2): p1 = len(arr1) - 1 runner = len(arr2) - 1 p2 = len(arr2) - len(arr1) - 1 while p1 >= 0 or (p2 >= 0 and p1 != runner and (p2 != runner)): if p1 >= 0 and p2 >= 0: if arr1[p1] > arr2[p2]: arr2[runner] = arr1[p1] p...
# strings_with_backspaces # given strings with backspace character '#' # check if they are equal def strings_with_backspaces(str1, str2): p = len(str1)-1 q = len(str2)-1 while p >= 0 and q >= 0: # handle backspace character if str1[p] == '#': p = p - 2 if str2[q] == '...
def strings_with_backspaces(str1, str2): p = len(str1) - 1 q = len(str2) - 1 while p >= 0 and q >= 0: if str1[p] == '#': p = p - 2 if str2[q] == '#': q = q - 2 if p >= 0 and q >= 0: if str1[p] != str2[q]: return False else: ...
expected_output = { "interfaces": { "Ethernet1/1": { "interface": "Ethernet1/1", "statistics": { "txreq": 0, "rxlogoff": 0, "txtotal": 3, "txreqid": 0, "lastrxsrcmac": "00:00:00:ff:00:00", ...
expected_output = {'interfaces': {'Ethernet1/1': {'interface': 'Ethernet1/1', 'statistics': {'txreq': 0, 'rxlogoff': 0, 'txtotal': 3, 'txreqid': 0, 'lastrxsrcmac': '00:00:00:ff:00:00', 'rxinvalid': 0, 'rxrespid': 0, 'rxlenerr': 0, 'rxversion': 0, 'rxstart': 0, 'rxresp': 0, 'rxtotal': 0}}}}
FreeSerifBold18pt7bBitmaps = [ 0x7B, 0xEF, 0xFF, 0xFF, 0xF7, 0x9E, 0x71, 0xC7, 0x0C, 0x20, 0x82, 0x00, 0x00, 0x07, 0x3E, 0xFF, 0xFF, 0xDC, 0x60, 0x37, 0x83, 0xFC, 0x1F, 0xE0, 0xFF, 0x07, 0xB8, 0x3D, 0xC0, 0xCC, 0x06, 0x20, 0x31, 0x01, 0x80, 0x03, 0x8E, 0x00, 0xC3, 0x80, 0x30, 0xE0, 0x1C, 0x38, 0x07, 0x0...
free_serif_bold18pt7b_bitmaps = [123, 239, 255, 255, 247, 158, 113, 199, 12, 32, 130, 0, 0, 7, 62, 255, 255, 220, 96, 55, 131, 252, 31, 224, 255, 7, 184, 61, 192, 204, 6, 32, 49, 1, 128, 3, 142, 0, 195, 128, 48, 224, 28, 56, 7, 14, 1, 195, 135, 255, 253, 255, 255, 127, 255, 193, 135, 0, 225, 192, 56, 112, 14, 28, 3, 13...
class ImportedJvmLib: _imported_libs = [] @classmethod def has_library(cls, library: str) -> bool: return library in cls._imported_libs @classmethod def import_lib(cls, library: str) -> bool: if library not in cls._imported_libs: cls._imported_libs.append(library) ...
class Importedjvmlib: _imported_libs = [] @classmethod def has_library(cls, library: str) -> bool: return library in cls._imported_libs @classmethod def import_lib(cls, library: str) -> bool: if library not in cls._imported_libs: cls._imported_libs.append(library) ...
# Load modules load_modules = { 'hw_fakeIO' : {'bus': 31}, 'gen_ping' : {'debug': 2, 'bus': 32}, 'gen_ping~1' : {'debug': 2}, 'mod_stat' : {'debug': 2} } # Scenario actions = [ {'gen_ping' : {'pipe': 2}}, {'gen_ping~1' : {'pipe': 1}}, {'hw_fakeIO' : {'action':'wri...
load_modules = {'hw_fakeIO': {'bus': 31}, 'gen_ping': {'debug': 2, 'bus': 32}, 'gen_ping~1': {'debug': 2}, 'mod_stat': {'debug': 2}} actions = [{'gen_ping': {'pipe': 2}}, {'gen_ping~1': {'pipe': 1}}, {'hw_fakeIO': {'action': 'write', 'pipe': 2}}, {'mod_stat': {'pipe': 2}}, {'mod_stat': {'pipe': 1}}]
# Copyright 2013 VMware, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing,...
class Clienterror(Exception): """dbeekeeper client error. Dbeekeeper raises a ClientError when it encounters a client-side errors. Examples of client-side errors are: - Trying to delete a non-existent record. - Foreign key constraint error. - Malformed transaction. Client-side errors are ...
# parsetab.py # This file is automatically generated. Do not edit. # pylint: disable=W,C,R _tabversion = '3.10' _lr_method = 'LALR' _lr_signature = 'AND CLOSE_B COLUMN_FUNCTION_NAME COMMA DIVIDE EQUALITY FROM_T GREATER_THAN LESS_THAN MINUS NOT NUMBER OPEN_B OR PLUS SELECT_T SEMICOLON TIMES WHERE_TSQLselect : SELECT_...
_tabversion = '3.10' _lr_method = 'LALR' _lr_signature = 'AND CLOSE_B COLUMN_FUNCTION_NAME COMMA DIVIDE EQUALITY FROM_T GREATER_THAN LESS_THAN MINUS NOT NUMBER OPEN_B OR PLUS SELECT_T SEMICOLON TIMES WHERE_TSQLselect : SELECT_T COLUMN_FUNCTION_NAME FROM_T COLUMN_FUNCTION_NAME SEMICOLON\n | SELECT_T TIME...
# nlantau, 2002-11-08 def spin_words(s): # s = s.split(" ") # for i, word in enumerate(s): # if len(word) >= 5: # s[i] = word[::-1] # return " ".join(s) return " ".join([i[::-1] if len(i) >= 5 else i for i in s.split(" ")]) print(spin_words("hey my name is Niklas Welcome"))
def spin_words(s): return ' '.join([i[::-1] if len(i) >= 5 else i for i in s.split(' ')]) print(spin_words('hey my name is Niklas Welcome'))
CSS_BUNDLES = { 'common': ( 'css/normalize.css', 'less/style.less', ), 'profile': ( 'less/profile.less', ) } JS_BUNDLES = { 'common': ( 'js/standup.js', ) }
css_bundles = {'common': ('css/normalize.css', 'less/style.less'), 'profile': ('less/profile.less',)} js_bundles = {'common': ('js/standup.js',)}
"""Initialize proj-template module.""" # __version__ should be updated only by utils/release __version__ = "0.2.1"
"""Initialize proj-template module.""" __version__ = '0.2.1'
# # PySNMP MIB module BIANCA-BRICK-TDRC-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/BIANCA-BRICK-TDRC-MIB # Produced by pysmi-0.3.4 at Wed May 1 11:38:47 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (def...
(object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (single_value_constraint, value_range_constraint, constraints_union, value_size_constraint, constraints_intersection) ...
[ [ 1.00000000e00, 9.50744855e-01, 7.61580875e-01, 1.45494511e-03, 1.35271514e-04, 2.75262668e-03, 9.40575477e-01, 4.90755141e-01, 3.16822332e-03, 6.38672254e-01, 3.44275537e-05, ], [ 1.00000000e00, 2.345...
[[1.0, 0.950744855, 0.761580875, 0.00145494511, 0.000135271514, 0.00275262668, 0.940575477, 0.490755141, 0.00316822332, 0.638672254, 3.44275537e-05], [1.0, 0.234589189, 0.702082945, 0.000884605265, 0.000567562813, 0.00594375533, 0.553862215, 0.388027539, 0.0111098015, 0.271039211, 0.000725442977], [1.0, 0.0878852262, 0...
"""AI Engines Here is a set of AI- and ML-patterns for adavanced research of business data. """
"""AI Engines Here is a set of AI- and ML-patterns for adavanced research of business data. """
def solution(s): answer = True tmp = '' li = [] for c in s: if c == '(': li.append(c) else: if len(li) == 0: return False tmp = li.pop() if tmp == '': return False return len(li) == 0
def solution(s): answer = True tmp = '' li = [] for c in s: if c == '(': li.append(c) else: if len(li) == 0: return False tmp = li.pop() if tmp == '': return False return len(li) == 0
# Created by MechAviv # Violetta's Charming Damage Skin | (2433251) if sm.addDamageSkin(2433251): sm.chat("'Violetta's Charming Damage Skin' Damage Skin has been added to your account's damage skin collection.") sm.consumeItem()
if sm.addDamageSkin(2433251): sm.chat("'Violetta's Charming Damage Skin' Damage Skin has been added to your account's damage skin collection.") sm.consumeItem()
class MultiVariateTrainer: def __init__(self, trainers): self._trainers = trainers def fit(self, parameters, values): for n, trainer in enumerate(self._trainers): trainer.fit(parameters, values[:,n]) @property def models(self): return [trainer.model for trainer in ...
class Multivariatetrainer: def __init__(self, trainers): self._trainers = trainers def fit(self, parameters, values): for (n, trainer) in enumerate(self._trainers): trainer.fit(parameters, values[:, n]) @property def models(self): return [trainer.model for trainer ...
def addTwoNumbers(a, b): return a + b firstNumber = input("What is the first number?") secondNumber = input("What is the second number?") result = addTwoNumbers(firstNumber, secondNumber) print(result) # Why are the two numbers not added correctly? # Example of type casting result = addTwoNumbers(int(firstNumber...
def add_two_numbers(a, b): return a + b first_number = input('What is the first number?') second_number = input('What is the second number?') result = add_two_numbers(firstNumber, secondNumber) print(result) result = add_two_numbers(int(firstNumber), int(secondNumber)) print(result)
# Copyright 2014 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. # A top level slice of a presentation.main thread can cause the webapp to behave # unresponsively if its thread duration is greater than or equals to # USER...
user_perceivable_delay_threshold_ms = 50 class _Mainthreadjankstat(object): """A small wrapper class for storing mainthread jank stats computed for single record. """ def __init__(self): self.sum_big_top_slices_thread_time = 0 self.biggest_top_slice_thread_time = 0 def __compute_mainthrea...
""" binclf clfviz ================================== Utils library to visualize decision trees. Author: Casokaks (https://github.com/Casokaks/) Created on: Nov 1st 2018 """ def xgb_visualize(clf, tree_idx=0, with_stats=False, dump_format='text'): booster = clf.get_booster() dumps = booster.get...
""" binclf clfviz ================================== Utils library to visualize decision trees. Author: Casokaks (https://github.com/Casokaks/) Created on: Nov 1st 2018 """ def xgb_visualize(clf, tree_idx=0, with_stats=False, dump_format='text'): booster = clf.get_booster() dumps = booster.get_dump(with_sta...
subnet_create_payload = { "nickname": "Test Python Subnet" } subnet_update_payload = { "allowed": "LOCKED" }
subnet_create_payload = {'nickname': 'Test Python Subnet'} subnet_update_payload = {'allowed': 'LOCKED'}
def rev_order(s: str): return ' '.join(s.split(' ')[::-1]) def test1(): print(rev_order('Technical Interview Preparation') == 'Preparation Interview Technical') def main(): test1() if __name__ == '__main__': main()
def rev_order(s: str): return ' '.join(s.split(' ')[::-1]) def test1(): print(rev_order('Technical Interview Preparation') == 'Preparation Interview Technical') def main(): test1() if __name__ == '__main__': main()
#Ahmed Mousa: 201601381 #Eman Adel: 201902302 #These functions are for taking file names, reading, writing, and closing files def inputfile(): return input('Enter input file name: ') def openinput(x): return open(x, 'r') def readinput(x): return x.read() def outputfile(): return input('Enter o...
def inputfile(): return input('Enter input file name: ') def openinput(x): return open(x, 'r') def readinput(x): return x.read() def outputfile(): return input('Enter output file name: ') def openoutput(x): return open(x, 'w') def closefile(x): return x.close() def removenew(x): if x =...
#!/usr/bin/env python2 def xutf8len(x): if x < 0x80: return 1 if x < 0x800: return 2 if x < 0x10000: return 3 if x < 0x200000: return 4 if x < 0x4000000: return 5 if x < 0x80000000: return 6 return 7 def enci32(x): if x >= 0: return x return (-x) * 2 + 1 def skipadjust(x): if ...
def xutf8len(x): if x < 128: return 1 if x < 2048: return 2 if x < 65536: return 3 if x < 2097152: return 4 if x < 67108864: return 5 if x < 2147483648: return 6 return 7 def enci32(x): if x >= 0: return x return -x * 2 + 1 de...
#!/usr/bin/env python3 # these are the last few bytes of the file o = [int(x, 16) for x in '70 69 63 6f 43 54 4b 80 6b 35 7a 73 69 64 36 71 5f 65 65 61 65 63 34 38 62 7d'.split(' ')] flag = [] for i in range(5): flag.append(o.pop(0)) for i in range(6, 0xf + 1): flag.append(o.pop(0) - 5) flag.append(o.pop(0...
o = [int(x, 16) for x in '70 69 63 6f 43 54 4b 80 6b 35 7a 73 69 64 36 71 5f 65 65 61 65 63 34 38 62 7d'.split(' ')] flag = [] for i in range(5): flag.append(o.pop(0)) for i in range(6, 15 + 1): flag.append(o.pop(0) - 5) flag.append(o.pop(0) + 3) for i in range(16, 26): flag.append(o.pop(0)) print(bytes(fla...
n = int(input()) for b in range(1, n+1, 3): print(b)
n = int(input()) for b in range(1, n + 1, 3): print(b)
__all__ = ['simulator', 'screen'] __version__ = '0.0' # See also below and setup.py __revision__ = "$Id$" # New software should look at this instead of at __version__ above. version_info = (0, 0, 0, 'experimental', 0) # See also above and setup.py
__all__ = ['simulator', 'screen'] __version__ = '0.0' __revision__ = '$Id$' version_info = (0, 0, 0, 'experimental', 0)
def computepay(h,r): if h <= 40: return h * r else: return ((h-40) * (r * 1.5)) + (40 * r) hrs = float(input("Enter Hours: ")) rs = float(input("Enter Rate: ")) p = computepay(hrs,rs) print("Pay",p)
def computepay(h, r): if h <= 40: return h * r else: return (h - 40) * (r * 1.5) + 40 * r hrs = float(input('Enter Hours: ')) rs = float(input('Enter Rate: ')) p = computepay(hrs, rs) print('Pay', p)
# 374. Guess Number Higher or Lower # ttungl@gmail.com # The guess API is already defined for you. # @param num, your guess # @return -1 if my number is lower, 1 if my number is higher, otherwise return 0 # def guess(num): class Solution(object): def guessNumber(self, n): """ :type n: int ...
class Solution(object): def guess_number(self, n): """ :type n: int :rtype: int """ (left, right) = (1, n) while left + 1 < right: mid = left + (right - left) / 2 x = guess(mid) if x == 0: return mid eli...
N = int(input()) A = list(map(int, input().split())) ans = [0] * N for i in A: ans[i - 1] += 1 for i in ans: print(i)
n = int(input()) a = list(map(int, input().split())) ans = [0] * N for i in A: ans[i - 1] += 1 for i in ans: print(i)
FILE_TYPE_OPTIONS = {} USAGE_RIGHT_OPTIONS = {} ASPECT_RATIO_OPTIONS = {'tall': 't', 'square': 's', 'wide': 'w', 'panoramic': 'xw'} IMAGE_SIZE_OPTIONS = {'any': '', 'icon': 'i', 'medium': 'm', 'large': 'l', 'exactly': 'ex', '400x300+': 'qsvga', '640x480+': 'vga', ...
file_type_options = {} usage_right_options = {} aspect_ratio_options = {'tall': 't', 'square': 's', 'wide': 'w', 'panoramic': 'xw'} image_size_options = {'any': '', 'icon': 'i', 'medium': 'm', 'large': 'l', 'exactly': 'ex', '400x300+': 'qsvga', '640x480+': 'vga', '800x600+': 'svga', '1024x768+': 'xga', '2mp+': '2mp', '...
def cipher(text, shift, encrypt=True): """ Encrypts and decrypts words written using a Caesar cipher, which replaces a letter with another letter a given number of places away in the alphabet. Parameters ---------- text : String The String that should be processed in the function sh...
def cipher(text, shift, encrypt=True): """ Encrypts and decrypts words written using a Caesar cipher, which replaces a letter with another letter a given number of places away in the alphabet. Parameters ---------- text : String The String that should be processed in the function sh...
d={} while True: s=input().split() if s == ["-1"]: break else: id,subject=s[0],s[1:] for sub in subject: if sub not in d: d[sub]={id} else: d[sub].add(id) class1,class2=input().split() if (class1 in d) and (class2 in d): two...
d = {} while True: s = input().split() if s == ['-1']: break else: (id, subject) = (s[0], s[1:]) for sub in subject: if sub not in d: d[sub] = {id} else: d[sub].add(id) (class1, class2) = input().split() if class1 in d and class...
class Solution: # @param A : list of integers # @param B : integer # @return an integer def solve(self, A, B): n = len(A) left = 0 right = n - 1 count = 0 while (left <= right): mid = int((right + left) / 2) # Check if middle element is ...
class Solution: def solve(self, A, B): n = len(A) left = 0 right = n - 1 count = 0 while left <= right: mid = int((right + left) / 2) if A[mid] <= B: count = mid + 1 left = mid + 1 else: righ...
# Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def mergeInBetween(self, list1: ListNode, a: int, b: int, list2: ListNode) -> ListNode: fakeNode = ListNode() fakeNode.next = list1 ...
class Solution: def merge_in_between(self, list1: ListNode, a: int, b: int, list2: ListNode) -> ListNode: fake_node = list_node() fakeNode.next = list1 list1_curr = fakeNode list2_curr = list2 (a_pos, b_pos) = (None, None) temp = 0 while list1Curr.next: ...
''' Given an array of integers arr, return true if and only if it is a valid mountain array. Recall that arr is a mountain array if and only if: arr.length >= 3 There exists some i with 0 < i < arr.length - 1 such that: arr[0] < arr[1] < ... < arr[i - 1] < arr[i] arr[i] > arr[i + 1] > ... > arr[arr.length - 1] Examp...
""" Given an array of integers arr, return true if and only if it is a valid mountain array. Recall that arr is a mountain array if and only if: arr.length >= 3 There exists some i with 0 < i < arr.length - 1 such that: arr[0] < arr[1] < ... < arr[i - 1] < arr[i] arr[i] > arr[i + 1] > ... > arr[arr.length - 1] Examp...
# Choose the GNN architecture between "DeepSet", "GCN", "EdgeNet", "PointNet", "MetaNet" #use_model = "DeepSet" #use_model = "GCN" use_model = "EdgeNet" #use_model = "PointNet" #use_model = "EdgePoint" #use_model = "MetaNet" # Learning rate learning_rate = 0.0006303742576368124 # Weight decay weight_decay = 1.991127...
use_model = 'EdgeNet' learning_rate = 0.0006303742576368124 weight_decay = 1.991127058506617e-08 n_layers = 1 k_nn = 4.86294104668695 n_epochs = 150 training = True simsuite = 'SIMBA' simset = 'CV' n_sims = 27 params = [use_model, learning_rate, weight_decay, n_layers, k_nn, n_epochs, training, simsuite, simset, n_sims...
""" """ load("@bazel_skylib//rules:copy_file.bzl", _copy_file = "copy_file") def path_concat(*args): """Concatenate a list of paths Args: *args: The paths to concatenate. Returns: A path that consists of the individual path segments but concatenated. """ path = "" for arg in args...
""" """ load('@bazel_skylib//rules:copy_file.bzl', _copy_file='copy_file') def path_concat(*args): """Concatenate a list of paths Args: *args: The paths to concatenate. Returns: A path that consists of the individual path segments but concatenated. """ path = '' for arg in args: ...
age = 22 # if age >= 18: # message = "Eligible" # else: # message = "Not eligible" message = "Eligible" if age >= 18 else "Not eligible" print(message)
age = 22 message = 'Eligible' if age >= 18 else 'Not eligible' print(message)
""" Given an array of strings A[], determine if the strings can be chained together to form a circle. A string X can be chained together with another string Y if the last character of X is same as first character of Y. If every string of the array can be chained, it will form a circle. For eg for the array arr[] = {"f...
""" Given an array of strings A[], determine if the strings can be chained together to form a circle. A string X can be chained together with another string Y if the last character of X is same as first character of Y. If every string of the array can be chained, it will form a circle. For eg for the array arr[] = {"f...
"""Given an integer n, return any array containing n unique integers such that they add up to 0. Example 1: Input: n = 5 Output: [-7,-1,1,3,4] Explanation: These arrays also are accepted [-5,-1,1,2,3] , [-3,-1,2,-2,4].""" n = 5 list = [] for i in range(1, (n // 2) + 1): posi = i neg = -1 * i list.appe...
"""Given an integer n, return any array containing n unique integers such that they add up to 0. Example 1: Input: n = 5 Output: [-7,-1,1,3,4] Explanation: These arrays also are accepted [-5,-1,1,2,3] , [-3,-1,2,-2,4].""" n = 5 list = [] for i in range(1, n // 2 + 1): posi = i neg = -1 * i list.append(...
def mult (x,y): return (x*y) def div (x,y): return (x/y)
def mult(x, y): return x * y def div(x, y): return x / y
__author__ = 'Fule Liu' PROTEIN = "ACDEFGHIKLMNPQRSTVWY" DNA = "ACGT" RNA = "ACGU" didna_list = ['Base stacking', 'Protein induced deformability', 'B-DNA twist', 'Dinucleotide GC Content', 'A-philicity', 'Propeller twist', 'Duplex stability:(freeenergy)', 'Duplex tability(disruptenergy)', ...
__author__ = 'Fule Liu' protein = 'ACDEFGHIKLMNPQRSTVWY' dna = 'ACGT' rna = 'ACGU' didna_list = ['Base stacking', 'Protein induced deformability', 'B-DNA twist', 'Dinucleotide GC Content', 'A-philicity', 'Propeller twist', 'Duplex stability:(freeenergy)', 'Duplex tability(disruptenergy)', 'DNA denaturation', 'Bending s...
class Solution: def XXX(self, a: str, b: str) -> str: a, b = a[::-1], b[::-1] if len(a) < len(b): a, b = b, a b += "0" * (len(a) - len(b)) res = "" carrier = 0 for i, j in zip(a, b): cur = (int(i) + int(j) + carrier) % 2 carrier = (...
class Solution: def xxx(self, a: str, b: str) -> str: (a, b) = (a[::-1], b[::-1]) if len(a) < len(b): (a, b) = (b, a) b += '0' * (len(a) - len(b)) res = '' carrier = 0 for (i, j) in zip(a, b): cur = (int(i) + int(j) + carrier) % 2 ...
class Solution: def numDistinct(self, s: str, t: str) -> int: dp = [] dp.append([1] * (len(s) + 1)) for i in range(len(t)): dp.append([0] * (len(s) + 1)) for i in range(1, len(t) + 1): for j in range(1, len(s) + 1): dp[i][j] = dp[i][j-...
class Solution: def num_distinct(self, s: str, t: str) -> int: dp = [] dp.append([1] * (len(s) + 1)) for i in range(len(t)): dp.append([0] * (len(s) + 1)) for i in range(1, len(t) + 1): for j in range(1, len(s) + 1): dp[i][j] = dp[i][j - 1] ...
'''https://leetcode.com/problems/rotate-image/ 48. Rotate Image Medium 6773 413 Add to List Share You are given an n x n 2D matrix representing an image, rotate the image by 90 degrees (clockwise). You have to rotate the image in-place, which means you have to modify the input 2D matrix directly. DO NOT allocate a...
"""https://leetcode.com/problems/rotate-image/ 48. Rotate Image Medium 6773 413 Add to List Share You are given an n x n 2D matrix representing an image, rotate the image by 90 degrees (clockwise). You have to rotate the image in-place, which means you have to modify the input 2D matrix directly. DO NOT allocate a...
file=open("C:\\Users\minjie\Desktop\data_label.txt","r",encoding="utf-8") file1=open("data_test.txt","w",encoding="utf-8") sentence="" label="" sen=[] lab=[] text=[] ignored_words=['!','\"','$','%','\'','(',')','*','+',',','.','..','@','#','&','?','/'] for line in file: line=line.lower() if(line[0]=='\"'): ...
file = open('C:\\Users\\minjie\\Desktop\\data_label.txt', 'r', encoding='utf-8') file1 = open('data_test.txt', 'w', encoding='utf-8') sentence = '' label = '' sen = [] lab = [] text = [] ignored_words = ['!', '"', '$', '%', "'", '(', ')', '*', '+', ',', '.', '..', '@', '#', '&', '?', '/'] for line in file: line = l...
class Assembler: def __init__(self, output_file): self._output_file = output_file def load_register_with_value(self, reg_index, reg_value): opcode = 0x6000 opcode |= ((reg_index & 0xF) << 8) opcode |= (reg_value & 0xFF) self._write_opcode(opcode) def load_font(self...
class Assembler: def __init__(self, output_file): self._output_file = output_file def load_register_with_value(self, reg_index, reg_value): opcode = 24576 opcode |= (reg_index & 15) << 8 opcode |= reg_value & 255 self._write_opcode(opcode) def load_font(self, reg_i...
flag = "rarctf{See,ThatWasn'tSoHard-1eb519ed}" out = [] key = [0x13, 0x37] for c in flag: c = ord(c) out.append((c ^ key[0]) + key[1]) key = key[::-1] # print(', '.join([chr(c) for c in out])) print(', '.join([hex(c) for c in out]))
flag = "rarctf{See,ThatWasn'tSoHard-1eb519ed}" out = [] key = [19, 55] for c in flag: c = ord(c) out.append((c ^ key[0]) + key[1]) key = key[::-1] print(', '.join([hex(c) for c in out]))
''' Statement Given a two-digit integer, print its left digit (a tens digit) and then its right digit (a ones digit). Use the operator of integer division for obtaining the tens digit and the operator of taking remainder for obtaining the ones digit. Example input 79 Example output 7 9 ''' num = int(input()) print(nu...
""" Statement Given a two-digit integer, print its left digit (a tens digit) and then its right digit (a ones digit). Use the operator of integer division for obtaining the tens digit and the operator of taking remainder for obtaining the ones digit. Example input 79 Example output 7 9 """ num = int(input()) print(nu...
class MergeEntry: def __init__(self, log_entry): self.sha1 = '' self.action = '' self.description = '' self.issue = 0 def set_with(self, log_entry): self.sha1 = log_entry[0:8] def extract_substring_surrounded_by(self, char): pass
class Mergeentry: def __init__(self, log_entry): self.sha1 = '' self.action = '' self.description = '' self.issue = 0 def set_with(self, log_entry): self.sha1 = log_entry[0:8] def extract_substring_surrounded_by(self, char): pass
rec={} n=int(input("enter no. of students:")) i=1 while i<=n: name=input("enter student name:") marks=input("enter % of marks of student:") rec[name]=marks i=i+1 print("name of students","\t","% of marks") for x in rec: print("\t",x,"\t\t",rec[x])
rec = {} n = int(input('enter no. of students:')) i = 1 while i <= n: name = input('enter student name:') marks = input('enter % of marks of student:') rec[name] = marks i = i + 1 print('name of students', '\t', '% of marks') for x in rec: print('\t', x, '\t\t', rec[x])
# -*- coding: utf-8 -*- """ Created on Thu Apr 18 14:50:56 2019 @author: ajand """ # Function to sort the words # in ascending order def sortedSentence(Sentence): # Spliting the Sentence into words words = Sentence.split(" ") # Sorting the words words.sort() ...
""" Created on Thu Apr 18 14:50:56 2019 @author: ajand """ def sorted_sentence(Sentence): words = Sentence.split(' ') words.sort() new_sentence = ' '.join(words) return newSentence sentence = 'to learn programming refer geeksforgeeks' print(sorted_sentence(Sentence)) sentence = 'geeks for geeks' print...
# -------------------------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # --------------------------------------------------------------------...
def get_http_request_kwargs(kwargs): http_request_keywords = ['params', 'headers', 'json', 'data', 'files'] http_request_kwargs = {key: kwargs.pop(key, None) for key in http_request_keywords if key in kwargs} return http_request_kwargs
''' * @author: ashwek * @date: 20/12/2018 ''' n = int(input("Enter limit : ")) for i in range(1, n+1): output = "" if i%3 == 0 : output = "Fizz" if i%5 == 0: output += "Buzz" if output : print(output) else: print(i)
""" * @author: ashwek * @date: 20/12/2018 """ n = int(input('Enter limit : ')) for i in range(1, n + 1): output = '' if i % 3 == 0: output = 'Fizz' if i % 5 == 0: output += 'Buzz' if output: print(output) else: print(i)
''' @author: l4zyc0d3r People who are happy makes other happy. I am gonna finish it slowly but definitely.cdt ''' # Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def detectCycle(self, head: ListNode) -> ListNode:...
""" @author: l4zyc0d3r People who are happy makes other happy. I am gonna finish it slowly but definitely.cdt """ class Solution: def detect_cycle(self, head: ListNode) -> ListNode: (sp, fp) = (head, head) while fp and fp.next: sp = sp.next fp = fp.next.next if...
class Vocab: def __init__(self, vocab_path): self.word2id = dict() self.id2word = list() for ln in open(vocab_path): wid, word, freq = ln.strip().split("\t") self.word2id[word] = int(wid) self.id2word.append(word) if len(self.id2word) == 50...
class Vocab: def __init__(self, vocab_path): self.word2id = dict() self.id2word = list() for ln in open(vocab_path): (wid, word, freq) = ln.strip().split('\t') self.word2id[word] = int(wid) self.id2word.append(word) if len(self.id2word) == 500...
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Aug 6 07:54:08 2018 @author: tuheenahmmed """ def calculateHandlen(hand): """ Returns the length (number of letters) in the current hand. hand: dictionary (string-> int) returns: integer """ length =0 for letter in ha...
""" Created on Mon Aug 6 07:54:08 2018 @author: tuheenahmmed """ def calculate_handlen(hand): """ Returns the length (number of letters) in the current hand. hand: dictionary (string-> int) returns: integer """ length = 0 for letter in hand: length += hand[letter] return...
class MaxRetriesExceeded(Exception): pass class HTTPMethodNotFound(Exception): pass
class Maxretriesexceeded(Exception): pass class Httpmethodnotfound(Exception): pass
""" Summary of ``hexagon_grid.py`` ------------------------------ Text-based definition of a SQL function to create a hexagon grid overlay """ def sql_to_make_hex_grid( extent_table: str, epsg: int, output_table_name: str, size: float ): """ This function returns a string wit...
""" Summary of ``hexagon_grid.py`` ------------------------------ Text-based definition of a SQL function to create a hexagon grid overlay """ def sql_to_make_hex_grid(extent_table: str, epsg: int, output_table_name: str, size: float): """ This function returns a string with a valid SQL query that creates ...
test_list = ['NINE', 'Geeky', 'Computers', 'Algorithms'] print ("The original list is : " + str(test_list)) subs = 'ELEPHANTINE ' chars = set('NINE') if any((c in chars) for c in test_list): print('Found') else: print('Not Found')
test_list = ['NINE', 'Geeky', 'Computers', 'Algorithms'] print('The original list is : ' + str(test_list)) subs = 'ELEPHANTINE ' chars = set('NINE') if any((c in chars for c in test_list)): print('Found') else: print('Not Found')
# # @lc app=leetcode.cn id=240 lang=python3 # # [240] search-a-2d-matrix-ii # None # @lc code=end
None
nums = [10,9,2] print(nums) print(nums[0]) print(nums[1]) print(nums[2]) for i in nums: print(i) it = iter(nums) print(it.__next__()) print(it.__next__()) print(it.__next__()) print(next(it)) print(next(it)) print(next(it))
nums = [10, 9, 2] print(nums) print(nums[0]) print(nums[1]) print(nums[2]) for i in nums: print(i) it = iter(nums) print(it.__next__()) print(it.__next__()) print(it.__next__()) print(next(it)) print(next(it)) print(next(it))
# Copyright 2014 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...
load('@io_bazel_rules_go//go/private:common.bzl', 'get_go_toolchain', 'go_exts', 'hdr_exts', 'c_exts', 'asm_exts', 'pkg_dir') load('@io_bazel_rules_go//go/private:library.bzl', 'go_library') load('@io_bazel_rules_go//go/private:binary.bzl', 'c_linker_options') def cgo_genrule(tags=[], **kwargs): return cgo_library...
# test10.py a = _n('a') b = _n('b') root = (a^b)*inv(a^b)
a = _n('a') b = _n('b') root = (a ^ b) * inv(a ^ b)
"""A module defining the third party dependency GMP""" load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") def gmp_repositories(): maybe( http_archive, name = "GMP_lib", build_file = Label("@//third_party/GMP:B...
"""A module defining the third party dependency GMP""" load('@bazel_tools//tools/build_defs/repo:http.bzl', 'http_archive') load('@bazel_tools//tools/build_defs/repo:utils.bzl', 'maybe') def gmp_repositories(): maybe(http_archive, name='GMP_lib', build_file=label('@//third_party/GMP:BUILD.gmp.bazel'), sha256='258e...
# # @lc app=leetcode id=100 lang=python3 # # [100] Same Tree # # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def isSameTree(self, p: TreeNode, q: TreeNode) -> bool: if p is No...
class Solution: def is_same_tree(self, p: TreeNode, q: TreeNode) -> bool: if p is None: return q is None elif q is None: return False else: return p.val == q.val and self.isSameTree(p.left, q.left) and self.isSameTree(p.right, q.right)
L, Q = map(int, input().split()) w = {"0": L} plist = [0] for _ in range(Q): c, x = map(int, input().split()) if c == 1: target_p = None for p in plist: if p < x: target_p = p else: break w[str(x)] = target_p + w[str(target_p)] -...
(l, q) = map(int, input().split()) w = {'0': L} plist = [0] for _ in range(Q): (c, x) = map(int, input().split()) if c == 1: target_p = None for p in plist: if p < x: target_p = p else: break w[str(x)] = target_p + w[str(target_p)] ...
#!/usr/bin/python # ============================================================================== # Author: Tao Li (taoli@ucsd.edu) # Date: May 3, 2015 # Question: 038-Count-and-Say # Link: https://leetcode.com/problems/count-and-say/ # ========================================================================...
class Solution: def count_and_say(self, n): res = str(1) while n > 1: n -= 1 res = self.say(res) return res def say(self, s): if len(s) == 1: return '1' + s last = s[0] new_str = '' counter = 1 for i in s[1:]: ...
def stop(track, pos, start_speed): max_speed = len(track)-1 solutions = {} for posistion in range(len(track)): if track[posistion]: solutions[posistion] = set([0]) for posistion in reversed(range(pos, len(track))): if not track[posistion]: continue ...
def stop(track, pos, start_speed): max_speed = len(track) - 1 solutions = {} for posistion in range(len(track)): if track[posistion]: solutions[posistion] = set([0]) for posistion in reversed(range(pos, len(track))): if not track[posistion]: continue for s...
class level(object): bg = pygame.image.load(os.path.abspath(os.path.join(os.path.dirname(__file__),'images/bg.png'))) def __init__(self,currentpos,levellength): self.currentpos = currentpos self.fulllength = fulllength self.vel = velocity def draw(self, win): ...
class Level(object): bg = pygame.image.load(os.path.abspath(os.path.join(os.path.dirname(__file__), 'images/bg.png'))) def __init__(self, currentpos, levellength): self.currentpos = currentpos self.fulllength = fulllength self.vel = velocity def draw(self, win): win.blit(se...
config_dict = { "out_path": "~/daily_counts.json", "trackers": [ { "name": "Hex.pm (Elixir/Erlang)", "url": "https://hex.pm/packages", "regex": ">(\\d+) Results Found" }, { "name": "DUB (dlang)", "url": "https://code.dlang.org", "regex": "<p>Found (\\d+) packages.<\/...
config_dict = {'out_path': '~/daily_counts.json', 'trackers': [{'name': 'Hex.pm (Elixir/Erlang)', 'url': 'https://hex.pm/packages', 'regex': '>(\\d+) Results Found'}, {'name': 'DUB (dlang)', 'url': 'https://code.dlang.org', 'regex': '<p>Found (\\d+) packages.<\\/p>'}, {'name': 'npm (node.js)', 'url': 'https://skimdb.np...
class Solution: def solve(self, nums, M, K): n = len(nums) r = -99999 for i in range(n - M * K): r = max(r, sum(nums[i: i + M * K + 1: K + 1])) return r def solve2(self, N, R, points): M = len(R) S = len(points) R.sort(reverse=True) p...
class Solution: def solve(self, nums, M, K): n = len(nums) r = -99999 for i in range(n - M * K): r = max(r, sum(nums[i:i + M * K + 1:K + 1])) return r def solve2(self, N, R, points): m = len(R) s = len(points) R.sort(reverse=True) poi...
# This is an example of a comment that Python ignores. Use these to make notes as you write your code. You will also fill out the top comment with any help or resources you use. # Collaborators: (fill this is on every assignment, even if the answer is "none") print('Hello world') name='Keelie' print(f'Hel...
print('Hello world') name = 'Keelie' print(f'Hello {name}') name2 = 'Friends' print(f' Welcome {name} and {name2}') print('What is your favorite period of history?') period_of_history = input() print(f'The {period_of_history} is fascinating!') print('What do you like about The Holy Roman Empire?') what_do_you_like_abou...
# -*- coding: utf-8 -*- """ idfy_rest_client.models.konsern_link This file was automatically generated for Idfy by APIMATIC v2.0 ( https://apimatic.io ) """ class KonsernLink(object): """Implementation of the 'KonsernLink' model. TODO: type model description here. Attributes: ...
""" idfy_rest_client.models.konsern_link This file was automatically generated for Idfy by APIMATIC v2.0 ( https://apimatic.io ) """ class Konsernlink(object): """Implementation of the 'KonsernLink' model. TODO: type model description here. Attributes: orgnr_overste_mor_field (int): TODO...
# Asks for a file name and tries to find it and adds a file extention to the # input name. If it is not found, tell and try again untill it is found def enterFile(): # initialisation notFound = True # while the file isn't found, keep asking for a filename while notFound: # input filename need...
def enter_file(): not_found = True while notFound: file_name = input('Enter the filename here, without the suffux("<enter file suffix here>"): ') file_name += str('<enter file suffix here> (example: ".txt")') try: open(fileName) except FileNotFoundError: p...
expected_output = { "bgp_id": 5918, "vrf": { "L3VPN-1151": { "neighbor": { "192.168.10.253": { "address_family": { "vpnv4": { "activity_paths": "5564978/1540171", "activity_pre...
expected_output = {'bgp_id': 5918, 'vrf': {'L3VPN-1151': {'neighbor': {'192.168.10.253': {'address_family': {'vpnv4': {'activity_paths': '5564978/1540171', 'activity_prefixes': '2722671/700066', 'as': 61100, 'attribute_entries': '5101/4901', 'bgp_table_version': 9370786, 'cache_entries': {'filter-list': {'memory_usage'...
class Solution: def numDifferentIntegers(self, word: str) -> int: s = "".join([char if char.isdigit() else " " for char in word]) return len({int(num) for num in s.split()})
class Solution: def num_different_integers(self, word: str) -> int: s = ''.join([char if char.isdigit() else ' ' for char in word]) return len({int(num) for num in s.split()})
if __name__ == '__main__': print("hello, world")
if __name__ == '__main__': print('hello, world')
''' ATOMIC WEIGHTS OF THE ELEMENTS (2019) from the IUPAC Commission on Isotopic Abundances and Atomic Weights Based on the following reports: - Pure Appl. Chem., 2016, 88, 265-291 (https://doi.org/10.1515/pac-2015-0305) - Chem. Eng. News, 2015, 93(37), 9 (https://doi.org/10.1021/cen-09337-notw9) ...
""" ATOMIC WEIGHTS OF THE ELEMENTS (2019) from the IUPAC Commission on Isotopic Abundances and Atomic Weights Based on the following reports: - Pure Appl. Chem., 2016, 88, 265-291 (https://doi.org/10.1515/pac-2015-0305) - Chem. Eng. News, 2015, 93(37), 9 (https://doi.org/10.1021/cen-09337-notw9) - P...
# -*- coding: utf-8 -*- # @Author: Nate # @Date: 2020-02-20 08:25:21 # @Last Modified by: Nate # @Last Modified time: 2021-12-12 15:54:04 path = 'V:\crawler\manga_crawler\download\cartoonmad'
path = 'V:\\crawler\\manga_crawler\\download\\cartoonmad'
'''Common restriction sites.''' fallback_enzymes = {'AflII': ('CTTAAG', (1, 5)), 'AgeI': ('ACCGGT', (1, 5)), 'BamHI': ('GGATCC', (1, 5)), 'DpnI': ('GATC', (2, 2)), 'DraI': ('TTTAAA', (3, 3)), 'EcoRI': ('GAATTC', (1, 5)...
"""Common restriction sites.""" fallback_enzymes = {'AflII': ('CTTAAG', (1, 5)), 'AgeI': ('ACCGGT', (1, 5)), 'BamHI': ('GGATCC', (1, 5)), 'DpnI': ('GATC', (2, 2)), 'DraI': ('TTTAAA', (3, 3)), 'EcoRI': ('GAATTC', (1, 5)), 'EcoRV': ('GATATC', (3, 3)), 'FokI': ('GGATG', (14, 18)), 'HindIII': ('AAGCTT', (1, 5)), 'NcoI': ('...
def subsets(nums): res = [] dfs(nums, [], res) return res def dfs(nums, path, res): res.append(path) for i in range(len(nums)): dfs(nums[i + 1 :], path + [nums[i]], res) return res def subsets2(nums): res = [[]] for num in sorted(nums): print(res) res += [item...
def subsets(nums): res = [] dfs(nums, [], res) return res def dfs(nums, path, res): res.append(path) for i in range(len(nums)): dfs(nums[i + 1:], path + [nums[i]], res) return res def subsets2(nums): res = [[]] for num in sorted(nums): print(res) res += [item + ...
"""Useful utilities used internally or useful to extensions.""" def tpl_cons(hd, tl): yield hd for x in tl: yield x def contains_ellipsis(idx): if idx is Ellipsis: return True elif isinstance(idx, tuple): for item in idx: if item is Ellipsis: retu...
"""Useful utilities used internally or useful to extensions.""" def tpl_cons(hd, tl): yield hd for x in tl: yield x def contains_ellipsis(idx): if idx is Ellipsis: return True elif isinstance(idx, tuple): for item in idx: if item is Ellipsis: return ...
soma = 0 conta = 0 c = 0 while not c == 999: c = int(input('digite um valor : [ 999 para PARAR ] :')) conta += 1 if c != 999: soma = (soma + c) print('vc digitou {} numeros e a soma entre eles e {}'.format(conta - 1, soma))
soma = 0 conta = 0 c = 0 while not c == 999: c = int(input('digite um valor : [ 999 para PARAR ] :')) conta += 1 if c != 999: soma = soma + c print('vc digitou {} numeros e a soma entre eles e {}'.format(conta - 1, soma))
# -*- encoding: utf-8 -*- # Ref: https://github.com/dissemin/wikiciteparser/blob/master/wikiciteparser/en/__init__.py """ List of citation templates which are going to be extracted """ CITATION_TEMPLATES = set([ 'citation', 'cite arxiv', 'cite av media', 'cite av media notes', 'cite book', 'c...
""" List of citation templates which are going to be extracted """ citation_templates = set(['citation', 'cite arxiv', 'cite av media', 'cite av media notes', 'cite book', 'cite conference', 'cite dvd notes', 'cite encyclopedia', 'cite episode', 'cite interview', 'cite journal', 'cite mailing list', 'cite map', 'cite n...
def logging_detector(funct): def wrapper(*args, **kwargs): print(f'The function called was {funct.__name__}') print('Arguments passed:') for arg in args: print(arg) print(funct(*args)) return wrapper @logging_detector def homer(name, day, rating): return 'HOMER...
def logging_detector(funct): def wrapper(*args, **kwargs): print(f'The function called was {funct.__name__}') print('Arguments passed:') for arg in args: print(arg) print(funct(*args)) return wrapper @logging_detector def homer(name, day, rating): return 'HOMER'...
"""Manages print format for GOEA results.""" __copyright__ = "Copyright (C) 2016-2018, DV Klopfenstein, H Tang, All rights reserved." __author__ = "DV Klopfenstein" # import collections as cx class PrtFmt(object): """Manages print format for GOEA results.""" # Default Excel table column widths for GOEA res...
"""Manages print format for GOEA results.""" __copyright__ = 'Copyright (C) 2016-2018, DV Klopfenstein, H Tang, All rights reserved.' __author__ = 'DV Klopfenstein' class Prtfmt(object): """Manages print format for GOEA results.""" default_fld2col_widths = {'NS': 3, 'GO': 12, 'alt': 2, 'level': 3, 'depth': 3, ...
class Solution: def getModifiedArray(self, length, updates): """ :type length: int :type updates: List[List[int]] :rtype: List[int] """ result=[0] * length for operation in updates: result[operation[0]] = result[operation[0]] + operation[2] ...
class Solution: def get_modified_array(self, length, updates): """ :type length: int :type updates: List[List[int]] :rtype: List[int] """ result = [0] * length for operation in updates: result[operation[0]] = result[operation[0]] + operation[2] ...
real_number = {chr(el) for el in range(ord('0'), ord('9') + 1)} real_number.update(['.', ',']) required_real_number = {'.'} def real_number_is_valid(number): real_number_as_set = set(number) if not number or real_number_as_set - real_number or required_real_number - real_number_as_set: return False ...
real_number = {chr(el) for el in range(ord('0'), ord('9') + 1)} real_number.update(['.', ',']) required_real_number = {'.'} def real_number_is_valid(number): real_number_as_set = set(number) if not number or real_number_as_set - real_number or required_real_number - real_number_as_set: return False ...
#!/usr/bin/env python """ File name: test_CTCI_Ch4_Ex5.py Author: Matt Randazzo Date created: 2/18/2019 Date last modified: 2/18/2019 Python Version: 3.7 Description: CTCI 4.5 Validate BST Implement a function to check if a binary tree is a binary...
""" File name: test_CTCI_Ch4_Ex5.py Author: Matt Randazzo Date created: 2/18/2019 Date last modified: 2/18/2019 Python Version: 3.7 Description: CTCI 4.5 Validate BST Implement a function to check if a binary tree is a binary search tree Clas...
""" A collection of Bootstrap static files. """ __author__ = 'Peter Bittner' __email__ = 'django@bittner.it' __license__ = 'MIT' __url__ = 'https://github.com/bittner/django-bootstrap-static' __version__ = '5.0.0-beta1'
""" A collection of Bootstrap static files. """ __author__ = 'Peter Bittner' __email__ = 'django@bittner.it' __license__ = 'MIT' __url__ = 'https://github.com/bittner/django-bootstrap-static' __version__ = '5.0.0-beta1'
''' Problem: Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists, and should also be sorted. For example, given following linked lists : 5 -> 8 -> 20 4 -> 11 -> 15 The merged list should be : 4 -> 5 -> 8 -> 11 -> 15 -> 2...
""" Problem: Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists, and should also be sorted. For example, given following linked lists : 5 -> 8 -> 20 4 -> 11 -> 15 The merged list should be : 4 -> 5 -> 8 -> 11 -> 15 -> 2...
""" 0426. Convert Binary Search Tree to Sorted Doubly Linked List Medium Convert a Binary Search Tree to a sorted Circular Doubly-Linked List in place. You can think of the left and right pointers as synonymous to the predecessor and successor pointers in a doubly-linked list. For a circular doubly linked list, the p...
""" 0426. Convert Binary Search Tree to Sorted Doubly Linked List Medium Convert a Binary Search Tree to a sorted Circular Doubly-Linked List in place. You can think of the left and right pointers as synonymous to the predecessor and successor pointers in a doubly-linked list. For a circular doubly linked list, the p...
# # @lc app=leetcode id=367 lang=python3 # # [367] Valid Perfect Square # # @lc code=start class Solution: def isPerfectSquare(self, num): cur = 1 while True: multi = cur * cur if multi > num: return False if multi == num: return T...
class Solution: def is_perfect_square(self, num): cur = 1 while True: multi = cur * cur if multi > num: return False if multi == num: return True cur += 1
# Convert Integer to the Sum of Two No-Zero Integers # # Source - https://leetcode.com/problems/convert-integer-to-the-sum-of-two-no-zero-integers/ class Solution: def getNoZeroIntegers(self, n): for a in range(n): if '0' not in f'{a}{n - a}': return [a, n - a] s = Solution()....
class Solution: def get_no_zero_integers(self, n): for a in range(n): if '0' not in f'{a}{n - a}': return [a, n - a] s = solution().getNoZeroIntegers(11) print(s)
#class Solution: # def chalkReplacer(self, chalk: List[int], k: int) -> int: def chalkReplacer(chalk, k): # loop thru the list `chalk` one time first, # to know its sum. somme = 0 for i, n_i in enumerate(chalk): k -= n_i if k < 0: return i somme += n_i ...
def chalk_replacer(chalk, k): somme = 0 for (i, n_i) in enumerate(chalk): k -= n_i if k < 0: return i somme += n_i k %= somme for (i, n_i) in enumerate(chalk): k -= n_i if k < 0: return i def test(chalk, k, expected): sol = chalk_repla...
# Copyright The OpenTelemetry 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 in ...
""" The **OpenTelemetry Collector Exporter** allows to export OpenTelemetry traces to OpenTelemetry Collector. .. code:: python from opentelemetry import trace from opentelemetry.ext.otcollector.trace_exporter import CollectorSpanExporter from opentelemetry.sdk.trace import TracerProvider from opente...
ENTRY_POINT = 'match_parens' FIX = """ Fix the bug of in solution which considers )( )( as valid. Add test case for above. """ #[PROMPT] def match_parens(lst): ''' You are given a list of two strings, both strings consist of open parentheses '(' or close parentheses ')' only. Your job is to check if ...
entry_point = 'match_parens' fix = '\nFix the bug of in solution which considers )( )( as valid.\nAdd test case for above.\n' def match_parens(lst): """ You are given a list of two strings, both strings consist of open parentheses '(' or close parentheses ')' only. Your job is to check if it is possibl...