content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
""" @Project : DuReader @Module : __init__.py.py @Author : Deco [deco@cubee.com] @Created : 8/13/18 3:43 PM @Desc : """
""" @Project : DuReader @Module : __init__.py.py @Author : Deco [deco@cubee.com] @Created : 8/13/18 3:43 PM @Desc : """
class Video: def __init__(self, id: str, date: str, title: str): self.id = id self.date = date self.title = title def __members(self): return ( self.id, self.date, self.title, ) def __eq__(self, other) -> bool: if type(oth...
class Video: def __init__(self, id: str, date: str, title: str): self.id = id self.date = date self.title = title def __members(self): return (self.id, self.date, self.title) def __eq__(self, other) -> bool: if type(other) is type(self): return self.__m...
class LogLevels: def __init__(self): self.__Load_Dict() def __Load_Dict(self): lines = [] with open("LogLevels.csv", 'r') as log_level_file: for each_line in log_level_file: each_line = each_line.replace('\n', '') lines.append(each_line) ...
class Loglevels: def __init__(self): self.__Load_Dict() def ___load__dict(self): lines = [] with open('LogLevels.csv', 'r') as log_level_file: for each_line in log_level_file: each_line = each_line.replace('\n', '') lines.append(each_line) ...
while True: line = input() if line == "Stop": break print(line)
while True: line = input() if line == 'Stop': break print(line)
# # Karl Keusgen # 2020-09-23 # UseJsonConfig = False
use_json_config = False
def green_bold(payload): """ Format payload as green. """ return '\x1b[32;1m{0}\x1b[39;22m'.format(payload) def yellow_bold(payload): """ Format payload as yellow. """ return '\x1b[33;1m{0}\x1b[39;22m'.format(payload) def red_bold(payload): """ Format payload as red. """ ...
def green_bold(payload): """ Format payload as green. """ return '\x1b[32;1m{0}\x1b[39;22m'.format(payload) def yellow_bold(payload): """ Format payload as yellow. """ return '\x1b[33;1m{0}\x1b[39;22m'.format(payload) def red_bold(payload): """ Format payload as red. """ ...
# Definition for a binary tree node. class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right class Solution: def sumOfLeftLeaves(self, root: Optional[TreeNode]) -> int: def s(node, isLeft=True): if...
class Treenode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right class Solution: def sum_of_left_leaves(self, root: Optional[TreeNode]) -> int: def s(node, isLeft=True): if not node: return 0 ...
# -*- coding: utf-8 -*- """ The print proxy is a mechanism to provide fully variable pdf print creation process inside of the oereb server with minimal impact on the behavior of it. The idea is to bind an external web accessible print service to the oereb server. The extract is generated by the oereb server the result ...
""" The print proxy is a mechanism to provide fully variable pdf print creation process inside of the oereb server with minimal impact on the behavior of it. The idea is to bind an external web accessible print service to the oereb server. The extract is generated by the oereb server the result is sent to the print ins...
def main(): for tc in range(int(input())): N, ans = int(input()), -1 for a in range(1,N//2): b = (N*(2*a-N))//(2*(a-N)) c = N-a-b if a+b+c==N and a*a+b*b==c*c: ans = max(ans,a*b*c) print(ans) if __name__=="__main__": main()
def main(): for tc in range(int(input())): (n, ans) = (int(input()), -1) for a in range(1, N // 2): b = N * (2 * a - N) // (2 * (a - N)) c = N - a - b if a + b + c == N and a * a + b * b == c * c: ans = max(ans, a * b * c) print(ans) if __n...
# %% [8. String to Integer (atoi)](https://leetcode.com/problems/string-to-integer-atoi/) class Solution: def myAtoi(self, s: str) -> int: try: s = re.match(r"\+?-?[0-9]+", s.strip()).group() return min(2147483647, max(-2147483648, int(s))) except: return 0
class Solution: def my_atoi(self, s: str) -> int: try: s = re.match('\\+?-?[0-9]+', s.strip()).group() return min(2147483647, max(-2147483648, int(s))) except: return 0
# Succesfull HTTP_200_OK: int = 200 # Client Error HTTP_400_BAD_REQUEST: int = 400 HTTP_401_UNAUTHORIZED: int = 401 HTTP_403_FORBIDDEN: int = 403 HTTP_404_NOT_FOUND: int = 404 HTTP_405_METHOD_NOT_ALLOWED: int = 405 HTTP_409_CONFLICT: int = 409 HTTP_428_PRECONDITION_REQUIRED: int = 428 # Server Error HTTP_500_INTERNAL...
http_200_ok: int = 200 http_400_bad_request: int = 400 http_401_unauthorized: int = 401 http_403_forbidden: int = 403 http_404_not_found: int = 404 http_405_method_not_allowed: int = 405 http_409_conflict: int = 409 http_428_precondition_required: int = 428 http_500_internal_server_error: int = 500 http_501_not_impleme...
c, link = emk.module("c", "link") link.depdirs += [ "$:proj:$" ]
(c, link) = emk.module('c', 'link') link.depdirs += ['$:proj:$']
adjoining = [(1, 0), (-1, 0), (0, 1), (0, -1)] def compute_max_square(tiles): def is_square(x, y, m): for dx in range(m): for dy in range(m): uid = (x + dx, y + dy) if uid not in tiles: return False return True max_square = 0 ...
adjoining = [(1, 0), (-1, 0), (0, 1), (0, -1)] def compute_max_square(tiles): def is_square(x, y, m): for dx in range(m): for dy in range(m): uid = (x + dx, y + dy) if uid not in tiles: return False return True max_square = 0 ...
apis = { 'PhishTank': [ { 'name': 'PT_01', 'url': 'http://checkurl.phishtank.com/checkurl/', 'api_key': '' } ], 'GoogleSafeBrowsing': [ { 'name': 'GSB_01', 'url': 'https://safebrowsing.googleapis.com/v4/threatMatches:find', ...
apis = {'PhishTank': [{'name': 'PT_01', 'url': 'http://checkurl.phishtank.com/checkurl/', 'api_key': ''}], 'GoogleSafeBrowsing': [{'name': 'GSB_01', 'url': 'https://safebrowsing.googleapis.com/v4/threatMatches:find', 'api_key': '', 'client': {'clientId': 'URL Checker', 'clientVersion': '1.0'}}], 'URLScan': [{'name': 'U...
class WorkflowStatus: ACTIVE = 'ACTIVE' COMPLETED = 'COMPLETED' FAILED = 'FAILED' CANCELED = 'CANCELED' TERMINATED = 'TERMINATED' CONTINUED_AS_NEW = 'CONTINUED_AS_NEW' TIMED_OUT = 'TIMED_OUT' class RegistrationStatus: REGISTERED = 'REGISTERED' DEPRECATED = 'DEPRECATED'
class Workflowstatus: active = 'ACTIVE' completed = 'COMPLETED' failed = 'FAILED' canceled = 'CANCELED' terminated = 'TERMINATED' continued_as_new = 'CONTINUED_AS_NEW' timed_out = 'TIMED_OUT' class Registrationstatus: registered = 'REGISTERED' deprecated = 'DEPRECATED'
class Solution: def myAtoi(self, str): """ :type str: str :rtype: int """ if str == "": return 0 lens = len(str) result = 0 flag = 1 i = 0 while i < lens and str[i] == " ": i += 1 if i < lens and str[i] ...
class Solution: def my_atoi(self, str): """ :type str: str :rtype: int """ if str == '': return 0 lens = len(str) result = 0 flag = 1 i = 0 while i < lens and str[i] == ' ': i += 1 if i < lens and str[i]...
class Enemy: hp = 200 def __init__(self, attack_low, attack_high): self.attack_high = attack_high self.attack_low = attack_low def getAttackLow(self): print("Low Attack", self.attack_low) return self.attack_low def getAttackHigh(self): print("High Attack", sel...
class Enemy: hp = 200 def __init__(self, attack_low, attack_high): self.attack_high = attack_high self.attack_low = attack_low def get_attack_low(self): print('Low Attack', self.attack_low) return self.attack_low def get_attack_high(self): print('High Attack', ...
""" Problem found on Hacker Rank: https://www.hackerrank.com/challenges/drawing-book/problem?utm_campaign=challenge-recommendation&utm_medium=email&utm_source=24-hour-campaign Observations About the Problem: - the last page, and n if n is odd, then that means the last page number is odd. Likewise, it is also prin...
""" Problem found on Hacker Rank: https://www.hackerrank.com/challenges/drawing-book/problem?utm_campaign=challenge-recommendation&utm_medium=email&utm_source=24-hour-campaign Observations About the Problem: - the last page, and n if n is odd, then that means the last page number is odd. Likewise, it is also prin...
def get_next_value(v): v *= 252533 return v % 33554393 x = 1 y = 1 val = 20151125 while True: if y == 1: y = x + 1 x = 1 else: x += 1 y -= 1 # print(x, y) val = get_next_value(val) if x == 3083 and y == 2978: print(val) break
def get_next_value(v): v *= 252533 return v % 33554393 x = 1 y = 1 val = 20151125 while True: if y == 1: y = x + 1 x = 1 else: x += 1 y -= 1 val = get_next_value(val) if x == 3083 and y == 2978: print(val) break
class command_base : def __init__(self): self.talk = False self.talkNum = 0
class Command_Base: def __init__(self): self.talk = False self.talkNum = 0
#-*- coding:utf-8 -*- """ RSA Utils This submodule comprises of RSA utilities, and common exploit scripts. The tool also features RSA Analyser. """
""" RSA Utils This submodule comprises of RSA utilities, and common exploit scripts. The tool also features RSA Analyser. """
class Solution: def maxScoreSightseeingPair(self, A: List[int]) -> int: maxAi, result = 0, 0 # max Ai keeps track of best encountered till now A[i]+i. # result keeps finding better results across all j's. for j in range(len(A)): result = max(maxAi+A[j]-j, result) ...
class Solution: def max_score_sightseeing_pair(self, A: List[int]) -> int: (max_ai, result) = (0, 0) for j in range(len(A)): result = max(maxAi + A[j] - j, result) max_ai = max(maxAi, A[j] + j) return result
""" Author: James Ma Email stuff here: jamesmawm@gmail.com """ """ API doumentation: https://www.interactivebrokers.com/en/software/api/apiguide/java/reqhistoricaldata.htm https://www.interactivebrokers.com/en/software/api/apiguide/tables/tick_types.htm """ FIELD_BID_SIZE = 0 FIELD_BID_PRICE = 1 FIELD_ASK_PRICE = 2 F...
""" Author: James Ma Email stuff here: jamesmawm@gmail.com """ '\nAPI doumentation:\nhttps://www.interactivebrokers.com/en/software/api/apiguide/java/reqhistoricaldata.htm\nhttps://www.interactivebrokers.com/en/software/api/apiguide/tables/tick_types.htm\n' field_bid_size = 0 field_bid_price = 1 field_ask_price = 2 fie...
#!/usr/bin/env python imagedir = parent + "/oiio-images" command = rw_command (imagedir, "oiio.ico")
imagedir = parent + '/oiio-images' command = rw_command(imagedir, 'oiio.ico')
# -*- coding: utf-8 -*- """Config file for getting IP, email and encryption. """ # Config of getting public IP from router # You should get them from browser after logging in router ROUTER_IP_URL = 'http://192.168.0.1/userRpm/StatusRpm.htm' AUTHORIZATION_HEADERS = { 'Authorization': 'Basic YWRtaW46SklNNDgxNDg2MGpp...
"""Config file for getting IP, email and encryption. """ router_ip_url = 'http://192.168.0.1/userRpm/StatusRpm.htm' authorization_headers = {'Authorization': 'Basic YWRtaW46SklNNDgxNDg2MGppbQ=='} ip_regex = 'wanPara\\s+=\\s+new\\s+Array\\(.*?"(\\d+\\.\\d+\\.\\d+\\.\\d+)",' email_address = 'your_email_address@mail.com' ...
triangle = '''75 95 64 17 47 82 18 35 87 10 20 04 82 47 65 19 01 23 75 03 34 88 02 77 73 07 63 67 99 65 04 28 06 16 70 92 41 41 26 56 83 40 80 70 33 41 48 72 33 47 32 37 16 94 29 53 71 44 65 25 43 91 52 97 51 14 70 11 33 28 77 73 17 78 39 68 17 57 91 71 52 38 17 14 91 43 58 50 27 29 48 63 66 04 68 89 53 67 30 73 16 69 ...
triangle = '75\n95 64\n17 47 82\n18 35 87 10\n20 04 82 47 65\n19 01 23 75 03 34\n88 02 77 73 07 63 67\n99 65 04 28 06 16 70 92\n41 41 26 56 83 40 80 70 33\n41 48 72 33 47 32 37 16 94 29\n53 71 44 65 25 43 91 52 97 51 14\n70 11 33 28 77 73 17 78 39 68 17 57\n91 71 52 38 17 14 91 43 58 50 27 29 48\n63 66 04 68 89 53 67 3...
"""Base class for implementing Lambda handlers as classes. Used across multiple Lambda functions (included in each zip file). Add additional features here common to all your Lambdas, like logging.""" class LambdaBase(object): @classmethod def get_handler(cls, *args, **kwargs): def handler(event, contex...
"""Base class for implementing Lambda handlers as classes. Used across multiple Lambda functions (included in each zip file). Add additional features here common to all your Lambdas, like logging.""" class Lambdabase(object): @classmethod def get_handler(cls, *args, **kwargs): def handler(event, cont...
# possible cell states, bitwise-flags CELL_MINE = 1 CELL_REVEALED = 2 CELL_FLAGGED = 4 CELL_HIDDEN = 8 CELL_EMPTY = 16 # Colours for numbered cells. COLORS = { 1: 'blue', 2: 'green', 3: 'red', 4: 'dark-blue', 5: 'brown', 6: 'purple', 7: 'dark-green', 8: 'orange' } # [height, w...
cell_mine = 1 cell_revealed = 2 cell_flagged = 4 cell_hidden = 8 cell_empty = 16 colors = {1: 'blue', 2: 'green', 3: 'red', 4: 'dark-blue', 5: 'brown', 6: 'purple', 7: 'dark-green', 8: 'orange'} difficulties = {'beginner': [9, 9, 10], 'intermediate': [16, 16, 40], 'advanced': [16, 30, 99]}
n1 = "123" print(n1.isdigit()) # -- ID1 n2 = "345 2" print(n2.isdigit()) # -- ID2 n3 = "345 2b" print(n3.isdigit()) # -- ID3 n4 = "\u0035" print(n4.isdigit()) # -- ID4 n5 = "\u00BC" print(n5) print(n5.isdigit()) # -- ID5 n6 = "\u00B2343" print(n6) print(n6.isdigit()) # -- ID6 n7 = "8.9" print(n7.isdigit(...
n1 = '123' print(n1.isdigit()) n2 = '345 2' print(n2.isdigit()) n3 = '345 2b' print(n3.isdigit()) n4 = '5' print(n4.isdigit()) n5 = '¼' print(n5) print(n5.isdigit()) n6 = '²343' print(n6) print(n6.isdigit()) n7 = '8.9' print(n7.isdigit()) n8 = '123-456-975' print(n8.isdigit())
# -*- coding: utf-8 -*- # Copyright (c) 2017-18 Richard Hull and contributors # See LICENSE.rst for details. """ Display drivers for LED Matrices & 7-segment displays (MAX7219) and RGB NeoPixels (WS2812 / APA102). """ __version__ = '1.1.1'
""" Display drivers for LED Matrices & 7-segment displays (MAX7219) and RGB NeoPixels (WS2812 / APA102). """ __version__ = '1.1.1'
expected_output = { "ospf3-database-information": { "ospf3-area-header": {"ospf-area": "0.0.0.0"}, "ospf3-database": [ { "lsa-type": "Router", "lsa-id": "0.0.0.0", "advertising-router": "10.16.2.2", "sequence-number": "0x800...
expected_output = {'ospf3-database-information': {'ospf3-area-header': {'ospf-area': '0.0.0.0'}, 'ospf3-database': [{'lsa-type': 'Router', 'lsa-id': '0.0.0.0', 'advertising-router': '10.16.2.2', 'sequence-number': '0x80000002', 'age': '491', 'checksum': '0x549c', 'lsa-length': '40', 'ospf3-router-lsa': {'bits': '0x0', ...
names = ["Helder", "Fabia", "Linda", "Leonie", "Carina", "Ivan", "Lexy"] # print(names[0]) # print(names[1]) # print(names[2]) # print(names[3]) # print(names[4]) # print(names[5]) # print(names[6]) #print all elements with position on the left #ex: # 0: Helder # 1: Fabia ... counter = 0 while counter < len(names):...
names = ['Helder', 'Fabia', 'Linda', 'Leonie', 'Carina', 'Ivan', 'Lexy'] counter = 0 while counter < len(names): print('{}: {}'.format(counter + 1, names[counter])) counter += 1
def stopTracking(): i01.headTracking.stopTracking() i01.eyesTracking.stopTracking()
def stop_tracking(): i01.headTracking.stopTracking() i01.eyesTracking.stopTracking()
def isInt(x): return type(x) in (float, int) and int(x) == x class CommChannel: def __init__(self): self.outbox = [] self.inbox = [] def put(self, update): if len(update) > 0: self.outbox.append(update) def get(self): inbox = self.inbox self.inbox = [] return ...
def is_int(x): return type(x) in (float, int) and int(x) == x class Commchannel: def __init__(self): self.outbox = [] self.inbox = [] def put(self, update): if len(update) > 0: self.outbox.append(update) def get(self): inbox = self.inbox self.inbox...
class Solution : def canPair(self, nums, k) : n = len(nums) if n % 2 != 0 : return False # Initialization of dictionary count = [0] * k # Filling the map for i in range(n) : count[nums[i]%k] += 1 #print(count) ...
class Solution: def can_pair(self, nums, k): n = len(nums) if n % 2 != 0: return False count = [0] * k for i in range(n): count[nums[i] % k] += 1 if count[0] % 2 != 0 or (k % 2 == 0 and count[k // 2] % 2 != 0): return False limit =...
# https://sudipghimire.com.np """ Numeric Data Types in Python to run the file, we can go to the terminal and just type python 02_data_types/02_basic_data_types.py """ x: complex = -5j x = 5 # integer x = 5.5 # float x = True # Boolean # simple interest # p -> principal amount 10000 # r -> rate ...
""" Numeric Data Types in Python to run the file, we can go to the terminal and just type python 02_data_types/02_basic_data_types.py """ x: complex = -5j x = 5 x = 5.5 x = True p = 10000 r = 10.5 t = 1.45 print(type(p)) simple_interest = p * t * r / 100 print(simple_interest) string_one = 'Hello World' "\n - They...
class SingleReply: def __init__(self, inviteeId, status): self.inviteeId = inviteeId self.status = status class PartyReplyInfoBase: def __init__(self, partyId, partyReplies): self.partyId = partyId self.replies = [] for oneReply in partyReplies: self.rep...
class Singlereply: def __init__(self, inviteeId, status): self.inviteeId = inviteeId self.status = status class Partyreplyinfobase: def __init__(self, partyId, partyReplies): self.partyId = partyId self.replies = [] for one_reply in partyReplies: self.repli...
class Solution: # @param A : list of integers # @return an integer def findMinXor(self, nums): nums.sort() x = nums[0] minimumXOR = 10**9 for i in range(1, len(nums)): y = nums[i] minimumXOR = min(minimumXOR, x^y) x = y return mi...
class Solution: def find_min_xor(self, nums): nums.sort() x = nums[0] minimum_xor = 10 ** 9 for i in range(1, len(nums)): y = nums[i] minimum_xor = min(minimumXOR, x ^ y) x = y return minimumXOR
""" Reflection by Simon Greenwold. Vary the specular reflection component of a material with the horizontal position of the mouse. """ def setup(): size(640, 360, P3D) noStroke() colorMode(RGB, 1) fill(0.4) def draw(): background(0) translate(width / 2, height / 2) # Set the specular...
""" Reflection by Simon Greenwold. Vary the specular reflection component of a material with the horizontal position of the mouse. """ def setup(): size(640, 360, P3D) no_stroke() color_mode(RGB, 1) fill(0.4) def draw(): background(0) translate(width / 2, height / 2) light_specular(1, ...
class UrlResources(object): def __init__(self, domain, sandbox, version): super(UrlResources, self).__init__() self.domain = domain self.sandbox = sandbox self.version = version def get_resource_url(self): return self.get_resource_path().format(version=self.version) ...
class Urlresources(object): def __init__(self, domain, sandbox, version): super(UrlResources, self).__init__() self.domain = domain self.sandbox = sandbox self.version = version def get_resource_url(self): return self.get_resource_path().format(version=self.version) ...
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def isSameTree(self, p: Optional[TreeNode], q: Optional[TreeNode]) -> bool: def preorderTraversal(ro...
class Solution: def is_same_tree(self, p: Optional[TreeNode], q: Optional[TreeNode]) -> bool: def preorder_traversal(root1, root2): if not root1 and (not root2): return True elif not root1 or not root2 or root1.val != root2.val: return False ...
"""Provides source code for third party libraries that we needed to adapt for use in Makahiki. Currently, Makahiki uses adapted versions of the following third party libraries: * `apps.lib.avatar`_: a library for including pictures. * `apps.lib.brabeion`_: a library for badges. * `apps.lib.django_cas`_: a libr...
"""Provides source code for third party libraries that we needed to adapt for use in Makahiki. Currently, Makahiki uses adapted versions of the following third party libraries: * `apps.lib.avatar`_: a library for including pictures. * `apps.lib.brabeion`_: a library for badges. * `apps.lib.django_cas`_: a libr...
""" 1. line notifyMKT 2. mango server 3. mango test """ line_bot_api = 'kRC4gIlLRwvJ80crtV5g5yNPq3QwqhlbSt2KEliih2VaKiwIC8ruldSn6cvmyVrWSoO0URuuEqfMs+IH9xDyMa4u6oiTm2tUJ+HNtG0414HtSEepysKxV6Y/e9h1pO/PcXlaI4BxO6aQZHfLCjsj7AdB04t89/1O/w1cDnyilFU=' handler = 'd61b703734bf899efae9c86a14365240' mango_channel = '55zHqfzX2vg...
""" 1. line notifyMKT 2. mango server 3. mango test """ line_bot_api = 'kRC4gIlLRwvJ80crtV5g5yNPq3QwqhlbSt2KEliih2VaKiwIC8ruldSn6cvmyVrWSoO0URuuEqfMs+IH9xDyMa4u6oiTm2tUJ+HNtG0414HtSEepysKxV6Y/e9h1pO/PcXlaI4BxO6aQZHfLCjsj7AdB04t89/1O/w1cDnyilFU=' handler = 'd61b703734bf899efae9c86a14365240' mango_channel = '55zHqfzX2vgu...
pkgname = "xinput" pkgver = "1.6.3" pkgrel = 0 build_style = "gnu_configure" hostmakedepends = ["pkgconf"] makedepends = [ "libxext-devel", "libxi-devel", "libxrandr-devel", "libxinerama-devel" ] pkgdesc = "X input device configuration utility" maintainer = "q66 <q66@chimera-linux.org>" license = "MIT" url = "https...
pkgname = 'xinput' pkgver = '1.6.3' pkgrel = 0 build_style = 'gnu_configure' hostmakedepends = ['pkgconf'] makedepends = ['libxext-devel', 'libxi-devel', 'libxrandr-devel', 'libxinerama-devel'] pkgdesc = 'X input device configuration utility' maintainer = 'q66 <q66@chimera-linux.org>' license = 'MIT' url = 'https://xor...
class Solution: def twoSum(self, nums: List[int], target: int) -> List[int]: for i in range(len(nums)): n=target-nums[i] rest_of_nums=nums[i+1:] if n in rest_of_nums: return[i,(rest_of_nums.index(n))+i+1]
class Solution: def two_sum(self, nums: List[int], target: int) -> List[int]: for i in range(len(nums)): n = target - nums[i] rest_of_nums = nums[i + 1:] if n in rest_of_nums: return [i, rest_of_nums.index(n) + i + 1]
class Request: # trip: Trip # rider: User # pickup: Location id: str def __init__(self, rider, trip, pickup): self.rider = rider self.trip = trip self.pickup = pickup def accept(self): self.trip.riders.append((self.rider, self.pickup)) def un_accept(self): ...
class Request: id: str def __init__(self, rider, trip, pickup): self.rider = rider self.trip = trip self.pickup = pickup def accept(self): self.trip.riders.append((self.rider, self.pickup)) def un_accept(self): if (self.rider, self.pickup) in self.trip.riders: ...
""" 198 House Robber """ class Solution: def rob(self, nums): """ :type nums: List[int] :rtype: int """ now, last = 0, 0 for n in nums: last, now = now, max(n+last, now) return now class Solution: def rob(self, nums): ...
""" 198 House Robber """ class Solution: def rob(self, nums): """ :type nums: List[int] :rtype: int """ (now, last) = (0, 0) for n in nums: (last, now) = (now, max(n + last, now)) return now class Solution: def rob(self, nums): """ ...
class MeshFace(object): """ Represents the values of the four indices of a mesh face quad. If the third and fourth values are the same,this face represents a triangle. MeshFace(a: int,b: int,c: int) MeshFace(a: int,b: int,c: int,d: int) """ def Flip(self): """ Flip(self: MeshFac...
class Meshface(object): """ Represents the values of the four indices of a mesh face quad. If the third and fourth values are the same,this face represents a triangle. MeshFace(a: int,b: int,c: int) MeshFace(a: int,b: int,c: int,d: int) """ def flip(self): """ Flip(self: MeshFace) ...
radioData = [ "HLC\Adaptive\9558L_L1024A10_73", "HLC\Adaptive\9558L_L1024A10_73", "HLC\Adaptive\9558L_L1024A10_73", "HLC\Adaptive\9558L_L1024A10_73", "HLC\Adaptive\9558L_L1024A10_73", "HLC\Adaptive\9558L_L1024A10_73", "HLC\Adaptive\9558L_L1024A10_73", "HLC\Adaptive\9558L_L1024A10_73", "HLC\Adaptive\9558L_L1024A30_230",...
radio_data = ['HLC\\Adaptive\\9558L_L1024A10_73', 'HLC\\Adaptive\\9558L_L1024A10_73', 'HLC\\Adaptive\\9558L_L1024A10_73', 'HLC\\Adaptive\\9558L_L1024A10_73', 'HLC\\Adaptive\\9558L_L1024A10_73', 'HLC\\Adaptive\\9558L_L1024A10_73', 'HLC\\Adaptive\\9558L_L1024A10_73', 'HLC\\Adaptive\\9558L_L1024A10_73', 'HLC\\Adaptive\\95...
fname = input('Enter a file name: ') fhand = open(fname) countAddr = dict() for line in fhand: if line.startswith('From '): words = line.split() #print(words) countAddr[words[1]] = countAddr.get(words[1],0) + 1 print(countAddr)
fname = input('Enter a file name: ') fhand = open(fname) count_addr = dict() for line in fhand: if line.startswith('From '): words = line.split() countAddr[words[1]] = countAddr.get(words[1], 0) + 1 print(countAddr)
TOKEN = '1325729680:AAE3qwRzCXRukKJVvxM3VN_vsesEko6j4EI' HEROKU = 'https://sauce-finder.herokuapp.com/' BASE_TELEGRAM_URL = 'https://api.telegram.org/bot{}'.format(TOKEN) WEBHOOK_ENDPOINT = '{}/webhook'.format(HEROKU) TELEGRAM_INIT_WEBHOOK_URL = '{}/setWebhook?url={}'.format(BASE_TELEGRAM_URL, WEBHOOK_ENDPOINT) TELEGRA...
token = '1325729680:AAE3qwRzCXRukKJVvxM3VN_vsesEko6j4EI' heroku = 'https://sauce-finder.herokuapp.com/' base_telegram_url = 'https://api.telegram.org/bot{}'.format(TOKEN) webhook_endpoint = '{}/webhook'.format(HEROKU) telegram_init_webhook_url = '{}/setWebhook?url={}'.format(BASE_TELEGRAM_URL, WEBHOOK_ENDPOINT) telegra...
# Shader Uniform vs_uni = ''' uniform mat4 view_mat; uniform float Z_Bias; uniform float Z_Offset; vec4 pos_view; in vec3 pos; in vec3 nrm; void main() { pos_view = view_mat * vec4(pos+(nrm*Z_Offset), 1.0f); pos_view.z = pos_view.z - Z_Bias / pos_view.z; ...
vs_uni = '\n uniform mat4 view_mat;\n uniform float Z_Bias;\n uniform float Z_Offset;\n\n vec4 pos_view;\n \n in vec3 pos;\n in vec3 nrm;\n\n\n\n void main()\n {\n pos_view = view_mat * vec4(pos+(nrm*Z_Offset), 1.0f);\n pos_view.z = pos_view.z - Z_Bias / pos_view.z; \n gl...
##Looks like this piece of your code is in development, but this is a great place to think about using a for loop - for piece in range(32)... ## you'd need to have an array or other structure that holds the information that changes between iterations (i.e. piece1, piece1loc). I'd suggest using a dictionary ## as you ca...
piece1 = input('enter in piece abb') piece1loc = input('enter in the order-coord of the piece (eg. 64 for h1, 32 for h5)') print('Confirmation: You have inputted a', piece1, 'on order-coord', piece1loc) piece2 = input('enter in piece abb') piece2loc = input('enter in the order-coord of the piece (eg. 64 for h1, 32 for ...
# This code solves the Levine Sequence class LevineSequence: def __init__(self): self.start = ["2"] self.split = ["2"] self.result = "" self.len = 0 self.path = r'./Levine_Sequence/results.txt' def void(self): self.start = self.split self.split = [] ...
class Levinesequence: def __init__(self): self.start = ['2'] self.split = ['2'] self.result = '' self.len = 0 self.path = './Levine_Sequence/results.txt' def void(self): self.start = self.split self.split = [] self.len = len(self.start) def ...
water_count = int(input("Write how many ml of water the coffee machine has: ")) milk_count = int(input("Write how many ml of milk the coffee machine has: ")) coffee_beans_count = int( input("Write how many grams of coffee beans the coffee machine has: ")) number_of_drinks = int(input("Write how many cups of coffee ...
water_count = int(input('Write how many ml of water the coffee machine has: ')) milk_count = int(input('Write how many ml of milk the coffee machine has: ')) coffee_beans_count = int(input('Write how many grams of coffee beans the coffee machine has: ')) number_of_drinks = int(input('Write how many cups of coffee you w...
# Copyright 2017 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...
"""Utility functions for working with strings, lists, and files in Skylark.""" darwin_execution_requirements = {'requires-darwin': ''} def apple_action(ctx, **kw): """Creates an action that only runs on MacOS/Darwin. Call it similar to how you would call ctx.action: apple_action(ctx, outputs=[...], inpu...
# def make_hashs(word, sub_size): # ret = set() # current_hash = sum(ord(word[i]) * (i + 1) for i in range(sub_size)) # current_suma = sum(ord(word[i]) for i in range(sub_size)) # ret.add(current_hash) # for initial_pos in range(1, len(word) - sub_size + 1): # current_hash -= current_suma ...
while True: n = int(input()) if N == 0: break words = tuple((input() for _ in range(N))) min_ = 0 max_ = min((len(word) for word in words)) while True: if min_ == max_: break sub_size = max(min_ + 1, min_ + (max_ - min_) // 2) win = False if an...
N,S,R = map(int,input().split()) broken = list(map(int,input().split())) plus = list(map(int,input().split())) D = [1]*(N+1) for i in broken: D[i]-=1 for i in plus: D[i]+=1 ans = 0 for i in range(1,N+1): j = D[i] if j >= 1: continue if D[i-1] >1: D[i-1]-=1 elif i+1 < N + 1 an...
(n, s, r) = map(int, input().split()) broken = list(map(int, input().split())) plus = list(map(int, input().split())) d = [1] * (N + 1) for i in broken: D[i] -= 1 for i in plus: D[i] += 1 ans = 0 for i in range(1, N + 1): j = D[i] if j >= 1: continue if D[i - 1] > 1: D[i - 1] -= 1 ...
TELUGU_CORPORA = [ {'name':'telugu_text_wikisource', 'origin': 'https://github.com/cltk/telugu_text_wikisource.git', 'location':'remote', 'type':'text'}, ]
telugu_corpora = [{'name': 'telugu_text_wikisource', 'origin': 'https://github.com/cltk/telugu_text_wikisource.git', 'location': 'remote', 'type': 'text'}]
# Address: I2CBUS = 10 # /dev/i2c-1 EMC2301_ADDRESS = 0x2F # 8 bit version # Register CONF = 0x20 # Configuration FAN_STAT = 0x24 # Fan Status FAN_STALL = 0x25 # Fan Stall Status * FAN_SPIN = 0x26 # Fan Spin Status * DRIVE_FALL = 0x27...
i2_cbus = 10 emc2301_address = 47 conf = 32 fan_stat = 36 fan_stall = 37 fan_spin = 38 drive_fall = 39 fan_interrupt = 41 pwm_polarity = 42 pwm_output = 43 pwm_base = 45 fan_setting = 48 pwm_divide = 49 fan_conf1 = 50 fan_conf2 = 51 gain = 53 fan_spin_up = 54 fan_max_step = 55 fan_min_drive = 56 tach_count = 57 fan_fai...
def gauss(X): n = len(X) x = [0]*n for i in range(n): if X[i][i] == 0.0: return "Sorry can't excute" for j in range(i+1,n): rat = X[j][i]/X[i][i] for k in range(n+1): X[j][k] = X[j][k] - rat*X[i][k] print(X) x[n-1] = X[n-1][n]/X[n-...
def gauss(X): n = len(X) x = [0] * n for i in range(n): if X[i][i] == 0.0: return "Sorry can't excute" for j in range(i + 1, n): rat = X[j][i] / X[i][i] for k in range(n + 1): X[j][k] = X[j][k] - rat * X[i][k] print(X) x[n - 1] = X[...
"""Codewars: What is my golf score? 7 kyu URL: https://www.codewars.com/kata/59f7a0a77eb74bf96b00006a/train/python I have the par value for each hole on a golf course and my stroke score on each hole. I have them stored as strings, because I wrote them down on a sheet of paper. Right now, I'm using those strings to...
"""Codewars: What is my golf score? 7 kyu URL: https://www.codewars.com/kata/59f7a0a77eb74bf96b00006a/train/python I have the par value for each hole on a golf course and my stroke score on each hole. I have them stored as strings, because I wrote them down on a sheet of paper. Right now, I'm using those strings to...
def factorial_division(num1, num2): sum = 1 sum2 = 1 for num in range(num1, 0, -1): sum = sum * num for num in range(num2, 0, -1): sum2 = sum2 * num result = sum / sum2 return result num1 = int(input()) num2 = int(input()) print(f"{factorial_division(num1, num2):.2f}")
def factorial_division(num1, num2): sum = 1 sum2 = 1 for num in range(num1, 0, -1): sum = sum * num for num in range(num2, 0, -1): sum2 = sum2 * num result = sum / sum2 return result num1 = int(input()) num2 = int(input()) print(f'{factorial_division(num1, num2):.2f}')
version = "1.0" def getVersion(): return version
version = '1.0' def get_version(): return version
dyn.baseball.pos[0] = 16.0 dyn.baseball.pos[1] = 0.1 dyn.baseball.pos[2] = 2.0 dyn.baseball.vel[0] = -30.0 dyn.baseball.vel[1] = -0.1 dyn.baseball.vel[2] = 1.0 dyn.baseball.theta = trick.attach_units("degree",-90.0) dyn.baseball.phi = trick.attach_units("degree",1.0) dyn.baseball.omega0 = trick.attach_units("revoluti...
dyn.baseball.pos[0] = 16.0 dyn.baseball.pos[1] = 0.1 dyn.baseball.pos[2] = 2.0 dyn.baseball.vel[0] = -30.0 dyn.baseball.vel[1] = -0.1 dyn.baseball.vel[2] = 1.0 dyn.baseball.theta = trick.attach_units('degree', -90.0) dyn.baseball.phi = trick.attach_units('degree', 1.0) dyn.baseball.omega0 = trick.attach_units('revoluti...
# zip(*(('white', 'small'), ('red', 'big'))) colors, sizes = zip(*(('white', 'small'), ('red', 'big'))) print(colors) print(sizes)
(colors, sizes) = zip(*(('white', 'small'), ('red', 'big'))) print(colors) print(sizes)
class TestModel(object): @staticmethod def train(x): # y = np.sin(3 * x[0]) * 4 * (x[0] - 1) * (x[0] + 2) res = 0 for i in range(100000000): res += i y = sum(x * x) return y
class Testmodel(object): @staticmethod def train(x): res = 0 for i in range(100000000): res += i y = sum(x * x) return y
# -*- coding: utf-8 -*- class FARule: def __init__(self, state, character, next_state): self.state = state self.character = character self.next_state = next_state def __str__(self): return "<FARule {1} --> {2} --> {3}>".format(str(self.state), self,character, ...
class Farule: def __init__(self, state, character, next_state): self.state = state self.character = character self.next_state = next_state def __str__(self): return '<FARule {1} --> {2} --> {3}>'.format(str(self.state), self, character, str(self.next_state)) def follow(sel...
m = 0 def findMedian(a, b ,c): if a > b: if a < c: return a elif b > c: return b else: return c else: if a > c: return a elif b < c: return b else: return c def partition(A, l, r): p =...
m = 0 def find_median(a, b, c): if a > b: if a < c: return a elif b > c: return b else: return c elif a > c: return a elif b < c: return b else: return c def partition(A, l, r): p = A[l] i = l + 1 for j in ...
#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright: (c) 2014, Trond Hindenes <trond@hindenes.com> # Copyright: (c) 2018, Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # this is a windows documentation stub. actual code lives in the .ps1 # file of the ...
ansible_metadata = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'} documentation = '\n---\nmodule: win_chocolatey\nversion_added: "1.9"\nshort_description: Manage packages using chocolatey\ndescription:\n- Manage packages using Chocolatey (U(http://chocolatey.org/)).\n- If Chocolatey is ...
# Approach : # Divide the linked list to two halved # First half is head and the remaining as rest # The head points to the rest in a normal linked list # In the reverse linked list , the next of current points to the prev node and the head node should point to NULL # Keep continuing this process till the last node ...
class Solution: def reverse_list(self, head): if head is None or head.next is None: return head rest = self.reverseList(head.next) head.next.next = head head.next = None return rest
class arithmetic: def __init__(self): pass def add(self, x: int, y: int) -> int: return x + y def sub(self, x: int, y: int) -> int: return x - y def mul(self, x: int, y: int) -> int: return x * y def div(self, x: int, y: int) -> float: ...
class Arithmetic: def __init__(self): pass def add(self, x: int, y: int) -> int: return x + y def sub(self, x: int, y: int) -> int: return x - y def mul(self, x: int, y: int) -> int: return x * y def div(self, x: int, y: int) -> float: return x / y
Bag=[] #Luggage Bag Bag.append('Waterbottle') Bag.append('Milk') Bag.append('Clothes') Bag.append('Books') #Removing milk from the bag Bag.remove('Milk') print(Bag)
bag = [] Bag.append('Waterbottle') Bag.append('Milk') Bag.append('Clothes') Bag.append('Books') Bag.remove('Milk') print(Bag)
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None ''' test case: 1. empty list 2. there is only one node in the list 3. more than one node ''' class Solution(object): def reverseList(self, head): """ :type ...
""" test case: 1. empty list 2. there is only one node in the list 3. more than one node """ class Solution(object): def reverse_list(self, head): """ :type head: ListNode :rtype: ListNode """ if head == None: return None elif head.next == None: ...
#!/usr/bin/env python def start(agent) -> None: try: next_step = next(agent) try: next_step(agent) except TypeError: msg = "Returned generator not a function, did you use yield from?" raise TypeError(msg) except StopIteration: pass
def start(agent) -> None: try: next_step = next(agent) try: next_step(agent) except TypeError: msg = 'Returned generator not a function, did you use yield from?' raise type_error(msg) except StopIteration: pass
#inserta strings en una lista texto = input("Ingrese un string: ") no_olvidar = texto.split(",") #la coma seria el separador no_olvidar.sort() #Para ordenar la lista de menor a mayor (en orden alfabetico) print(no_olvidar)
texto = input('Ingrese un string: ') no_olvidar = texto.split(',') no_olvidar.sort() print(no_olvidar)
#!/usr/bin/env python3 #encoding=utf-8 #----------------------------------------------- # Usage: python3 3-desc-computed.py # Description: computed attribute with attribute descriptor #----------------------------------------------- # Implementation 1 class DescSquare: def __init__(self, start): self.va...
class Descsquare: def __init__(self, start): self.value = start def __get__(self, instance, owner): print('Descriptor DescSquare __get__ method...') return self.value ** 2 def __set__(self, instance, value): print('Descriptor DescSquare __set__ method...') self.val...
def do_greet(self, args): """Greet name with welcome message: greet NAME""" self.output = 'Welcome ' + args module_directory = {'greet': do_greet} startup_script_directory = {}
def do_greet(self, args): """Greet name with welcome message: greet NAME""" self.output = 'Welcome ' + args module_directory = {'greet': do_greet} startup_script_directory = {}
# Created by Egor Kostan. # GitHub: https://github.com/ikostan # LinkedIn: https://www.linkedin.com/in/egor-kostan/ def password(string: str) -> bool: """ Your job is to create a simple password validation function, as seen on many websites. You are permitted to use any methods to validate the password. The ...
def password(string: str) -> bool: """ Your job is to create a simple password validation function, as seen on many websites. You are permitted to use any methods to validate the password. The rules for a valid password are as follows: 1. There needs to be at least 1 uppercase letter. 2. There needs to be at...
class Invoice: def __init__(self, bill_to, date): self.bill_to = bill_to self.date = date self.invoice_items = [] self.invoice_total = 0 def add_invoice_item(self, invoice_item): ''' Write the code to append an invoice_item to the self.invoice_items list ...
class Invoice: def __init__(self, bill_to, date): self.bill_to = bill_to self.date = date self.invoice_items = [] self.invoice_total = 0 def add_invoice_item(self, invoice_item): """ Write the code to append an invoice_item to the self.invoice_items list ...
class paths: """ Feel free to remove this if you don't need it/add your own custom settings and use them """ class hypothesis: export_path = '/tmp/my_demo/backups/hypothesis'
class Paths: """ Feel free to remove this if you don't need it/add your own custom settings and use them """ class Hypothesis: export_path = '/tmp/my_demo/backups/hypothesis'
class Solution(object): def rotateRight(self, head, k): """ :type head: ListNode :type k: int :rtype: ListNode """ if not head: return None n = 0 cursor = head while cursor: cursor = cursor.next n += 1 ...
class Solution(object): def rotate_right(self, head, k): """ :type head: ListNode :type k: int :rtype: ListNode """ if not head: return None n = 0 cursor = head while cursor: cursor = cursor.next n += 1 ...
class Solution: def findMedianSortedArrays(self, nums1, nums2): """ :type nums1: List[int] :type nums2: List[int] :rtype: float """ length = len(nums1) + len(nums2) res = sorted(nums1 + nums2) if length % 2: return res[int((length-1)/2)] ...
class Solution: def find_median_sorted_arrays(self, nums1, nums2): """ :type nums1: List[int] :type nums2: List[int] :rtype: float """ length = len(nums1) + len(nums2) res = sorted(nums1 + nums2) if length % 2: return res[int((length - 1) ...
# -*- coding: utf-8 -*- DESC = "emr-2019-01-03" INFO = { "ScaleOutInstance": { "params": [ { "name": "TimeUnit", "desc": "Time unit of scale-out. Valid values:\n<li>s: seconds. When `PayMode` is 0, `TimeUnit` can only be `s`.</li>\n<li>m: month. When `PayMode` is 1, `TimeUnit` can only be `m...
desc = 'emr-2019-01-03' info = {'ScaleOutInstance': {'params': [{'name': 'TimeUnit', 'desc': 'Time unit of scale-out. Valid values:\n<li>s: seconds. When `PayMode` is 0, `TimeUnit` can only be `s`.</li>\n<li>m: month. When `PayMode` is 1, `TimeUnit` can only be `m`.</li>'}, {'name': 'TimeSpan', 'desc': 'Duration of sca...
neutral_site_fields = ['Azteca Stadium', 'Estadio Azteca', 'Tottenham Hotspur', 'Tottenham Hotspur Stadium', 'Twickenham', 'Twickenham Stadium', 'Wembley', 'Wembley Stadium'] standardized_field_names = { 'Arrowhead Stadium': 'Arrowhead Stadium', 'AT&T': 'AT&T Stadium', 'AT&T Stadium': 'AT&T Stadium', 'Ba...
neutral_site_fields = ['Azteca Stadium', 'Estadio Azteca', 'Tottenham Hotspur', 'Tottenham Hotspur Stadium', 'Twickenham', 'Twickenham Stadium', 'Wembley', 'Wembley Stadium'] standardized_field_names = {'Arrowhead Stadium': 'Arrowhead Stadium', 'AT&T': 'AT&T Stadium', 'AT&T Stadium': 'AT&T Stadium', 'Bank of America': ...
""" _ _ _ _ (_) | | (_) | ___ _ _ __ ___ _ __ | | ___ _ __ ___ __ _ _| | / __| | '_ ` _ \| '_ \| |/ _ \ | '_ ` _ \ / _` | | | \__ \ | | | | | | |_) | | __/ | | | | | | (_| | | | |___/_|_| |_| |_| .__/|_|\___| |_| |_| |_|\__,_|_|_...
""" _ _ _ _ (_) | | (_) | ___ _ _ __ ___ _ __ | | ___ _ __ ___ __ _ _| | / __| | '_ ` _ \\| '_ \\| |/ _ \\ | '_ ` _ \\ / _` | | | \\__ \\ | | | | | | |_) | | __/ | | | | | | (_| | | | |___/_|_| |_| |_| .__/|_|\\___| |_| |_| |_|\\...
privKey = "" with open ('privKey.txt', 'rt') as myfile: # Open file lorem.txt for reading text for myline in myfile: # For each line, read it to a string print(myline) if myline == "Your ETH privkey derived from seed:": print(myline) #Doesnt do anything, just holds that line ...
priv_key = '' with open('privKey.txt', 'rt') as myfile: for myline in myfile: print(myline) if myline == 'Your ETH privkey derived from seed:': print(myline) else: priv_key = myline print(privKey) f = open('privKey.txt', 'w') f.write(privKey) f.close()
class MinisyncError(Exception): pass class PermissionError(MinisyncError): pass
class Minisyncerror(Exception): pass class Permissionerror(MinisyncError): pass
# https://leetcode.com/problems/repeated-string-match/ class Solution(object): def repeatedStringMatch(self, A, B): """ :type A: str :type B: str :rtype: int """ repeat = 0 sr = A while len(A) <= 10000: if B in A: return repeat + 1 else: A = A + sr repeat += 1 return -1
class Solution(object): def repeated_string_match(self, A, B): """ :type A: str :type B: str :rtype: int """ repeat = 0 sr = A while len(A) <= 10000: if B in A: return repeat + 1 else: a = A + sr repeat ...
def result(x1, y1, x2, y2): num_list = [x1, y1, x2, y2] for _ in range(2): num_list.remove(max(num_list)) f = num_list[0] g = num_list[1] print(f"({f}, {g})") print(f"({', '.join(num_list)})") a = int(input()) b = int(input()) c = int(input()) d = int(input()) result(a, b, c, d)
def result(x1, y1, x2, y2): num_list = [x1, y1, x2, y2] for _ in range(2): num_list.remove(max(num_list)) f = num_list[0] g = num_list[1] print(f'({f}, {g})') print(f"({', '.join(num_list)})") a = int(input()) b = int(input()) c = int(input()) d = int(input()) result(a, b, c, d)
class Number: def __init__(self, num): self.num = num def __add__(self, num2): print("Lets add") return self.num + num2.num def __mul__(self, num2): print("Lets multiply") return self.num * num2.num n1 = Number(4) n2 = Number(6) sum = n1 + n2 mul = n...
class Number: def __init__(self, num): self.num = num def __add__(self, num2): print('Lets add') return self.num + num2.num def __mul__(self, num2): print('Lets multiply') return self.num * num2.num n1 = number(4) n2 = number(6) sum = n1 + n2 mul = n1 * n2 print(su...
# Module : kilo_to_mile_converter # Description : This program program asks # the user to enter a distance in kilometers, # and then converts that distance to miles with this formula # Miles = Kilometers * 0.6214 # Programmer : William Kpabitey Kwabla # Date : 05/04/16 # Def...
def main(): intro() kilometers = float(input('Please Enter Distance in Kilometers: ')) print() kilo_to_mile(kilometers) def intro(): print('This program program asks') print('the user to enter a distance in kilometers,') print('and then converts that distance to miles with this formula') ...
# -*- coding: utf-8 -*- class ThreadSafeCreateMixin(object): """ ThreadSafeCreateMixin can be used as an inheritance of thread safe backend implementations """ @classmethod def create(cls): """ Return always a new instance of the backend class """ return cls() ...
class Threadsafecreatemixin(object): """ ThreadSafeCreateMixin can be used as an inheritance of thread safe backend implementations """ @classmethod def create(cls): """ Return always a new instance of the backend class """ return cls() class Singletoncreatemixi...
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def invertTree(self, root: TreeNode) -> TreeNode: self.rec(root) return root def rec(sel...
class Solution: def invert_tree(self, root: TreeNode) -> TreeNode: self.rec(root) return root def rec(self, root): if root is None: return if root.left is None and root.right is None: return self.rec(root.left) self.rec(root.right) ...
NAMES = ['arnold SchwArzenegger', 'alEc Baldwin', 'Bob belderbos', 'julian sequeira', 'Sandra Bullock', 'keAnu reeves', 'julbob pybites', 'Bob Belderbos', 'julian sequeira', 'Al Pacino', 'brad pitt', 'matt damon', 'brad pitt'] def surname(inputStr): return inputStr.split()[1] def f...
names = ['arnold SchwArzenegger', 'alEc Baldwin', 'Bob belderbos', 'julian sequeira', 'Sandra Bullock', 'keAnu reeves', 'julbob pybites', 'Bob Belderbos', 'julian sequeira', 'Al Pacino', 'brad pitt', 'matt damon', 'brad pitt'] def surname(inputStr): return inputStr.split()[1] def firstname(inputStr): return l...
# n ==> Size of circle # m ==> Number of items # k ==> Initial position def lastPosition(n, m, k): if (m<=n-k+1): return m+k-1 m=m-(n-k+1) if(m%n==0): return n else: return m%n # Driver code n = 5 m = 8 k = 2 ans=lastPosition(n, m, k) print(ans)
def last_position(n, m, k): if m <= n - k + 1: return m + k - 1 m = m - (n - k + 1) if m % n == 0: return n else: return m % n n = 5 m = 8 k = 2 ans = last_position(n, m, k) print(ans)
def get_yes_or_no_input(prompt): """ Prompts the user for a y/n answer returns True if yes, and False if no :param prompt: (String) prompt for input. :return: (Boolean) True for Yes False for No """ while True: value = input(prompt + " [y/n]: ") if v...
def get_yes_or_no_input(prompt): """ Prompts the user for a y/n answer returns True if yes, and False if no :param prompt: (String) prompt for input. :return: (Boolean) True for Yes False for No """ while True: value = input(prompt + ' [y/n]: ') if v...
""" Main Orange Canvas Application and supporting classes. """
""" Main Orange Canvas Application and supporting classes. """
# Given a non-negative integer x, compute and return the square root of x. # Since the return type is an integer, the decimal digits are truncated, # and only the integer part of the result is returned. # Note: You are not allowed to use any built-in exponent function or operator, # such as pow(x, 0.5) or x ** 0.5. ...
class Initialsolution: def my_sqrt(self, x: int) -> int: (start, end) = (0, x) while start <= end: mid = start + (end - start) // 2 square = mid * mid if square > x: end = mid - 1 elif square < x: start = mid + 1 ...
def get_color(code): # write your answer between #start and #end #start return '' #end print('Test 1') print('Expected:Red') result = get_color ('R') print('Actual :' + result) print() print('Test 2') print('Expected:Green') result = get_color ('g') print('Actual :' + result) print() print('Test...
def get_color(code): return '' print('Test 1') print('Expected:Red') result = get_color('R') print('Actual :' + result) print() print('Test 2') print('Expected:Green') result = get_color('g') print('Actual :' + result) print() print('Test 3') print('Expected:Blue') result = get_color('B') print('Actual :' + resu...