content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
t = 0 def calc(n): p = 0 for j in range(1, n): if n % j == 0: p += j q = 0 for j in range(1, p): if p % j == 0: q += j if n == q and n != p: return n else: return 0 for i in range(1, 10001): t += calc(i) print (t)
t = 0 def calc(n): p = 0 for j in range(1, n): if n % j == 0: p += j q = 0 for j in range(1, p): if p % j == 0: q += j if n == q and n != p: return n else: return 0 for i in range(1, 10001): t += calc(i) print(t)
# @author Huaze Shen # @date 2020-01-15 class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None def max_depth(root): if root is None: return 0 return max(max_depth(root.left), max_depth(root.right)) + 1 if __name__ == '__main__': root_...
class Treenode: def __init__(self, x): self.val = x self.left = None self.right = None def max_depth(root): if root is None: return 0 return max(max_depth(root.left), max_depth(root.right)) + 1 if __name__ == '__main__': root_ = tree_node(3) root_.left = tree_node(9...
class Solution: def mySqrt(self, x: int) -> int: lo = 0 hi = 2 while hi ** 2 <= x: lo = hi hi *= 2 while hi - lo > 1: mid = (hi + lo) // 2 if mid ** 2 <= x: lo = mid else: hi = mid ret...
class Solution: def my_sqrt(self, x: int) -> int: lo = 0 hi = 2 while hi ** 2 <= x: lo = hi hi *= 2 while hi - lo > 1: mid = (hi + lo) // 2 if mid ** 2 <= x: lo = mid else: hi = mid r...
""" 1. Clarification 2. Possible solutions - mod - log2 - bit manipulation (2 versions): get the rightmost 1-bit in n: x & (-x) set the rightmost 1-bit to 0-bit in n: x & (x - 1) 3. Coding 4. Tests """ # T=O(lgn), S=O(1) class Solution: def isPowerOfTwo(self, n: int) -> bool: i...
""" 1. Clarification 2. Possible solutions - mod - log2 - bit manipulation (2 versions): get the rightmost 1-bit in n: x & (-x) set the rightmost 1-bit to 0-bit in n: x & (x - 1) 3. Coding 4. Tests """ class Solution: def is_power_of_two(self, n: int) -> bool: if n <= 0: ...
#!usr/bin/python # -*- coding:utf8 -*- """ you can tell your celery instance to user a configuration module by calling the app.config_from_object() method """ broker_url = 'redis://127.0.0.1:6379/3' result_backend = 'redis://127.0.0.1:6379/0' task_serializer = 'json' result_serializer = 'json'
""" you can tell your celery instance to user a configuration module by calling the app.config_from_object() method """ broker_url = 'redis://127.0.0.1:6379/3' result_backend = 'redis://127.0.0.1:6379/0' task_serializer = 'json' result_serializer = 'json'
#encoding=utf-8 # appexceptions.py # This file is part of PSR Registration Shuffler # # Copyright (C) 2008 - Dennis Schulmeister <dennis -at- ncc-1701a.homelinux.net> # # This is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Soft...
""" PURPOSE ======= This module provides all exceptions known in the main (psrregshuffle) package. """ __all__ = ['ClassIsSingleton', 'NoClassObject', 'NoClassFound', 'NoFileGiven', 'InvalidExportClass', 'Cancel'] class Exceptionwithmessage(Exception): """ This is a super-class for all self-defined exceptions...
# Copyright 2019 Quantapix 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 l...
class Converter: by_name = {} @classmethod def convert(cls, src, **kw): return cls.by_name[type(src).__name__].convert(src, **kw) def __init__(self, name): self.name = name def __call__(self, cls): self.by_name[self.name] = cls return cls class With_Current: ...
students = [ {'name': 'fred', 'age': 29}, {'name': 'jim', 'age': 34}, {'name': 'alice', 'age': 12} ] students = sorted(students, key=lambda x: x['age']) #print(students) students = [ {'name': 'fred', 'dob': '1961-08-12'}, {'name': 'jim', 'dob': '1972-01-12'}, {'name': 'alice', 'dob': '1949-01-01'}, {'name': 'bob', '...
students = [{'name': 'fred', 'age': 29}, {'name': 'jim', 'age': 34}, {'name': 'alice', 'age': 12}] students = sorted(students, key=lambda x: x['age']) students = [{'name': 'fred', 'dob': '1961-08-12'}, {'name': 'jim', 'dob': '1972-01-12'}, {'name': 'alice', 'dob': '1949-01-01'}, {'name': 'bob', 'dob': '1931-12-25'}] st...
class Solution: def orangesRotting(self, grid: List[List[int]]) -> int: minutes = 0 mark = [] nonRotten = 0 for i, row in enumerate(grid): for j, r in enumerate(row): if r == 2: # Rotten mark.append((i,j)) ...
class Solution: def oranges_rotting(self, grid: List[List[int]]) -> int: minutes = 0 mark = [] non_rotten = 0 for (i, row) in enumerate(grid): for (j, r) in enumerate(row): if r == 2: mark.append((i, j)) elif r == 1: ...
# # PySNMP MIB module Q-BRIDGE-MIB (http://pysnmp.sf.net) # ASN.1 source http://mibs.snmplabs.com:80/asn1/Q-BRIDGE-MIB # Produced by pysmi-0.0.7 at Fri Feb 17 12:48:35 2017 # On host 5641388e757d platform Linux version 4.4.0-62-generic by user root # Using Python version 2.7.13 (default, Dec 22 2016, 09:22:15) # ( Int...
(integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_union, single_value_constraint, constraints_intersection, value_size_constraint, value_range_constraint) ...
# Copyright 2017 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. ######################################################## # NOTE: THIS FILE IS GENERATED. DO NOT EDIT IT! # # Instead, run create_include_gyp.py to reg...
{'targets': [{'target_name': 'app_window_common', 'includes': ['../../../third_party/closure_compiler/include_js.gypi']}, {'target_name': 'audio_player_foreground', 'includes': ['../../../third_party/closure_compiler/include_js.gypi']}, {'target_name': 'background_window', 'includes': ['../../../third_party/closure_com...
# Python Program To Apply Two Decorator To The Same Function Using @ Symbol ''' Function Name : Apply 2 Decorator To Same Function Using @. Function Date : 9 Sep 2020 Function Author : Prasad Dangare Input : Integer Output : Integer ''' def decor(fun): def inner(): ...
""" Function Name : Apply 2 Decorator To Same Function Using @. Function Date : 9 Sep 2020 Function Author : Prasad Dangare Input : Integer Output : Integer """ def decor(fun): def inner(): value = fun() return value + 2 return inner def decor1(fun): def...
#! /usr/bin/python3 # LCS using dynamic programming recursive method def lcsRecursion(seq1,seq2,m,n): if m == 0 or n == 0: return 0 else: if seq1[m-1] == seq2[n-1]: return 1 + lcsRecursion(seq1,seq2,m-1,n-1) else: return (max(lcsRecursion(seq1,seq2,m-1,n),lcsRecursion(seq1,seq2,m,n-1))) seq...
def lcs_recursion(seq1, seq2, m, n): if m == 0 or n == 0: return 0 elif seq1[m - 1] == seq2[n - 1]: return 1 + lcs_recursion(seq1, seq2, m - 1, n - 1) else: return max(lcs_recursion(seq1, seq2, m - 1, n), lcs_recursion(seq1, seq2, m, n - 1)) seq1 = ['a', 'c', 't', 'g', 'g', 'a', 'c',...
# def conv(x): # if x == 'R': # return [0,1] # elif x == 'L': # return [0,-1] # elif x == 'U': # return [-1, 0] # elif x == 'D': # return [1,0] # h, w, n = map(int, input().split()) # sr, sc = map(int, input().split()) # s = list(map(lambda x: conv(x), list(input()))) # t = list(map(lambda x: c...
(h, w, n) = map(int, input().split()) (sr, sc) = map(int, input().split()) s = input() t = input() wr = sc wl = sc hu = sr hd = sr def taka(k, wr, wl, hu, hd): if k == 'U': hu -= 1 if k == 'D': hd += 1 if k == 'R': wr += 1 if k == 'L': wl -= 1 return (wr, wl, hu, hd)...
### # Copyright (c) 2002-2005, Jeremiah Fincher # Copyright (c) 2010-2021, Valentin Lorentz # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # * Redistributions of source code must retain the a...
""" ansi.py ANSI Terminal Interface Color Usage: print RED + 'this is red' + RESET print BOLD + GREEN + WHITEBG + 'this is bold green on white' + RESET def move(new_x, new_y): 'Move cursor to new_x, new_y' def moveUp(lines): 'Move cursor up # of lines' def moveDown(lines): 'Move cursor down # of lines' de...
class Graph: def __init__(self): self.edges = {} def neighbors(self, node_id): return self.edges[node_id]
class Graph: def __init__(self): self.edges = {} def neighbors(self, node_id): return self.edges[node_id]
numdays = int(input('Number of worked days in a month: ')) # 8 is the number of hours worked by day and 25 is the gain per hour gainperday = 25*8 salary = numdays*gainperday print('The employee has worked {} days in the last month.' .format(numdays)) print('The value that he will receive is R${:.2f}.'.format((sal...
numdays = int(input('Number of worked days in a month: ')) gainperday = 25 * 8 salary = numdays * gainperday print('The employee has worked {} days in the last month.'.format(numdays)) print('The value that he will receive is R${:.2f}.'.format(salary))
class Orange: priceOfOranges = 5 stock = 30 def __init__(self, quantityToBuy): self.quantityToBuy = quantityToBuy def OrangeSelling(self): if int(self.quantityToBuy) > Orange.stock: print("We do not have enough oranges, Please select a lesser quantity.") else: ...
class Orange: price_of_oranges = 5 stock = 30 def __init__(self, quantityToBuy): self.quantityToBuy = quantityToBuy def orange_selling(self): if int(self.quantityToBuy) > Orange.stock: print('We do not have enough oranges, Please select a lesser quantity.') else: ...
species_ids =set([str(i) for i in [882,1148,3055,3702,4081,4577,4896,4932,5061,5691,5833,6239,7165,7227,7460,7955,8364,9031,9598,9606,9615,9796,9823,9913,10090,10116,39947,44689,64091,83332,85962,99287,122586,158878,160490,169963,192222,198214,208964,211586,214092,214684,224308,226186,243159,260799,267671,272623,272624...
species_ids = set([str(i) for i in [882, 1148, 3055, 3702, 4081, 4577, 4896, 4932, 5061, 5691, 5833, 6239, 7165, 7227, 7460, 7955, 8364, 9031, 9598, 9606, 9615, 9796, 9823, 9913, 10090, 10116, 39947, 44689, 64091, 83332, 85962, 99287, 122586, 158878, 160490, 169963, 192222, 198214, 208964, 211586, 214092, 214684, 22430...
""" Class to help with key entry less typos """ class MTKeys: """class to enumerate keys used in module""" data = "data" date = "date" # TVMaze tvmaze = "tvmaze" summary = "summary" name = "name" url = "url" image = "image" medium = "medium" original = "original" idOf...
""" Class to help with key entry less typos """ class Mtkeys: """class to enumerate keys used in module""" data = 'data' date = 'date' tvmaze = 'tvmaze' summary = 'summary' name = 'name' url = 'url' image = 'image' medium = 'medium' original = 'original' id_of_media = 'id' ...
# 8. Write a Python function that takes a list and returns a new list with unique elements of the first list. def unique(s): a = [] for i in s: if i not in a: a.append(i) else: pass return a print (unique([1,2,3,3,3,3,4,5]))
def unique(s): a = [] for i in s: if i not in a: a.append(i) else: pass return a print(unique([1, 2, 3, 3, 3, 3, 4, 5]))
''' This one works (Remember, a negative number multiplied by another negative number returns a positive number) ''' def solution(A): #sort the contents of A #find maxy1 by multiplying last three elements of sortedA #find maxy2 by multiplying first two elements of sortedA with the last element of sortedA ...
""" This one works (Remember, a negative number multiplied by another negative number returns a positive number) """ def solution(A): sorty = sorted(A) leny = len(sorty) maxy1 = sorty[leny - 1] * sorty[leny - 2] * sorty[leny - 3] maxy2 = sorty[0] * sorty[1] * sorty[leny - 1] maxy = max(maxy1, maxy...
string = 'this is a string with spaces' splits = [] pos = -1 last_pos = -1 while ' ' in string[pos + 1:]: pos = string.index(' ', pos + 1) splits.append(string[last_pos + 1:pos]) last_pos = pos splits.append(string[last_pos + 1:]) print(splits)
string = 'this is a string with spaces' splits = [] pos = -1 last_pos = -1 while ' ' in string[pos + 1:]: pos = string.index(' ', pos + 1) splits.append(string[last_pos + 1:pos]) last_pos = pos splits.append(string[last_pos + 1:]) print(splits)
countObjects, countVarinCallers = map(int, input().split()) if countVarinCallers <= 2: ans = 2 + countObjects + countObjects * countVarinCallers else: ans = 2 + countObjects + countObjects * countVarinCallers + countObjects * countVarinCallers* (countVarinCallers-1) // 2 print(ans)
(count_objects, count_varin_callers) = map(int, input().split()) if countVarinCallers <= 2: ans = 2 + countObjects + countObjects * countVarinCallers else: ans = 2 + countObjects + countObjects * countVarinCallers + countObjects * countVarinCallers * (countVarinCallers - 1) // 2 print(ans)
class MyClass: __var2 = 'var2' var3 = 'var3' def __init__(self): self.__var1 = 'var1' def normal_method(self): print(self.__var1) @classmethod def class_method(cls): print(cls.__var2) def my_method(self): print(self.__var1) print(self.__var2) ...
class Myclass: __var2 = 'var2' var3 = 'var3' def __init__(self): self.__var1 = 'var1' def normal_method(self): print(self.__var1) @classmethod def class_method(cls): print(cls.__var2) def my_method(self): print(self.__var1) print(self.__var2) ...
# Copyright 2016 Google 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,...
"""Web Test rules for Java.""" load('//web/internal:wrap_web_test_suite.bzl', 'wrap_web_test_suite') def java_web_test_suite(name, java_test_tags=None, test_class=None, **kwargs): """Defines a test_suite of web_test targets that wrap a java_test target. Args: name: The base name of the test. j...
class UpdateBag: """ Contains all the information that needs to passed between the Game and GUI class. """ def __init__(self, removals, bonuses, additions, movements, ice_removed, medals_removed, info, state=()): self.removals = removals self.bonuses = bonuses self.additions...
class Updatebag: """ Contains all the information that needs to passed between the Game and GUI class. """ def __init__(self, removals, bonuses, additions, movements, ice_removed, medals_removed, info, state=()): self.removals = removals self.bonuses = bonuses self.additions...
print('Welcome to the first interview!') print('Please enter your typing speed!') #get user typing speed typing_speed=int(input()) if typing_speed>60: print('Congratulation') print('You passed the first interview') print('The company will contact you') print('Later regarding the second interview') el...
print('Welcome to the first interview!') print('Please enter your typing speed!') typing_speed = int(input()) if typing_speed > 60: print('Congratulation') print('You passed the first interview') print('The company will contact you') print('Later regarding the second interview') else: print('Sorry')...
class Solution: def insert_list(self, head): stack = [] while(head): stack.append(head.val) head = head.next return stack def isPalindrome(self, head: ListNode) -> bool: if head == None: return True reverse_stack = self.insert_list...
class Solution: def insert_list(self, head): stack = [] while head: stack.append(head.val) head = head.next return stack def is_palindrome(self, head: ListNode) -> bool: if head == None: return True reverse_stack = self.insert_list(he...
# -*- coding: utf-8 -*- def comp_axes(self, output): """Compute axes used for the Structural module Parameters ---------- self : Structural a Structural object output : Output an Output object (to update) """ output.struct.Time = output.mag.Time # output.struct.Nt_tot...
def comp_axes(self, output): """Compute axes used for the Structural module Parameters ---------- self : Structural a Structural object output : Output an Output object (to update) """ output.struct.Time = output.mag.Time output.struct.Angle = output.mag.Angle
class Solution: def checker(self, s,l,r): while l >= 0 and r < len(s) and s[l] == s[r]: l -= 1 r += 1 return s[l+1:r] def longest_palindromic(self, s: str) -> str: maximum = " " for i in range(len(s)): case_1 = self.checker(s, ...
class Solution: def checker(self, s, l, r): while l >= 0 and r < len(s) and (s[l] == s[r]): l -= 1 r += 1 return s[l + 1:r] def longest_palindromic(self, s: str) -> str: maximum = ' ' for i in range(len(s)): case_1 = self.checker(s, i, i) ...
def usermail(user): """ Created: 2019-01-21 11:09:48 Aim: Change the destination of onsuccess email according to username. """ d={} paths = glob.glob('../mw*/src/snakemake/tables/email*.tsv') #paths.extend(glob.glob('inp/*/src/snakemake/tables/email*.tsv')) #print(paths) ...
def usermail(user): """ Created: 2019-01-21 11:09:48 Aim: Change the destination of onsuccess email according to username. """ d = {} paths = glob.glob('../mw*/src/snakemake/tables/email*.tsv') for path in paths: fp = open(path) rdr = csv.DictReader(filter(lam...
"""Copy one or more files to nodes in a cluster of systems""" __author__ = "Khosrow Ebrahimpour" __version__ = "0.1.2" __license__ = "MIT"
"""Copy one or more files to nodes in a cluster of systems""" __author__ = 'Khosrow Ebrahimpour' __version__ = '0.1.2' __license__ = 'MIT'
SKIPPER = 1096000 REITING = 1096001 if sm.sendAskYesNo("Would you like to skip the intro?"): sm.completeQuestNoRewards(2568) if sm.getChr().getLevel() < 10: sm.addLevel(10 - sm.getChr().getLevel()) sm.warp(912060500) sm.dispose() sm.lockInGameUI(True) sm.curNodeEventEnd(True) sm.forcedInput(0)...
skipper = 1096000 reiting = 1096001 if sm.sendAskYesNo('Would you like to skip the intro?'): sm.completeQuestNoRewards(2568) if sm.getChr().getLevel() < 10: sm.addLevel(10 - sm.getChr().getLevel()) sm.warp(912060500) sm.dispose() sm.lockInGameUI(True) sm.curNodeEventEnd(True) sm.forcedInput(0) s...
apiAttachAvailable = u'API\u53ef\u7528' apiAttachNotAvailable = u'\u7121\u6cd5\u4f7f\u7528' apiAttachPendingAuthorization = u'\u7b49\u5f85\u6388\u6b0a' apiAttachRefused = u'\u88ab\u62d2' apiAttachSuccess = u'\u6210\u529f' apiAttachUnknown = u'\u4e0d\u660e' budDeletedFriend = u'\u5df2\u5f9e\u670b\u53cb\u540d\u55ae\u522a...
api_attach_available = u'API可用' api_attach_not_available = u'無法使用' api_attach_pending_authorization = u'等待授權' api_attach_refused = u'被拒' api_attach_success = u'成功' api_attach_unknown = u'不明' bud_deleted_friend = u'已從朋友名單刪除' bud_friend = u'朋友' bud_never_been_friend = u'從未列入朋友名單' bud_pending_authorization = u'等待授權' bud_u...
def main(): N = int(input()) ans = 0 for i in range(1, N + 1): if '7' in str(i): continue if '7' in oct(i): continue ans += 1 print(ans) if __name__ == "__main__": main()
def main(): n = int(input()) ans = 0 for i in range(1, N + 1): if '7' in str(i): continue if '7' in oct(i): continue ans += 1 print(ans) if __name__ == '__main__': main()
# Part 1 data = open('data/day2.txt') x = 0 y = 0 for line in data: curr = line.strip().split() if curr[0] == "forward": x += int(curr[1]) elif curr[0] == "up": y -= int(curr[1]) else: y += int(curr[1]) print(x*y) # Part 2 data = open('data/day2.txt') x = 0 y = 0 aim = 0 for li...
data = open('data/day2.txt') x = 0 y = 0 for line in data: curr = line.strip().split() if curr[0] == 'forward': x += int(curr[1]) elif curr[0] == 'up': y -= int(curr[1]) else: y += int(curr[1]) print(x * y) data = open('data/day2.txt') x = 0 y = 0 aim = 0 for line in data: cu...
def docs(**kwargs): """ Annotate the decorated view function with the specified Swagger attributes. Usage: .. code-block:: python from aiohttp import web @docs(tags=['my_tag'], summary='Test method summary', description='Test method description', ...
def docs(**kwargs): """ Annotate the decorated view function with the specified Swagger attributes. Usage: .. code-block:: python from aiohttp import web @docs(tags=['my_tag'], summary='Test method summary', description='Test method description', ...
def add_num(num_1, num_2): result = num_1 + num_2 return result print(add_num(2, 3))
def add_num(num_1, num_2): result = num_1 + num_2 return result print(add_num(2, 3))
""" Description In selection sort we start by finding the minimum value in a given list and move it to a sorted list. Then we repeat the process for each of the remaining elements in the unsorted list. The next element entering the sorted list is compared with the existing elements and placed at its correct position...
""" Description In selection sort we start by finding the minimum value in a given list and move it to a sorted list. Then we repeat the process for each of the remaining elements in the unsorted list. The next element entering the sorted list is compared with the existing elements and placed at its correct position...
""" Given an array of 2n integers, your task is to group these integers into n pairs of integer, say (a1, b1), (a2, b2), ..., (an, bn) which makes sum of min(ai, bi) for all i from 1 to n as large as possible. Example 1: Input: [1,4,3,2] Output: 4 Explanation: n is 2, and the maximum sum of pairs is 4 = min(1, 2) + m...
""" Given an array of 2n integers, your task is to group these integers into n pairs of integer, say (a1, b1), (a2, b2), ..., (an, bn) which makes sum of min(ai, bi) for all i from 1 to n as large as possible. Example 1: Input: [1,4,3,2] Output: 4 Explanation: n is 2, and the maximum sum of pairs is 4 = min(1, 2) + m...
# # PySNMP MIB module GDC-SC553-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/GDC-SC553-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 19:05:21 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 201...
(octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (single_value_constraint, value_range_constraint, constraints_union, constraints_intersection, value_size_constraint) ...
class PedidoNotFoundException(Exception): pass class RequiredDataException(Exception): pass
class Pedidonotfoundexception(Exception): pass class Requireddataexception(Exception): pass
PADDLE_WIDTH = 20 PADDLE_HEIGHT = 90 AI_PADDLE_MAX_SPEED = 20 PADDLE_SPEED_SCALING = 0.6 PADDLE_MAX_SPEED = None BALL_X_SPEED = 12 BALL_BOUNCE_ON_PADDLE_SCALE = 0.40
paddle_width = 20 paddle_height = 90 ai_paddle_max_speed = 20 paddle_speed_scaling = 0.6 paddle_max_speed = None ball_x_speed = 12 ball_bounce_on_paddle_scale = 0.4
class UserAgents: @staticmethod def mac(): return 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36' @staticmethod def android(): return 'Mozilla/5.0 (Linux; Android 11; IN2021) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.210 M...
class Useragents: @staticmethod def mac(): return 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36' @staticmethod def android(): return 'Mozilla/5.0 (Linux; Android 11; IN2021) AppleWebKit/537.36 (KHTML, like Geck...
#views.py class CustomerServieViews(object): def customer_service(self, request): if request.user.is_anonymous(): return HttpResponseRedirect('/accounts/login') try: customer_service = models.Customer_Service.objects.get(pk=models.Customer_Service.objects.all()[0].id) except: customer_service = models....
class Customerservieviews(object): def customer_service(self, request): if request.user.is_anonymous(): return http_response_redirect('/accounts/login') try: customer_service = models.Customer_Service.objects.get(pk=models.Customer_Service.objects.all()[0].id) except...
""" Given an array where elements are sorted in ascending order, convert it to a height balanced BST. """ # Definition for a binary tree node # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: # @param num, a list of integ...
""" Given an array where elements are sorted in ascending order, convert it to a height balanced BST. """ class Solution: def sorted_array_to_bst(self, num): if num == None or len(num) == 0: return None return self.sortedArrayToBSTHelper(num, 0, len(num) - 1) def sorted_array_to...
#!/usr/bin/env python # -*- coding: utf-8 -*- """ __init__.py ~~~~~~~~~~~ A set of tools for lawyers :copyright: (c) 2021 by Law Engineering Systems SRL. :license: see LICENSE for more details. """ __title__ = 'lawyertools' __version__ = '0.0.1' __author__ = 'Biagio Distefano'
""" __init__.py ~~~~~~~~~~~ A set of tools for lawyers :copyright: (c) 2021 by Law Engineering Systems SRL. :license: see LICENSE for more details. """ __title__ = 'lawyertools' __version__ = '0.0.1' __author__ = 'Biagio Distefano'
#A number of stamps can be divided incrementally amongst people if the #number of stamps is equal to or exceeds the sum of the range from [1,N] def divideStamps(N, stamps): stamp_count = 0 total_per_person = 0 #Count number of stamps for i in range(len(stamps)): stamp_count += stamps[i] ...
def divide_stamps(N, stamps): stamp_count = 0 total_per_person = 0 for i in range(len(stamps)): stamp_count += stamps[i] for i in range(N): total_per_person += i if stamp_count >= total_per_person: return 'YES' return 'NO'
class Solution: def missingNumber(self, nums: List[int]) -> int: return self.missingNumberUsingSum(nums) def missingNumberUsingXOR(self, nums: List[int]) -> int: sum = 0 for i in range(0, len(nums) + 1): sum = sum ^ i for n in nums: ...
class Solution: def missing_number(self, nums: List[int]) -> int: return self.missingNumberUsingSum(nums) def missing_number_using_xor(self, nums: List[int]) -> int: sum = 0 for i in range(0, len(nums) + 1): sum = sum ^ i for n in nums: sum = sum ^ n ...
PER_PAGE = 15 RECENT_BOOK_COUNT = 30 BEANS_UPLOAD_ONE_BOOK = 0.5
per_page = 15 recent_book_count = 30 beans_upload_one_book = 0.5
# automatically generated by the FlatBuffers compiler, do not modify # namespace: apemodefb class ERotationOrderFb(object): EulerXYZ = 0 EulerXZY = 1 EulerYZX = 2 EulerYXZ = 3 EulerZXY = 4 EulerZYX = 5 EulerSphericXYZ = 6
class Erotationorderfb(object): euler_xyz = 0 euler_xzy = 1 euler_yzx = 2 euler_yxz = 3 euler_zxy = 4 euler_zyx = 5 euler_spheric_xyz = 6
class Template(object): def __init__(self, content): self._content = content @property def id(self): return self._content.get('id') @property def name(self): return self._content.get('name') @property def is_default(self): return self._content.get('is_defau...
class Template(object): def __init__(self, content): self._content = content @property def id(self): return self._content.get('id') @property def name(self): return self._content.get('name') @property def is_default(self): return self._content.get('is_defa...
incoming_dragons = int(input()) dragons_den = {} while incoming_dragons: dragon_spawn = input() # {type} {name} {damage} {health} {armor} rarity, name, damage, health, armor = dragon_spawn.split(" ") # default values: health 250, damage 45, and armor 10 if damage == "null": damage = "45" ...
incoming_dragons = int(input()) dragons_den = {} while incoming_dragons: dragon_spawn = input() (rarity, name, damage, health, armor) = dragon_spawn.split(' ') if damage == 'null': damage = '45' damage = int(damage) if health == 'null': health = '250' health = int(health) if ...
expected_output = { 'pid': 'WS-C3850-24P', 'os': 'iosxe', 'platform': 'cat3k_caa', 'version': '16.4.20170410:165034', }
expected_output = {'pid': 'WS-C3850-24P', 'os': 'iosxe', 'platform': 'cat3k_caa', 'version': '16.4.20170410:165034'}
# ' % kmergrammar # ' % Maria Katherine Mejia Guerra mm2842 # ' % 15th May 2017 # ' # Introduction # ' Some of the code below is under active development # ' ## Required libraries # + name = 'import_libraries', echo=False # + name= 'create_matrices', echo=False def create_matrices(): """ Parameters -----...
def create_matrices(): """ Parameters ---------- Return ---------- """ return '' def create_labels(): """ Parameters ---------- Return ---------- """ return ''
class Node: def __init__(self, k, v): self.k = k self.v = v self.pre = None self.nxt = None class LRUCache: def __init__(self, cap): self.mp = dict() self.cap = cap self.head = Node(0, 0) self.tail = Node(0, 0) self.head.nxt = self.tail ...
class Node: def __init__(self, k, v): self.k = k self.v = v self.pre = None self.nxt = None class Lrucache: def __init__(self, cap): self.mp = dict() self.cap = cap self.head = node(0, 0) self.tail = node(0, 0) self.head.nxt = self.tail ...
# 2020.01.15 # Sorry, was not in good mood yesterday # Problem Statement: # https://leetcode.com/problems/convert-sorted-list-to-binary-search-tree/ # Almost the same question as question 108, adding a convertion of linked list to array # Definition for singly-linked list. # class ListNode: # def __init__(self, va...
class Solution: def sorted_list_to_bst(self, head: ListNode) -> TreeNode: if not head: return None nums = self.linkedList2Array(head) middle = int(len(nums) / 2) self.root = tree_node(nums[middle]) self.sortedArrayToBSTHelper(nums, self.root) return self....
#WAP to accept a string from user and perform verbing operation on it. #String should be greater than or equal to 3, else leave unedited #if string ends with 'ing', replace 'ing' with 'ly' #add 'ing' if not present inputStr = input('Enter a string : ') result = '' if len(inputStr) >= 3: if inputStr.endswith('...
input_str = input('Enter a string : ') result = '' if len(inputStr) >= 3: if inputStr.endswith('ing'): result = inputStr.replace('ing', 'ly') else: result = inputStr + 'ing' else: result = inputStr print(result)
@profile def mean(nums): top = sum(nums) bot = len(nums) return float(top) / float(bot) if __name__ == "__main__": a_list = [1, 2, 3, 4, 5, 6, 10, 100] result = mean(a_list) print(result)
@profile def mean(nums): top = sum(nums) bot = len(nums) return float(top) / float(bot) if __name__ == '__main__': a_list = [1, 2, 3, 4, 5, 6, 10, 100] result = mean(a_list) print(result)
d, m, a = [int(x) for x in input().split()] t = (d % 5) + 3 mat = [] for i in range(t): mat.append([0 for x in range(t)]) mat[0][0] = a mat[0][1] = m mat[1][0] = d p = 2 for i in range(2, t): mat[0][i] = mat[0][i-1] + p mat[i][0] = mat[i-1][0] + p p += 1 for i in range(1, t): for j in range(1, t): ...
(d, m, a) = [int(x) for x in input().split()] t = d % 5 + 3 mat = [] for i in range(t): mat.append([0 for x in range(t)]) mat[0][0] = a mat[0][1] = m mat[1][0] = d p = 2 for i in range(2, t): mat[0][i] = mat[0][i - 1] + p mat[i][0] = mat[i - 1][0] + p p += 1 for i in range(1, t): for j in range(1, t...
RESET = "\x1B[0m" BOLD = "\x1B[1m" DIM = "\x1B[2m" UNDER = "\x1B[4m" REVERSE = "\x1B[7m" HIDE = "\x1B[8m" CLEARSCREEN = "\x1B[2J" CLEARLINE = "\x1B[2K" BLACK = "\x1B[30m" RED = "\x1B[31m" GREEN = "\x1B[32m" YELLOW = "\x1B[33m" BLUE = "\x1B[34m" MAGENTA = "\x1B[35m" CYAN = "\x1B[36m" WHITE = "\x1B[37m" B...
reset = '\x1b[0m' bold = '\x1b[1m' dim = '\x1b[2m' under = '\x1b[4m' reverse = '\x1b[7m' hide = '\x1b[8m' clearscreen = '\x1b[2J' clearline = '\x1b[2K' black = '\x1b[30m' red = '\x1b[31m' green = '\x1b[32m' yellow = '\x1b[33m' blue = '\x1b[34m' magenta = '\x1b[35m' cyan = '\x1b[36m' white = '\x1b[37m' bblack = '\x1b[40...
def create_message_routes(server): metrics = server._augur.metrics
def create_message_routes(server): metrics = server._augur.metrics
s = 'Ala ma kota' lz = list(s) print(lz) print() for i in range(len(lz)): print(lz[i]) print() for i in lz: print(i)
s = 'Ala ma kota' lz = list(s) print(lz) print() for i in range(len(lz)): print(lz[i]) print() for i in lz: print(i)
head = '''###host_name### NAC Implementation\n DATE START_TIME till END_TIME\nChange #''' first_line = "Participants & Contact Information:" second_line = 'Objectives' third_line = 'Procedure' numbered_line_part_one = ['Conduct pre job brief', "Contact the NOC (network alarms)", "Contact the Help Desk ...
head = '###host_name### NAC Implementation\n DATE START_TIME till END_TIME\nChange #' first_line = 'Participants & Contact Information:' second_line = 'Objectives' third_line = 'Procedure' numbered_line_part_one = ['Conduct pre job brief', 'Contact the NOC (network alarms)', 'Contact the Help Desk ', 'Apply...
# value of A represent its position in C # value of C represent its position in B def count_sort(A, k, exp): B = [0 for i in range(len(A))] C = [0 for i in range(k)] # count the frequency of each elements in A and save them in the coresponding position in B for i in range(0, len(A)): # calcula...
def count_sort(A, k, exp): b = [0 for i in range(len(A))] c = [0 for i in range(k)] for i in range(0, len(A)): index = A[i] // exp % 10 C[index] += 1 for i in range(1, k, 1): C[i] = C[i - 1] + C[i] for i in range(len(A) - 1, -1, -1): index = A[i] // exp % 10 B...
if __name__ == '__main__': text = input() text = text.lower() l = list(text) i = 0 while i < len(l): if i == 0: print(l[i].upper(), end='') elif l[i] == 'i' and (l[i-1] == ' ' or l[i-1] == '.' or l[i-1] == ',') and (l[i+1] == ' ' or l[i+1] == '.' or l[i+1] == ','): ...
if __name__ == '__main__': text = input() text = text.lower() l = list(text) i = 0 while i < len(l): if i == 0: print(l[i].upper(), end='') elif l[i] == 'i' and (l[i - 1] == ' ' or l[i - 1] == '.' or l[i - 1] == ',') and (l[i + 1] == ' ' or l[i + 1] == '.' or l[i + 1] == ...
ssb_sequence = Sequence(name='ssb', variable=' diff down from f0', variable_unit='GHz', step=1e6, start=0, stop=100e6) qubit_time = 1e-6 qubit_points = round(qubit_time / resolution) qubit_time_array = np...
ssb_sequence = sequence(name='ssb', variable=' diff down from f0', variable_unit='GHz', step=1000000.0, start=0, stop=100000000.0) qubit_time = 1e-06 qubit_points = round(qubit_time / resolution) qubit_time_array = np.arange(qubit_points) * resolution freq_array = ssb_sequence.variable_array for (i, freq) in enumerate(...
# :coding: utf-8 # :copyright: Copyright (c) 2013 Martin Pengelly-Phillips # :license: See LICENSE.txt. '''Custom error classes.''' class CollectionError(Exception): '''Raise when a collection error occurs.'''
"""Custom error classes.""" class Collectionerror(Exception): """Raise when a collection error occurs."""
TMP_PREFIX=".tmp" EXT_FRCMOD=".frcmod" EXT_PDB=".pdb" EXT_INP=".in" EXT_PARM7=".parm7"
tmp_prefix = '.tmp' ext_frcmod = '.frcmod' ext_pdb = '.pdb' ext_inp = '.in' ext_parm7 = '.parm7'
# Copyright (c) 2022 Patrick260 # Distributed under the terms of the MIT License. n = int(input()) print(int(n / 2) * int(n / 2))
n = int(input()) print(int(n / 2) * int(n / 2))
# Copyright 2017 Alvaro Lopez Garcia # # 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 writi...
class Gabonexception(Exception): msg_fmt = 'An unknown exception occurred.' def __init__(self, message=None, **kwargs): self.kwargs = kwargs if not message: try: message = self.msg_fmt % kwargs except Exception: message = self.msg_fmt ...
flag = object() # or class _Flag: __instance = None def __new__(cls): if cls.__instance is None: cls.__instance = object.__new__(cls) return cls.__instance # or class _Flag(Enum): flag = auto() flag = _Flag.flag
flag = object() class _Flag: __instance = None def __new__(cls): if cls.__instance is None: cls.__instance = object.__new__(cls) return cls.__instance class _Flag(Enum): flag = auto() flag = _Flag.flag
MAJOR_COLORS = ['White', 'Red', 'Black', 'Yellow', 'Violet'] MINOR_COLORS = ["Blue", "Orange", "Green", "Brown", "Slate"] def get_color_from_pair_number(pair_number): zero_based_pair_number = pair_number - 1 major_index = zero_based_pair_number // len(MINOR_COLORS) if major_index >= len(MAJOR_COLORS): raise...
major_colors = ['White', 'Red', 'Black', 'Yellow', 'Violet'] minor_colors = ['Blue', 'Orange', 'Green', 'Brown', 'Slate'] def get_color_from_pair_number(pair_number): zero_based_pair_number = pair_number - 1 major_index = zero_based_pair_number // len(MINOR_COLORS) if major_index >= len(MAJOR_COLORS): ...
# # PySNMP MIB module Nortel-MsCarrier-MscPassport-TdmaIwfMIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/Nortel-MsCarrier-MscPassport-TdmaIwfMIB # Produced by pysmi-0.3.4 at Wed May 1 14:31:23 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwan...
(integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (single_value_constraint, value_range_constraint, constraints_union, constraints_intersection, value_size_constraint) ...
## For !) ozone2 = ruleGMLString("""rule [ ruleID "O3 attack by .O-X, X != O " left [ node [ id 1 label "O+" ] node [ id 2 label "O-" ] edge [ source 1 target 2 label "-" ] node [ id 3 label "O." ] ] context [ node [ id 4 label "*" ] edge [ source 1 target 4 label "*" ] ] right [...
ozone2 = rule_gml_string('rule [\n\truleID "O3 attack by .O-X, X != O "\n\tleft [\n\t\tnode [ id 1 label "O+" ]\n\t\tnode [ id 2 label "O-" ]\n\t\tedge [ source 1 target 2 label "-" ]\n\t\tnode [ id 3 label "O." ]\n\t] \n\tcontext [\n \t\tnode [ id 4 label "*" ]\n \t\tedge [ source 1 target 4 label "*" ]\n\...
"""This module define WordFreq. WordFreq helps to measure distance between two texts.""" def _tokenize(text): """Return tokens from text. Text are splitted by tokens with space as seperator. All non alpha character discarded. All tokens are casefolded. """ # split text by spaces and add only ...
"""This module define WordFreq. WordFreq helps to measure distance between two texts.""" def _tokenize(text): """Return tokens from text. Text are splitted by tokens with space as seperator. All non alpha character discarded. All tokens are casefolded. """ wordvoid = (''.join((ch for ch in w i...
phrasal_verbs_data = [ ( 'The cat went to the garden. They left it out.', ['left out'] ), ( 'Going down the mountain was hectic.', ['Going down'] ), ( 'He got off at the airport. It was a rainy day. They switched the lights off.', ['got off', 'switched...
phrasal_verbs_data = [('The cat went to the garden. They left it out.', ['left out']), ('Going down the mountain was hectic.', ['Going down']), ('He got off at the airport. It was a rainy day. They switched the lights off.', ['got off', 'switched off'])] contractions_data = [("I don't condone this behaviour!", ["don't"...
class Array: _MAX_INDEX_LOOKUP_LENGTH = 1000 def __init__(self, reader, read_all): self.reader = reader self.begin_pos = self.reader._tell_read_pos() self.length = -1 # For optimizing index queries self.last_known_pos = self.reader._tell_read_pos() self.last_kn...
class Array: _max_index_lookup_length = 1000 def __init__(self, reader, read_all): self.reader = reader self.begin_pos = self.reader._tell_read_pos() self.length = -1 self.last_known_pos = self.reader._tell_read_pos() self.last_known_pos_index = 0 self.index_look...
# Print out a message and then ask the user for input print('Hello, world') user_name = input('Enter your name: ') print('Hello ', user_name)
print('Hello, world') user_name = input('Enter your name: ') print('Hello ', user_name)
# -------------------------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # --------------------------------------------------------------------...
def load_command_table(self, _): with self.command_group('staticwebapp enterprise-edge', is_preview=True) as g: g.custom_command('enable', 'enable_staticwebapp_enterprise_edge') g.custom_command('disable', 'disable_staticwebapp_enterprise_edge') g.custom_show_command('show', 'show_staticweba...
# coding: utf-8 """ Provides a class to customize template information on a per-view basis. To customize template properties for a particular view, create that view from a class that subclasses TemplateSpec. The "spec" in TemplateSpec stands for "special" or "specified" template information. """ class TemplateSpe...
""" Provides a class to customize template information on a per-view basis. To customize template properties for a particular view, create that view from a class that subclasses TemplateSpec. The "spec" in TemplateSpec stands for "special" or "specified" template information. """ class Templatespec(object): """...
x=int(input()) if(x%4==0 and x%100!=0 or x%400==0): print('1') else: print('0')
x = int(input()) if x % 4 == 0 and x % 100 != 0 or x % 400 == 0: print('1') else: print('0')
# Copyright 2013-2020 Lawrence Livermore National Security, LLC and other # Spack Project Developers. See the top-level COPYRIGHT file for details. # # SPDX-License-Identifier: (Apache-2.0 OR MIT) class PyAzuremlTrainAutomlClient(Package): """The azureml-train-automl-client package contains functionality for ...
class Pyazuremltrainautomlclient(Package): """The azureml-train-automl-client package contains functionality for automatically finding the best machine learning model and its parameters, given training and test data.""" homepage = 'https://docs.microsoft.com/en-us/azure/machine-learning/service/' ur...
"""Templates used to parse an XML object, that is send to the CSW server. """ xml_base = ( "<?xml version='1.0' encoding='ISO-8859-1' standalone='no'?>" "<csw:GetRecords " "xmlns:csw='http://www.opengis.net/cat/csw/2.0.2' " "xmlns:ogc='http://www.opengis.net/ogc' " "service='CSW' " "version='2....
"""Templates used to parse an XML object, that is send to the CSW server. """ xml_base = "<?xml version='1.0' encoding='ISO-8859-1' standalone='no'?><csw:GetRecords xmlns:csw='http://www.opengis.net/cat/csw/2.0.2' xmlns:ogc='http://www.opengis.net/ogc' service='CSW' version='2.0.2' resultType='results' startPosition='{...
#!/usr/bin/python # ============================================================================== # Author: Tao Li (taoli@ucsd.edu) # Date: May 2, 2015 # Question: 104-Maximum-Depth-of-Binary-Tree # Link: https://leetcode.com/problems/maximum-depth-of-binary-tree/ # ==========================================...
class Solution: def max_depth(self, root): if root is None: return 0 else: return 1 + max(self.maxDepth(root.left), self.maxDepth(root.right))
"""Reachy Pyluos Hal abstraction. Connects to the multipled gates via serial to synchronize with hardware. """
"""Reachy Pyluos Hal abstraction. Connects to the multipled gates via serial to synchronize with hardware. """
# ------------------------------------------ API URLs ------------------------------------------------------------------ GOOGLE_PROFILE_API_URL = 'https://www.googleapis.com/userinfo/v2/me' FACEBOOK_PROFILE_API_URL = 'https://graph.facebook.com/v3.2/me' FACEBOOK_PROFILE_PIC_API_URL = 'https://graph.facebook.com/v3.2/m...
google_profile_api_url = 'https://www.googleapis.com/userinfo/v2/me' facebook_profile_api_url = 'https://graph.facebook.com/v3.2/me' facebook_profile_pic_api_url = 'https://graph.facebook.com/v3.2/me/picture' github_profile_api_url = 'https://api.github.com/user' github_email_api_url = 'https://api.github.com/user/emai...
class Solution(object): def minWindow(self, s, t): """ :type s: str :type t: str :rtype: str """ start, end, left = 0, 0, 0 min_len = sys.maxsize hash = collections.defaultdict(int) for i in t: hash[i] += 1 num =...
class Solution(object): def min_window(self, s, t): """ :type s: str :type t: str :rtype: str """ (start, end, left) = (0, 0, 0) min_len = sys.maxsize hash = collections.defaultdict(int) for i in t: hash[i] += 1 num = l...
text = "Have a nice day!\nSee ya!" # with open("test1.txt", "a") as file: # append some text # file.write(text) # with open("test1.txt", "w") as file: # write a text overwriting # file.write(text) # with open("test1.txt", "r") as file: # read a text # ...
text = 'Have a nice day!\nSee ya!'
# Copyright 2013 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. { 'includes': [ 'extensions.gypi', ], 'variables': { 'chromium_code': 1, }, 'targets': [ { # GN version: //extensions/common ...
{'includes': ['extensions.gypi'], 'variables': {'chromium_code': 1}, 'targets': [{'target_name': 'extensions_common_constants', 'type': 'static_library', 'include_dirs': ['..', '<(INTERMEDIATE_DIR)'], 'sources': ['<@(extensions_common_constants_sources)'], 'msvs_disabled_warnings': [4267]}, {'target_name': 'extensions_...
def total_takings(monthly_takings): """ A regular flying circus happens twice or three times a month. For each month, information about the amount of money taken at each event is saved in a list, so that the amounts appear in the order in which they happened. The months' data is all collected in a dictionary ca...
def total_takings(monthly_takings): """ A regular flying circus happens twice or three times a month. For each month, information about the amount of money taken at each event is saved in a list, so that the amounts appear in the order in which they happened. The months' data is all collected in a dictionary ca...
class MyTime: def __init__(self, hrs=0, mins=0, secs=0): """ Create a MyTime object initialized to hrs, mins, secs """ self.hours = hrs self.minutes = mins self.seconds = secs totalsecs = hrs * 3600 + mins * 60 + secs self.hours = totalsecs // 3600 # Split in h, m,...
class Mytime: def __init__(self, hrs=0, mins=0, secs=0): """ Create a MyTime object initialized to hrs, mins, secs """ self.hours = hrs self.minutes = mins self.seconds = secs totalsecs = hrs * 3600 + mins * 60 + secs self.hours = totalsecs // 3600 leftoverse...
class XpathValidationError(Exception): """ When an error occurs in the process of xpath validation (NOT when an xpath is invalid) """ pass
class Xpathvalidationerror(Exception): """ When an error occurs in the process of xpath validation (NOT when an xpath is invalid) """ pass
class Solution: def longestCommonPrefix(self, strs: List[str]) -> str: if not len(strs): return '' shortest_length = min(len(s) for s in strs) res = [] for i in range(shortest_length): _set = set(s[i] for s in strs) if len(_set) > 1: ...
class Solution: def longest_common_prefix(self, strs: List[str]) -> str: if not len(strs): return '' shortest_length = min((len(s) for s in strs)) res = [] for i in range(shortest_length): _set = set((s[i] for s in strs)) if len(_set) > 1: ...
#Date: 022622 #Difficulty: Easy class Solution(object): def reverseString(self, s): """ :type s: List[str] :rtype: None Do not return anything, modify s in-place instead. """ left = 0 right=len(s)-1 while left<right: s[left],s[right]=s[right],s[lef...
class Solution(object): def reverse_string(self, s): """ :type s: List[str] :rtype: None Do not return anything, modify s in-place instead. """ left = 0 right = len(s) - 1 while left < right: (s[left], s[right]) = (s[right], s[left]) l...
filename = "Tp_Files/examples/files/numbers.txt" # Relative Path with open(filename, 'r') as fh: lines_str = fh.read() # reads all the lines into a string print(len(lines_str)) # number of characters in file print(lines_str) # the content of the file
filename = 'Tp_Files/examples/files/numbers.txt' with open(filename, 'r') as fh: lines_str = fh.read() print(len(lines_str)) print(lines_str)
KtlintConfigInfo = provider( fields = { "editorconfig": "Editor config file to use", }, ) def _ktlint_config_impl(ctx): return [ KtlintConfigInfo( editorconfig = ctx.file.editorconfig, ), ] ktlint_config = rule( _ktlint_config_impl, attrs = { "editor...
ktlint_config_info = provider(fields={'editorconfig': 'Editor config file to use'}) def _ktlint_config_impl(ctx): return [ktlint_config_info(editorconfig=ctx.file.editorconfig)] ktlint_config = rule(_ktlint_config_impl, attrs={'editorconfig': attr.label(doc='Editor config file to use', mandatory=False, allow_singl...
number = int(input()) for i in range(number): valores = [float(k) for k in input().split()] x = valores[0] * 0.2 + valores[1] * 0.3 + valores[2] * 0.5 print("{0:.1f}".format(x))
number = int(input()) for i in range(number): valores = [float(k) for k in input().split()] x = valores[0] * 0.2 + valores[1] * 0.3 + valores[2] * 0.5 print('{0:.1f}'.format(x))
def no_spacing_string(max_length=None, min_length=None): def validate(value): if ' ' in value: raise ValueError('There must be no spaces in this field') if max_length and len(value) > max_length: raise ValueError( f'This field must be shorter than {max_length}...
def no_spacing_string(max_length=None, min_length=None): def validate(value): if ' ' in value: raise value_error('There must be no spaces in this field') if max_length and len(value) > max_length: raise value_error(f'This field must be shorter than {max_length} characters') ...