content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
lower = int(input('Min: ')) upper = int(input('Max: ')) for num in range(lower, upper + 1): sum = 0 n = len(str(num)) temp = num while temp > 0: digit = temp % 10 sum += digit ** n temp //= 10 if num == sum: print(num)
lower = int(input('Min: ')) upper = int(input('Max: ')) for num in range(lower, upper + 1): sum = 0 n = len(str(num)) temp = num while temp > 0: digit = temp % 10 sum += digit ** n temp //= 10 if num == sum: print(num)
def linearRegression(px,py): sumx = 0 sumy = 0 sumxy = 0 sumxx = 0 n = len (px) for i in range(n): x = px[i] y = py[i] sumx += x sumy += y sumxx += x*x sumxy += x*y a=(sumxy-sumx*sumy/n)/(sumxx-(sumx**2)/n) b=(sumy-a*sumx)/n print(su...
def linear_regression(px, py): sumx = 0 sumy = 0 sumxy = 0 sumxx = 0 n = len(px) for i in range(n): x = px[i] y = py[i] sumx += x sumy += y sumxx += x * x sumxy += x * y a = (sumxy - sumx * sumy / n) / (sumxx - sumx ** 2 / n) b = (sumy - a ...
expected_output = { "vrf": { "default": { "interfaces": { "GigabitEthernet1": { "address_family": { "ipv4": { "dr_priority": 1, "hello_interval": 30, "n...
expected_output = {'vrf': {'default': {'interfaces': {'GigabitEthernet1': {'address_family': {'ipv4': {'dr_priority': 1, 'hello_interval': 30, 'neighbor_count': 1, 'version': 2, 'mode': 'sparse-mode', 'dr_address': '10.1.2.2', 'address': ['10.1.2.1']}}}, 'GigabitEthernet2': {'address_family': {'ipv4': {'dr_priority': 1...
# Tic-Tac-Toe 3x3 game game = [[" ", " ", " "], [" ", " ", " "], [" ", " ", " "]] players = ["X", "O"] current_player = 0 GAME_CONTINUES = -1 DRAW = -2 # if a player won, number of that player is returned def print_state(game_state): for line in range(3): print(*game_state[line], sep=" |...
game = [[' ', ' ', ' '], [' ', ' ', ' '], [' ', ' ', ' ']] players = ['X', 'O'] current_player = 0 game_continues = -1 draw = -2 def print_state(game_state): for line in range(3): print(*game_state[line], sep=' | ') if line != 2: print('--+---+--') def move(): try: move = i...
# OpenWeatherMap API Key weather_api_key = "6006d361789a66a63d965d32098db97e" # Google API Key g_key = "AIzaSyBkES3rvs8W2Uv7OJXtnd7i86WvOSEJp7A"
weather_api_key = '6006d361789a66a63d965d32098db97e' g_key = 'AIzaSyBkES3rvs8W2Uv7OJXtnd7i86WvOSEJp7A'
_4digit: grove.TM1637 = None def on_forever(): global _4digit if input.button_is_pressed(Button.A): _4digit = grove.create_display(DigitalPin.C16, DigitalPin.C17) _4digit.bit(1, 3) basic.pause(1000) _4digit.bit(2, 3) basic.pause(1000) _4digit.bit(3, 3) ...
_4digit: grove.TM1637 = None def on_forever(): global _4digit if input.button_is_pressed(Button.A): _4digit = grove.create_display(DigitalPin.C16, DigitalPin.C17) _4digit.bit(1, 3) basic.pause(1000) _4digit.bit(2, 3) basic.pause(1000) _4digit.bit(3, 3) ba...
class Solution: def gardenNoAdj(self, N: int, paths: List[List[int]]) -> List[int]: res = [0] * N G = [[] for i in range(N)] for x,y in paths: G[x-1].append(y-1) G[y-1].append(x-1) for i in range(N): res[i] = ({1,2,3,4} - {res[j] for j in G[i]}).po...
class Solution: def garden_no_adj(self, N: int, paths: List[List[int]]) -> List[int]: res = [0] * N g = [[] for i in range(N)] for (x, y) in paths: G[x - 1].append(y - 1) G[y - 1].append(x - 1) for i in range(N): res[i] = ({1, 2, 3, 4} - {res[j] f...
input_file = open("input.txt", "r") entriesArray = input_file.read().split("\n") depth_measure_increase = 0 for i in range(1, len(entriesArray), 1): if int(entriesArray[i]) > int(entriesArray[i-1]): depth_measure_increase += 1 print(f'{depth_measure_increase=}')
input_file = open('input.txt', 'r') entries_array = input_file.read().split('\n') depth_measure_increase = 0 for i in range(1, len(entriesArray), 1): if int(entriesArray[i]) > int(entriesArray[i - 1]): depth_measure_increase += 1 print(f'depth_measure_increase={depth_measure_increase!r}')
class TranslationMissing(Exception): # Exception for commands which currently do not support translation. def __init__(self, name): super().__init__( f"Translation for the command {name} is not currently supported" )
class Translationmissing(Exception): def __init__(self, name): super().__init__(f'Translation for the command {name} is not currently supported')
MONGO_SERVER_CONFIG = { 'host': 'mongo', 'port': 27017, 'username': 'spark-user', 'password': 'spark123' } MONGO_DATABASE_CONFIG = { 'DATABASE_NAME': 'video_games_analysis', 'COLLECTION_NAME': 'games' }
mongo_server_config = {'host': 'mongo', 'port': 27017, 'username': 'spark-user', 'password': 'spark123'} mongo_database_config = {'DATABASE_NAME': 'video_games_analysis', 'COLLECTION_NAME': 'games'}
# Authors: Hyunwoo Lee <hyunwoo9301@naver.com> # Released under the MIT license. def read_data(file): with open(file, 'r', encoding="utf-8") as f: data = [line.split('\t') for line in f.read().splitlines()] data = data[1:] return data
def read_data(file): with open(file, 'r', encoding='utf-8') as f: data = [line.split('\t') for line in f.read().splitlines()] data = data[1:] return data
class Rounder: def round(self, n, b): m = n%b return n-m if m < (b/2 + b%2) else n+b-m
class Rounder: def round(self, n, b): m = n % b return n - m if m < b / 2 + b % 2 else n + b - m
# Copyright (c) 2012 The Native Client Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. # Build the specific library dependencies for validating on x86-64 { 'includes': [ '../../../../../build/common.gypi', ], 'target_defaults...
{'includes': ['../../../../../build/common.gypi'], 'target_defaults': {'variables': {'target_base': 'none'}, 'target_conditions': [['target_base=="ncvalidate_x86_64"', {'sources': ['ncvalidate.c'], 'cflags!': ['-Wextra', '-Wswitch-enum', '-Wsign-compare'], 'defines': ['NACL_TRUSTED_BUT_NOT_TCB'], 'xcode_settings': {'WA...
n1 = int(input('enter first number: ')) n2 = int(input('enter second number: ')) print('Sum: ', int(n1+n2))
n1 = int(input('enter first number: ')) n2 = int(input('enter second number: ')) print('Sum: ', int(n1 + n2))
n1=480 n2=10 soma=0 for i in range (0,30,1): div=n1/n2 if i%2==0: soma=soma+div else: soma=soma-div n1=n1-5 n2=n2+1 print(soma)
n1 = 480 n2 = 10 soma = 0 for i in range(0, 30, 1): div = n1 / n2 if i % 2 == 0: soma = soma + div else: soma = soma - div n1 = n1 - 5 n2 = n2 + 1 print(soma)
''' ALU for CPU ''' bit = 0 | 1 byte = 8 * bit def adder(num1: bit, num2: bit, carry: bit) -> [bit, bit]: x = num1 ^ num2 s = x ^ carry a = x & carry b = num1 & num2 c = a | b return [c, s] def adder4bit(num1: byte, num2: byte) -> [bit, byte]: carry, a = adder(int(num1[3]), int(num2[3]),...
""" ALU for CPU """ bit = 0 | 1 byte = 8 * bit def adder(num1: bit, num2: bit, carry: bit) -> [bit, bit]: x = num1 ^ num2 s = x ^ carry a = x & carry b = num1 & num2 c = a | b return [c, s] def adder4bit(num1: byte, num2: byte) -> [bit, byte]: (carry, a) = adder(int(num1[3]), int(num2[3]),...
def dot(self, name, content): path = j.sal.fs.getTmpFilePath() j.sal.fs.writeFile(filename=path, contents=content) dest = j.sal.fs.joinPaths(j.sal.fs.getDirName(self.last_dest), "%s.png" % name) j.do.execute("dot '%s' -Tpng > '%s'" % (path, dest)) j.sal.fs.remove(path) return "![%s.png](%s.png)...
def dot(self, name, content): path = j.sal.fs.getTmpFilePath() j.sal.fs.writeFile(filename=path, contents=content) dest = j.sal.fs.joinPaths(j.sal.fs.getDirName(self.last_dest), '%s.png' % name) j.do.execute("dot '%s' -Tpng > '%s'" % (path, dest)) j.sal.fs.remove(path) return '![%s.png](%s.png)'...
class PagedList(list): def __init__(self, items, token): super(PagedList, self).__init__(items) self.token = token
class Pagedlist(list): def __init__(self, items, token): super(PagedList, self).__init__(items) self.token = token
class CircularQueuek: def __init__(self, k: int): self.queue = [0 for _ in range(k)] self.k = k self.front = 0 self.rear = -1 self.length = 0 def enQueue(self, value): if self.length < self.k: self.length = self.length +1 self.rear = (self...
class Circularqueuek: def __init__(self, k: int): self.queue = [0 for _ in range(k)] self.k = k self.front = 0 self.rear = -1 self.length = 0 def en_queue(self, value): if self.length < self.k: self.length = self.length + 1 self.rear = (s...
n=(int)(input()) dict1={} dict2={} c1=0 while(n>0): n-=1 str1=(input().split(" ")) if(str1[0] not in dict1.keys()): dict1[str1[0]]=str1[1] if(str1[1] not in dict2.keys()): dict2[str1[1]]=1 else: dict2[str1[1]]+=1 c1=max(dict2.values()) for i in dict2.key...
n = int(input()) dict1 = {} dict2 = {} c1 = 0 while n > 0: n -= 1 str1 = input().split(' ') if str1[0] not in dict1.keys(): dict1[str1[0]] = str1[1] if str1[1] not in dict2.keys(): dict2[str1[1]] = 1 else: dict2[str1[1]] += 1 c1 = max(dict2.values()) for i in dict2.keys(): ...
# config files CONFIG_DIR = "config" # Link to DB Configuration DB_CONFIG_FILE = "db.yml" # Name of collection COLLECTION_NAME = 'collection_name' CONFIG_DIR = "config" CONFIG_FNAME = "rss_feeds.yml" PARAM_CONFIG_FILE = "services.yml" APP_KEYS_FILE = "keys.yml" NLU_CONFIG = "nlu_config.yml" MESSAGING_FILE = "messagin...
config_dir = 'config' db_config_file = 'db.yml' collection_name = 'collection_name' config_dir = 'config' config_fname = 'rss_feeds.yml' param_config_file = 'services.yml' app_keys_file = 'keys.yml' nlu_config = 'nlu_config.yml' messaging_file = 'messaging_platforms.yml' socialmedia_file = 'socialmedia.yml' email_file ...
''' URL: https://leetcode.com/problems/build-an-array-with-stack-operations/ Difficulty: Easy Description: Build an Array With Stack Operations Given an array target and an integer n. In each iteration, you will read a number from list = {1,2,3..., n}. Build the target array using the following operations: Push: ...
""" URL: https://leetcode.com/problems/build-an-array-with-stack-operations/ Difficulty: Easy Description: Build an Array With Stack Operations Given an array target and an integer n. In each iteration, you will read a number from list = {1,2,3..., n}. Build the target array using the following operations: Push: ...
#!/usr/bin/python # Copyright 2017 Mirantis, 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 a...
""" Management of Contrail resources ================================ :depends: - vnc_api Python module Enforce the virtual router existence ------------------------------------ .. code-block:: yaml virtual_router: contrail.virtual_router_present: name: tor01 ip_address: 10.0.0.23 ...
# There's a function blackbox(lst) that takes a list, does some magic, and returns a list. # You don't know if it modifies the given list or creates a completely different one. # Find this out testing the function on your own list and print "modifies" if the fu # blackbox(lst) # print("modifies") # if the function ch...
football_list = ['Liverpool Football Club', 'English Premier League', 'Champion 2019-2020'] football_list_id = id(football_list) new_list = blackbox(football_list) new_list_id = id(new_list) if football_list_id == new_list_id: print('modifies') else: print('new')
# Path to the root location of the application inside the container. APP_ROOT = '/intend4' # Configuration directory, inside the application CONFIG_DIR = "{}/config".format(APP_ROOT) # Logging level LOG_LEVEL = 'INFO' # CRITICAL / ERROR / WARNING / INFO / DEBUG
app_root = '/intend4' config_dir = '{}/config'.format(APP_ROOT) log_level = 'INFO'
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: # @return a ListNode def removeNthFromEnd(self, head, n): if head is None: return None nodes = [] p = head while p : ...
class Solution: def remove_nth_from_end(self, head, n): if head is None: return None nodes = [] p = head while p: nodes.append(p) p = p.next if n == len(nodes): return nodes[1] if len(nodes) > 1 else None else: ...
# # Automatically generated # class Asm6502(object): pass Asm6502.BRK = 0x00 Asm6502.ORA_IX = 0x01 Asm6502.ORA_Z = 0x05 Asm6502.ASL_Z = 0x06 Asm6502.PHP = 0x08 Asm6502.ORA_IM = 0x09 Asm6502.ASL = 0x0A Asm6502.ORA_A = 0x0D Asm6502.ASL_A = 0x0E Asm6502.BPL = 0x10 ...
class Asm6502(object): pass Asm6502.BRK = 0 Asm6502.ORA_IX = 1 Asm6502.ORA_Z = 5 Asm6502.ASL_Z = 6 Asm6502.PHP = 8 Asm6502.ORA_IM = 9 Asm6502.ASL = 10 Asm6502.ORA_A = 13 Asm6502.ASL_A = 14 Asm6502.BPL = 16 Asm6502.ORA_IY = 17 Asm6502.ORA_ZX = 21 Asm6502.ASL_ZX = 22 Asm6502.CLC = 24 Asm6502.ORA_AY = 25 Asm6502.ORA_A...
class WindowPosition: position = [] def get(self, quantity, pos_x, pos_y, width, height): if quantity == 1: self.position.append({'pos_x': pos_x, 'pos_y': pos_y, 'width': width, 'height': height}) else: height_ratio = height * 4 / 3 # TODO hard coded 4:3 ratio ...
class Windowposition: position = [] def get(self, quantity, pos_x, pos_y, width, height): if quantity == 1: self.position.append({'pos_x': pos_x, 'pos_y': pos_y, 'width': width, 'height': height}) else: height_ratio = height * 4 / 3 if width > height_ratio: ...
#! python3 # __author__ = "YangJiaHao" # date: 2018/12/25 def duplicate(nums): length = len(nums) for n in nums: if n < 0 or n >= length: return False for i in range(len(nums)): while nums[i] != i: if nums[i] == nums[nums[i]]: return nums[i] ...
def duplicate(nums): length = len(nums) for n in nums: if n < 0 or n >= length: return False for i in range(len(nums)): while nums[i] != i: if nums[i] == nums[nums[i]]: return nums[i] else: (nums[i], nums[nums[i]]) = (nums[n...
#!/usr/bin/env python3 PIKS_DEFAULT_DIR=".piks" PIKS_DEFAULT_FILE="piks.db" PIKS_DEFAULT_CHECKSUM="sha512" if __name__ == "__main__": pass
piks_default_dir = '.piks' piks_default_file = 'piks.db' piks_default_checksum = 'sha512' if __name__ == '__main__': pass
categories = { 'Network Stereo Zone Amplifier', 'Network Stereo Receiver', 'Portable Player', 'Media Player', 'Network Streamer', 'Network player & Preamplifier', 'CD Player', 'Speaker', 'DAC', 'CD player', 'Streaming DAC', 'DAC & Network Streamer', 'DAC & Headphone Amp', 'Network Audio & CD...
categories = {'Network Stereo Zone Amplifier', 'Network Stereo Receiver', 'Portable Player', 'Media Player', 'Network Streamer', 'Network player & Preamplifier', 'CD Player', 'Speaker', 'DAC', 'CD player', 'Streaming DAC', 'DAC & Network Streamer', 'DAC & Headphone Amp', 'Network Audio & CD Player', 'All-in-One', 'Wire...
#return True if sum of any two num in list equals key O(n) num=[] n=int(input()) for x in range(n): num.append(int(input())) key=int(input()) for x in range(n): if key-num[x] in num: print(True) exit() #quit() print(None)
num = [] n = int(input()) for x in range(n): num.append(int(input())) key = int(input()) for x in range(n): if key - num[x] in num: print(True) exit() print(None)
class Order(): ASCENDING = 0 # lower is better DESCENDING = 1 # higher is better class Format(): ANONYMOUS = 0b0001 NAMED = 0b0010 LEADERBOARD = 0b0100 LIST = 0b1000 Delim = '|' KeyScorePosition = -1 # indeks v rezultatu, po katerem sortiramo ExpectedNicknamePosition = 10000 # indeks nickn...
class Order: ascending = 0 descending = 1 class Format: anonymous = 1 named = 2 leaderboard = 4 list = 8 delim = '|' key_score_position = -1 expected_nickname_position = 10000 labels = ['no label'] file_name = 'LEADERBOARDS.txt' output_format = Format.LEADERBOARD | Format.NAMED output_order = O...
n = int(input()) triangleList = [] for i in range(n): temp = [] if i == 0: temp.append(1) else: for j in range(i+1): if j==0 or j==i: temp.append(triangleList[i-1][j-1]) else: temp.append(triangleList[i-1][j]+triangleList[i-1...
n = int(input()) triangle_list = [] for i in range(n): temp = [] if i == 0: temp.append(1) else: for j in range(i + 1): if j == 0 or j == i: temp.append(triangleList[i - 1][j - 1]) else: temp.append(triangleList[i - 1][j] + triangleList...
# Copyright (c) 2020 The DAML Authors. All rights reserved. # SPDX-License-Identifier: Apache-2.0 lf_stable_version = "1.6" lf_latest_version = "1.7" lf_dev_version = "1.dev" lf_versions = [lf_stable_version, lf_latest_version, lf_dev_version]
lf_stable_version = '1.6' lf_latest_version = '1.7' lf_dev_version = '1.dev' lf_versions = [lf_stable_version, lf_latest_version, lf_dev_version]
class PluginBase(object): def run(self, **kwargs): err = "Error, this is an abstract method " \ "you need implement this in a derived class" raise NotImplementedError(err) class PluginDescription(object): def __init__(self, name, author, ...
class Pluginbase(object): def run(self, **kwargs): err = 'Error, this is an abstract method you need implement this in a derived class' raise not_implemented_error(err) class Plugindescription(object): def __init__(self, name, author, short_desc, long_desc, help_str, instance): self.n...
# -*- coding: utf-8 -*- config = dict( age_config={ "feature_name": "age", "feature_data_type": "int", "default_value": "PositiveSignedTypeDefault", "json_path_list": [("age", "$..content.age", "f_assert_not_null->f_assert_must_digit_or_float")], "f_map_and_filter_chain": "m_...
config = dict(age_config={'feature_name': 'age', 'feature_data_type': 'int', 'default_value': 'PositiveSignedTypeDefault', 'json_path_list': [('age', '$..content.age', 'f_assert_not_null->f_assert_must_digit_or_float')], 'f_map_and_filter_chain': 'm_get_seq_index_value(0)', 'reduce_chain': '', 'l_map_and_filter_chain':...
# # @lc app=leetcode id=309 lang=python3 # # [309] Best Time to Buy and Sell Stock with Cooldown # # @lc code=start class Solution: def maxProfit(self, prices: List[int]) -> int: if len(prices) < 2: return 0 s0 = 0 s1 = -prices[0] s2 = float('-inf') for i in rang...
class Solution: def max_profit(self, prices: List[int]) -> int: if len(prices) < 2: return 0 s0 = 0 s1 = -prices[0] s2 = float('-inf') for i in range(len(prices)): pre0 = s0 pre1 = s1 pre2 = s2 s0 = max(pre0, pre2) ...
class ArgumentsMethods(object): def add_arguments(self, parser): parser.add_argument( "states", nargs="+", help="States to export by FIPS code." )
class Argumentsmethods(object): def add_arguments(self, parser): parser.add_argument('states', nargs='+', help='States to export by FIPS code.')
# Programa recebe uma lista e transforma em uma strng separada por ',' e and antecedendo o ultimo elemento. def concatenar(lista): temporario = '' index = 0 for item in lista: if index == len(lista)-1: temporario += f'and {item}.' else: temporario += f'{item}, ' ...
def concatenar(lista): temporario = '' index = 0 for item in lista: if index == len(lista) - 1: temporario += f'and {item}.' else: temporario += f'{item}, ' index += 1 return temporario spam = ['apples', 'bananas', 'tofu', 'cats', 1] print(concatenar(spam)...
MESSAGES = dict({ "1": "\n\nData provided for method __init__() of class Feature \n" "was not correct to create dict() object", "2": "\n\nFeature object is not a valid geojson feature object, \n" "one of the following failed, geometry, properties or type field are missing \n", "3": "\n\nCo...
messages = dict({'1': '\n\nData provided for method __init__() of class Feature \nwas not correct to create dict() object', '2': '\n\nFeature object is not a valid geojson feature object, \none of the following failed, geometry, properties or type field are missing \n', '3': '\n\nCoordinates Array Items must be of floa...
# parsetab.py # This file is automatically generated. Do not edit. # pylint: disable=W,C,R _tabversion = '3.10' _lr_method = 'LALR' _lr_signature = 'leftTYPECASTrightUMINUSrightUNOTleftMASMENOSleftPOTENCIAleftPORDIVRESIDUOleftANDORSIMBOLOOR2SIMBOLOORSIMBOLOAND2leftDESPLAZAMIENTOIZQUIERDADESPLAZAMIENTODERECHAABS ACOS...
_tabversion = '3.10' _lr_method = 'LALR' _lr_signature = 'leftTYPECASTrightUMINUSrightUNOTleftMASMENOSleftPOTENCIAleftPORDIVRESIDUOleftANDORSIMBOLOOR2SIMBOLOORSIMBOLOAND2leftDESPLAZAMIENTOIZQUIERDADESPLAZAMIENTODERECHAABS ACOS ACOSD ACOSH ADD ALL ALTER AND ANY AS ASC ASIN ASIND ASINH ATAN ATAN2 ATAN2D ATAND ATANH AUTO_...
def read(filename): with open(filename, "r") as file: lines = file.readlines() result = {} mode = "main" result[mode] = {} for i in lines: i = i.replace("\n", "") if i.startswith(" "): i = i[4:] if i.startswith(" "): i ...
def read(filename): with open(filename, 'r') as file: lines = file.readlines() result = {} mode = 'main' result[mode] = {} for i in lines: i = i.replace('\n', '') if i.startswith(' '): i = i[4:] if i.startswith(' '): i = i[2:] if '/...
description = '' pages = ['header'] def setup(data): pass def test(data): navigate('http://store.demoqa.com/') click(header.my_account) verify_text('You must be logged in to use this page. Please use the form below to login to your account.') def teardown(data): pass
description = '' pages = ['header'] def setup(data): pass def test(data): navigate('http://store.demoqa.com/') click(header.my_account) verify_text('You must be logged in to use this page. Please use the form below to login to your account.') def teardown(data): pass
mystr = "banana" for x in mystr: print(x)
mystr = 'banana' for x in mystr: print(x)
FETCH_DATA_SOURCES_SQL = "select description, downloaded, url, data_source_type, group_name " \ "from data_source " \ "order by downloaded, group_name, description;" class DataSourcesQueryNames(object): DESCRIPTION = 'description' DOWNLOADED = 'downloaded' ...
fetch_data_sources_sql = 'select description, downloaded, url, data_source_type, group_name from data_source order by downloaded, group_name, description;' class Datasourcesquerynames(object): description = 'description' downloaded = 'downloaded' url = 'url' data_source_type = 'data_source_type' gr...
geral = {} aproveitamento = list() geral['nome'] = str(input('Nome jogador: ')) partidas = int(input(f'Quantas partidas {geral["nome"]} jogou ?')) count = 0 total = 0 while count < partidas: gols_games = (int(input(f'Quantos gols na partida {count}?'))) aproveitamento.append(gols_games) total = total + gol...
geral = {} aproveitamento = list() geral['nome'] = str(input('Nome jogador: ')) partidas = int(input(f"Quantas partidas {geral['nome']} jogou ?")) count = 0 total = 0 while count < partidas: gols_games = int(input(f'Quantos gols na partida {count}?')) aproveitamento.append(gols_games) total = total + gols_g...
INTEGER = "int" FLOAT = "float" BOOLEAN = "bool" STRING = "str" EMAIL = "email" ALPHA = "alpha" ALPHANUMERIC = "alphanumeric" STD = "std" LIST = "list" DICT = "dict" FILE = "file" ALLOWED_TYPES = {INTEGER: {"type": "integer"}, FLOAT: {"type": "number"}, BOOLEAN: {"type": "boolean"}, STRING: {"type": "string"}, ...
integer = 'int' float = 'float' boolean = 'bool' string = 'str' email = 'email' alpha = 'alpha' alphanumeric = 'alphanumeric' std = 'std' list = 'list' dict = 'dict' file = 'file' allowed_types = {INTEGER: {'type': 'integer'}, FLOAT: {'type': 'number'}, BOOLEAN: {'type': 'boolean'}, STRING: {'type': 'string'}, EMAIL: {...
APP_ID_TO_ARN_IDS = { 'co.justyo.yoapp': [ 'ios', 'ios-beta', 'ios-development', 'android', 'winphone' ], 'co.justyo.yopolls': [ 'com.flashpolls.beta.dev', 'com.flashpolls.beta.prod', 'com.flashpolls.flashpolls.dev', 'com.flashpolls....
app_id_to_arn_ids = {'co.justyo.yoapp': ['ios', 'ios-beta', 'ios-development', 'android', 'winphone'], 'co.justyo.yopolls': ['com.flashpolls.beta.dev', 'com.flashpolls.beta.prod', 'com.flashpolls.flashpolls.dev', 'com.flashpolls.flashpolls.prod', 'com.flashpolls.beta', 'com.thenet.flashpolls.dev', 'com.thenet.flashpoll...
#!/usr/bin/python zoo = ('python', 'elephant', 'penguin') # remember the parentheses are optional print('Number of animals in the zoo is', len(zoo)) new_zoo = ('monkey', 'camel', zoo) print('Number of cages in the zoo is', len(new_zoo)) print('All animals in new zoo are', new_zoo) print('Animals brought from old zoo...
zoo = ('python', 'elephant', 'penguin') print('Number of animals in the zoo is', len(zoo)) new_zoo = ('monkey', 'camel', zoo) print('Number of cages in the zoo is', len(new_zoo)) print('All animals in new zoo are', new_zoo) print('Animals brought from old zoo is', new_zoo[2]) print('last animal brought from old zoo is'...
def interest_template(isPlain, user_id, sim_percent): percent = int(sim_percent * 100) if isPlain: text = "Connect with {{user-%d}} as you have %d%% interests in common" \ % (user_id, percent) else: text = "<orange>Connect with {{user-%d}}</orange> as you have %d%% interests in common" \ % (user_id, p...
def interest_template(isPlain, user_id, sim_percent): percent = int(sim_percent * 100) if isPlain: text = 'Connect with {{user-%d}} as you have %d%% interests in common' % (user_id, percent) else: text = '<orange>Connect with {{user-%d}}</orange> as you have %d%% interests in common' % (user...
# Implementation of Binary Search # print('hello world') print(' ') # Define the Binary search variables # def binary_Search(array, start, end, x): if end >= start: # Alot the mid value # mid = (start + end) // 2 if array[mid] == x: # Array pointer equal to mid value # return mi...
print('hello world') print(' ') def binary__search(array, start, end, x): if end >= start: mid = (start + end) // 2 if array[mid] == x: return mid elif array[mid] > x: return binary__search(array, start, mid - 1, x) else: return binary__search(arr...
with open('1X-PBS_CurrentVsTime_10000sWait_Still.csv', 'r') as f: f.readline() f.readline() lastVoltage = 0.0 line = f.readline() o = None while line: splits = line.split(',') voltage = float(splits[1]) if voltage != lastVoltage: if o is not None: ...
with open('1X-PBS_CurrentVsTime_10000sWait_Still.csv', 'r') as f: f.readline() f.readline() last_voltage = 0.0 line = f.readline() o = None while line: splits = line.split(',') voltage = float(splits[1]) if voltage != lastVoltage: if o is not None: ...
length = int(input()) width = int(input()) height = int(input()) number = float(input()) volume = length * width * height total_liters = volume * 0.001 percent = number * 0.01 result = total_liters * (1 - percent) print('{0:.3f}'.format(result))
length = int(input()) width = int(input()) height = int(input()) number = float(input()) volume = length * width * height total_liters = volume * 0.001 percent = number * 0.01 result = total_liters * (1 - percent) print('{0:.3f}'.format(result))
class HandshakeRequestMessage(object): def __init__(self, protocol, version): self.protocol = protocol self.version = version
class Handshakerequestmessage(object): def __init__(self, protocol, version): self.protocol = protocol self.version = version
a, b, c = input().split(' ') a = int(a) b = int(b) c = int(c) MaiorAB = (a + b + abs(a - b)) / 2 MaiorABC = (MaiorAB + c + abs(MaiorAB - c)) / 2 print(f'{MaiorABC:.0f} eh o maior')
(a, b, c) = input().split(' ') a = int(a) b = int(b) c = int(c) maior_ab = (a + b + abs(a - b)) / 2 maior_abc = (MaiorAB + c + abs(MaiorAB - c)) / 2 print(f'{MaiorABC:.0f} eh o maior')
def while_loop(): cycle = 1 print('While loop: ') while cycle < 6: print('Inside a loop -> cycle : ', cycle) cycle = cycle + 1 print('Done - cycle =', cycle) def multiplication_table(): print(' -------------------- ') print('Multiplication table: ') number = 1; count = 1 ...
def while_loop(): cycle = 1 print('While loop: ') while cycle < 6: print('Inside a loop -> cycle : ', cycle) cycle = cycle + 1 print('Done - cycle =', cycle) def multiplication_table(): print(' -------------------- ') print('Multiplication table: ') number = 1 count = 1 ...
class Solution: def lengthOfLongestSubstring(self, s: str) -> int: # simplest case if len(s) == 0: return 0 longestSubstr = "" tempLongest = "" for i in range(0, len(s)): currentChar = s[i] tempLongest = self.getFirstNonrepeatingSubstr(s[i:]) ...
class Solution: def length_of_longest_substring(self, s: str) -> int: if len(s) == 0: return 0 longest_substr = '' temp_longest = '' for i in range(0, len(s)): current_char = s[i] temp_longest = self.getFirstNonrepeatingSubstr(s[i:]) i...
#python3 code def solution(x, y): # Your code here res = ((x+y-1)*(x+y-2))/2 + x return str(res)
def solution(x, y): res = (x + y - 1) * (x + y - 2) / 2 + x return str(res)
class GameState(object): def __init__(self, boxes, worker, parent): self.boxes = boxes self.worker = worker self.parent = parent def __eq__(self, other): return self.boxes == other.boxes and self.worker == other.worker def __hash__(self): return hash( (self.worker,...
class Gamestate(object): def __init__(self, boxes, worker, parent): self.boxes = boxes self.worker = worker self.parent = parent def __eq__(self, other): return self.boxes == other.boxes and self.worker == other.worker def __hash__(self): return hash((self.worker, ...
def parse_adjustment(data): return parse_adjustment_data(data['$objects'], data['$top']['root'].data) def parse_adjustment_data(data, root_index): out = {} for idx, key in enumerate(data[root_index]['NS.keys']): objkey = data[key.data] keyval = data[root_index]['NS.objects'][idx].data ...
def parse_adjustment(data): return parse_adjustment_data(data['$objects'], data['$top']['root'].data) def parse_adjustment_data(data, root_index): out = {} for (idx, key) in enumerate(data[root_index]['NS.keys']): objkey = data[key.data] keyval = data[root_index]['NS.objects'][idx].data ...
def binaryTreePaths(root: Optional[TreeNode]) -> List[str]: paths = [] if not root: return paths if (not root.right) and (not root.left): # This is a leaf paths.append(str(root.val)) if root.right: # append result of subtree on right paths.extend([f"{root.val}->{s...
def binary_tree_paths(root: Optional[TreeNode]) -> List[str]: paths = [] if not root: return paths if not root.right and (not root.left): paths.append(str(root.val)) if root.right: paths.extend([f'{root.val}->{subpath}' for subpath in self.binaryTreePaths(root.right)]) if roo...
class InnerClass: def __init__(self, a, b, c): self.a = a self.b = b self.c = c def generate_stuff(self): return self.a+10*self.b+100*self.c
class Innerclass: def __init__(self, a, b, c): self.a = a self.b = b self.c = c def generate_stuff(self): return self.a + 10 * self.b + 100 * self.c
def for_pentagon(): for row in range(10): for col in range(9): if (row==9) or (row>4 and (col==0 or col==8)) or (row+col==4 or col-row==4): print("*",end=" ") else: print(end=" ") print() def while_pentagon(): row=0 while r...
def for_pentagon(): for row in range(10): for col in range(9): if row == 9 or (row > 4 and (col == 0 or col == 8)) or (row + col == 4 or col - row == 4): print('*', end=' ') else: print(end=' ') print() def while_pentagon(): row = 0 w...
# Definition for a binary tree node. class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None def __repr__(self): return "{}".format(self.val) class Solution(object): # @param root, a tree node # @return a boolean # Time: N ...
class Treenode(object): def __init__(self, x): self.val = x self.left = None self.right = None def __repr__(self): return '{}'.format(self.val) class Solution(object): def is_valid_bst(self, root): output = [] self.inOrderTraversal(root, output) fo...
#https://www.hackerearth.com/practice/basic-programming/input-output/basics-of-input-output/practice-problems/algorithm/two-strings-4/ entry = int(input()) for i in range(entry): string1, string2 = input().split() for c in string1: if c in string2: string1 = string1.replace(c, '', 1) string2 = stri...
entry = int(input()) for i in range(entry): (string1, string2) = input().split() for c in string1: if c in string2: string1 = string1.replace(c, '', 1) string2 = string2.replace(c, '', 1) if len(string1) + len(string2) > 1: print('NO') else: print('YES')
#a1q2c.py #HUGHXIE #input for color and time from light color = input("What color is the light? (G/Y/R) :") speed = float(input("Enter speed of car in m/s: ")) distance = float(input("Enter distance from light in meters: ")) time = (distance / speed) #checks if color is red and time is greater than 2 or color is yell...
color = input('What color is the light? (G/Y/R) :') speed = float(input('Enter speed of car in m/s: ')) distance = float(input('Enter distance from light in meters: ')) time = distance / speed if color == 'R' and time <= 2 or (color == 'Y' and time <= 5) or color == 'G': print('Go') else: print('Stop')
def without_end(str): if len(str) == 2: return '' else: str = str[1:] l = len(str) -1 str = str[:l] return str
def without_end(str): if len(str) == 2: return '' else: str = str[1:] l = len(str) - 1 str = str[:l] return str
inFile = open("/etc/php5/fpm/pool.d/www.conf", "r", encoding = "utf-8") string = inFile.read() string = string.replace("pm.max_children = 5", "pm.max_children = 100") inFile.close() out = open("/etc/php5/fpm/pool.d/www.conf", "w", encoding = "utf-8") out.write(string) out.close()
in_file = open('/etc/php5/fpm/pool.d/www.conf', 'r', encoding='utf-8') string = inFile.read() string = string.replace('pm.max_children = 5', 'pm.max_children = 100') inFile.close() out = open('/etc/php5/fpm/pool.d/www.conf', 'w', encoding='utf-8') out.write(string) out.close()
class Calculator(): def __init__(self, number_1, number_2): self.number_1 = number_1 self.number_2 = number_2 def add(self): return self.number_1 + self.number_2 def subtract(self): return self.number_1 - self.number_2 def multiply(self): return self.number_1 ...
class Calculator: def __init__(self, number_1, number_2): self.number_1 = number_1 self.number_2 = number_2 def add(self): return self.number_1 + self.number_2 def subtract(self): return self.number_1 - self.number_2 def multiply(self): return self.number_1 * ...
happy_nums = set() happy_nums.add(1) class Solution: def sqrSum(self, n: int) -> int: res = 0 for c in str(n): res += int(c)**2 return res def isHappy(self, n: int) -> bool: global happy_nums temp = set() while True: sqr = self.sqrSum(n...
happy_nums = set() happy_nums.add(1) class Solution: def sqr_sum(self, n: int) -> int: res = 0 for c in str(n): res += int(c) ** 2 return res def is_happy(self, n: int) -> bool: global happy_nums temp = set() while True: sqr = self.sqrSu...
def swap(lst): if len(lst) < 2: return lst first = lst[0] last = lst[-1] return [last] + lst[1:-1] + [first] print(swap([12, 35, 9, 56, 24])) print(swap([1, 2, 3]))
def swap(lst): if len(lst) < 2: return lst first = lst[0] last = lst[-1] return [last] + lst[1:-1] + [first] print(swap([12, 35, 9, 56, 24])) print(swap([1, 2, 3]))
a, b, c = input().split(" ") a = int(a) b = int(b) c = int(c) if (c < a + b) and (b < c + a) and (a < b + c) and (0 < a,b,c < 10**5): if((a != b and b == c) or ( a == c and a != b) or ( a == b and c != b)): print("Valido-Isoceles") if ((a**2 == b**2 + c**2) or (b**2 == a**2 + c**2) or (c**2 == b**2...
(a, b, c) = input().split(' ') a = int(a) b = int(b) c = int(c) if c < a + b and b < c + a and (a < b + c) and (0 < a, b, c < 10 ** 5): if a != b and b == c or (a == c and a != b) or (a == b and c != b): print('Valido-Isoceles') if a ** 2 == b ** 2 + c ** 2 or b ** 2 == a ** 2 + c ** 2 or c ** 2 == ...
def main(): f = [line.rstrip("\n") for line in open("Data.txt")] coordinates = [] for line in f: coordinate = [int(i) for i in line.split(", ")] coordinates.append(coordinate) count = 0 for i in range(400): for j in range(400): sum_ = 0 for coordinat...
def main(): f = [line.rstrip('\n') for line in open('Data.txt')] coordinates = [] for line in f: coordinate = [int(i) for i in line.split(', ')] coordinates.append(coordinate) count = 0 for i in range(400): for j in range(400): sum_ = 0 for coordinate ...
class Solution: def mostCommonWord(self, paragraph: str, banned) -> str: helper = {} tmp_word = "" for i in paragraph: if (ord('a') <= ord(i) <= ord('z') or ord('A') <= ord(i) <= ord('Z')) is False: if len(tmp_word) > 0: if helper.__contains__(...
class Solution: def most_common_word(self, paragraph: str, banned) -> str: helper = {} tmp_word = '' for i in paragraph: if (ord('a') <= ord(i) <= ord('z') or ord('A') <= ord(i) <= ord('Z')) is False: if len(tmp_word) > 0: if helper.__contains...
#!python # -*- coding: utf-8 -*- # @author: Kun ''' Author: Kun Date: 2021-09-30 00:48:14 LastEditTime: 2021-09-30 00:48:14 LastEditors: Kun Description: FilePath: /HomoglyphAttacksDetector/utils/__init__.py '''
""" Author: Kun Date: 2021-09-30 00:48:14 LastEditTime: 2021-09-30 00:48:14 LastEditors: Kun Description: FilePath: /HomoglyphAttacksDetector/utils/__init__.py """
{ 'includes':[ '../common/common.gypi', ], 'targets': [ { 'target_name': 'tizen_network_bearer_selection', 'type': 'loadable_module', 'sources': [ 'network_bearer_selection_api.js', 'network_bearer_selection_connection_mobile.cc', 'network_bearer_selection_connect...
{'includes': ['../common/common.gypi'], 'targets': [{'target_name': 'tizen_network_bearer_selection', 'type': 'loadable_module', 'sources': ['network_bearer_selection_api.js', 'network_bearer_selection_connection_mobile.cc', 'network_bearer_selection_connection_mobile.h', 'network_bearer_selection_context.cc', 'network...
def DEBUG(s): #pass print(s)
def debug(s): print(s)
def add_to(subparsers): parser = subparsers.add_parser( "wifi", help="Get and set WiFi configuration", ) parser.add_children(__name__, __path__)
def add_to(subparsers): parser = subparsers.add_parser('wifi', help='Get and set WiFi configuration') parser.add_children(__name__, __path__)
''' 1. Write a Python program to print the following string in a specific format (see the output). Go to the editor Sample String : "Twinkle, twinkle, little star, How I wonder what you are! Up above the world so high, Like a diamond in the sky. Twinkle, twinkle, little star, How I wonder what you are" ...
""" 1. Write a Python program to print the following string in a specific format (see the output). Go to the editor Sample String : "Twinkle, twinkle, little star, How I wonder what you are! Up above the world so high, Like a diamond in the sky. Twinkle, twinkle, little star, How I wonder what you are" ...
''' Fill in your credentials from Twitter ''' consumer_key = '' consumer_secret = '' access_token_key = '' access_token_secret = '' account_name = "@" kytten_name = "" #Screen Name without the "@"
""" Fill in your credentials from Twitter """ consumer_key = '' consumer_secret = '' access_token_key = '' access_token_secret = '' account_name = '@' kytten_name = ''
class Solution: def longestRepeatingSubstring(self, S: str) -> int: # dp[i][j] means the longest repeating string ends at i and j. # (aka the target ends at i and the repeating one ends at j) n = len(S) + 1 dp = [[0] * n for _ in range(n)] result = 0 for i in range(1...
class Solution: def longest_repeating_substring(self, S: str) -> int: n = len(S) + 1 dp = [[0] * n for _ in range(n)] result = 0 for i in range(1, n): for j in range(i + 1, n): if S[i - 1] == S[j - 1]: dp[i][j] = dp[i - 1][j - 1] + 1 ...
emojis = \ { 29000000: "<:Unranked:601618883853680653>", 29000001: "<:BronzeLeagueIII:601611929311510528>", 29000002: "<:BronzeLeagueII:601611942850986014>", 29000003: "<:BronzeLeagueI:601611950228635648>", 29000004: "<:SilverLeagueIII:601611958067920906>", 29000005: ...
emojis = {29000000: '<:Unranked:601618883853680653>', 29000001: '<:BronzeLeagueIII:601611929311510528>', 29000002: '<:BronzeLeagueII:601611942850986014>', 29000003: '<:BronzeLeagueI:601611950228635648>', 29000004: '<:SilverLeagueIII:601611958067920906>', 29000005: '<:SilverLeagueII:601611965550428160>', 29000006: '<:Si...
course = 'Python for Beginners' #print the length of the string print(len(course)) #print all in upper print(course.upper()) #print all in lower print(course.lower()) #Find index of the first instance of 'P' print(course.find('P')) #Find index of the first instance of 'o' print(course.find('o')) #Find index of th...
course = 'Python for Beginners' print(len(course)) print(course.upper()) print(course.lower()) print(course.find('P')) print(course.find('o')) print(course.find('0')) print(course.find('Beginners')) print(course.replace('Beginners', 'Absolute Beginners')) print('Python' in course) print('python' in course)
#4.2 list_with_integers = [26, 3, 22, 5.9, 1337, 988, 69.544] for i in list_with_integers: print(float(i))
list_with_integers = [26, 3, 22, 5.9, 1337, 988, 69.544] for i in list_with_integers: print(float(i))
projectTwitterDataFile = open("project_twitter_data.csv","r") resultingDataFile = open("resulting_data.csv","w") punctuation_chars = ["'", '"', ",", ".", "!", ":", ";", '#', '@'] # lists of words to use positive_words = [] with open("positive_words.txt") as pos_f: for lin in pos_f: if lin[0] != ';' and lin...
project_twitter_data_file = open('project_twitter_data.csv', 'r') resulting_data_file = open('resulting_data.csv', 'w') punctuation_chars = ["'", '"', ',', '.', '!', ':', ';', '#', '@'] positive_words = [] with open('positive_words.txt') as pos_f: for lin in pos_f: if lin[0] != ';' and lin[0] != '\n': ...
def sum_repeat_digits(offset): l = [] for i, c in enumerate(digits): index_to_check = int((i + offset) % len(digits)) if c == digits[index_to_check]: l.append(int(c)) return sum(l) def main(): with open('inputs/solution1.txt') as f: digits = f.read().strip() pri...
def sum_repeat_digits(offset): l = [] for (i, c) in enumerate(digits): index_to_check = int((i + offset) % len(digits)) if c == digits[index_to_check]: l.append(int(c)) return sum(l) def main(): with open('inputs/solution1.txt') as f: digits = f.read().strip() pr...
employees = { 'Alice': 100000, 'Bob': 98000, 'Cena': 127000, 'Dwayne': 158000, 'Frank': 88000 } # find the top earner (every one with salary greater than or equal to 1 lakh) top_earners = [] for name,salary in employees.items(): if salary >= 100000: top_earners.append((name,salary)) p...
employees = {'Alice': 100000, 'Bob': 98000, 'Cena': 127000, 'Dwayne': 158000, 'Frank': 88000} top_earners = [] for (name, salary) in employees.items(): if salary >= 100000: top_earners.append((name, salary)) print(top_earners) top_earners = [(n, s) for (n, s) in employees.items() if s >= 100000] print(top_e...
VALID_AZURE_ENVIRONMENTS = [ 'AzurePublicCloud', 'AzureUSGovernmentCloud', 'AzureChinaCloud', 'AzureGermanCloud', ]
valid_azure_environments = ['AzurePublicCloud', 'AzureUSGovernmentCloud', 'AzureChinaCloud', 'AzureGermanCloud']
class Lane: def __init__(self, position, objectType, player_id): self.position = position self.object = objectType self.occupied_by_player_id = player_id
class Lane: def __init__(self, position, objectType, player_id): self.position = position self.object = objectType self.occupied_by_player_id = player_id
coordinates_E0E1E1 = ((123, 110), (123, 112), (123, 113), (123, 114), (123, 115), (123, 116), (123, 117), (123, 118), (123, 119), (123, 120), (123, 122), (124, 110), (124, 122), (125, 110), (125, 112), (125, 113), (125, 114), (125, 115), (125, 116), (125, 117), (125, 118), (125, 119), (125, 120), (125, 122), (126, 10...
coordinates_e0_e1_e1 = ((123, 110), (123, 112), (123, 113), (123, 114), (123, 115), (123, 116), (123, 117), (123, 118), (123, 119), (123, 120), (123, 122), (124, 110), (124, 122), (125, 110), (125, 112), (125, 113), (125, 114), (125, 115), (125, 116), (125, 117), (125, 118), (125, 119), (125, 120), (125, 122), (126, 10...
class Adam: def __init__(self, lr=0.001, beta1=0.9, beta2=0.999): self.lr = lr self.beta1 = beta1 self.beta2 = beta2 self.iter = 0 self.m = None self.v = None def update(self, params, grads): if self.m is None: self.m, self.v = {}, {}...
class Adam: def __init__(self, lr=0.001, beta1=0.9, beta2=0.999): self.lr = lr self.beta1 = beta1 self.beta2 = beta2 self.iter = 0 self.m = None self.v = None def update(self, params, grads): if self.m is None: (self.m, self.v) = ({}, {}) ...
# # PySNMP MIB module HH3C-RCP-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HH3C-RCP-MIB # Produced by pysmi-0.3.4 at Wed May 1 13:29:20 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 2019,...
(object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_intersection, value_size_constraint, single_value_constraint, value_range_constraint, constraints_union) ...
#Two words are blanagrams if they are anagrams but exactly one letter has been substituted for another. #Given two words, check if they are blanagrams of each other. def checkBlanagrams(word1, word2): difference = 0 sortedWord1 = sorted(word1) sortedWord2 = sorted(word2) for a, b in zip(sortedWor...
def check_blanagrams(word1, word2): difference = 0 sorted_word1 = sorted(word1) sorted_word2 = sorted(word2) for (a, b) in zip(sortedWord1, sortedWord2): if sortedWord1 == sortedWord2: return False if a != b: difference += 1 if difference > 1: ...
arr = [1, 2] brr = [3, 4] print(arr + brr) print([1] * 3)
arr = [1, 2] brr = [3, 4] print(arr + brr) print([1] * 3)
def check_is_prime(n): if n == 2 or n == 3: return True if n % 2 == 0 or n < 2: return False for i in range(3, int(n**0.5)+1, 2): if n % i == 0: return False return True
def check_is_prime(n): if n == 2 or n == 3: return True if n % 2 == 0 or n < 2: return False for i in range(3, int(n ** 0.5) + 1, 2): if n % i == 0: return False return True
if __name__ == '__main__': input = [x.strip().split('-') for x in open('input', 'r').readlines()] map = {} for path in input: if path[0] not in map: map[path[0]] = list() map[path[0]].append(path[1]) if path[1] not in map: map[path[1]] = list() map[path[1]].append(path[0]) ...
if __name__ == '__main__': input = [x.strip().split('-') for x in open('input', 'r').readlines()] map = {} for path in input: if path[0] not in map: map[path[0]] = list() map[path[0]].append(path[1]) if path[1] not in map: map[path[1]] = list() map[pat...
class DH_Endpoint(object): def __init__(self, public_key1, public_key2, private_key): self.public_key1 = public_key1 self.public_key2 = public_key2 self.private_key = private_key self.full_key = None def generate_partial_key(self): partial_key = self.public_key1**self.pri...
class Dh_Endpoint(object): def __init__(self, public_key1, public_key2, private_key): self.public_key1 = public_key1 self.public_key2 = public_key2 self.private_key = private_key self.full_key = None def generate_partial_key(self): partial_key = self.public_key1 ** self...
def make_sectional_content(data : list) -> list: sections = [] section = [] for item in data: if item == "~~~": sections.append(section) section = [] continue section.append(item) return sections def print_sectional_content(sect...
def make_sectional_content(data: list) -> list: sections = [] section = [] for item in data: if item == '~~~': sections.append(section) section = [] continue section.append(item) return sections def print_sectional_content(sections: list) -> None: ...
def test_find_or_create_invite(logged_rocket): rid = 'GENERAL' find_or_create_invite = logged_rocket.find_or_create_invite(rid=rid, days=7, max_uses=5).json() assert find_or_create_invite.get('success') assert find_or_create_invite.get('days') == 7 assert find_or_create_invite.get('maxUses') == 5 ...
def test_find_or_create_invite(logged_rocket): rid = 'GENERAL' find_or_create_invite = logged_rocket.find_or_create_invite(rid=rid, days=7, max_uses=5).json() assert find_or_create_invite.get('success') assert find_or_create_invite.get('days') == 7 assert find_or_create_invite.get('maxUses') == 5 d...