content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
questions = open('youtube_chat.txt', 'r').readlines() with open('question_dataset.txt', 'w+') as file: for s in set(questions): print(s.rstrip()[1:-1], file=file)
questions = open('youtube_chat.txt', 'r').readlines() with open('question_dataset.txt', 'w+') as file: for s in set(questions): print(s.rstrip()[1:-1], file=file)
A = 'avalue' B = { 'key' : 'value' } C = ['array']
a = 'avalue' b = {'key': 'value'} c = ['array']
CARGO = "Cargo" COMPOSER = "Composer" GO = "Go" MAVEN = "Maven" NPM = "npm" NUGET = "NuGet" PYPI = PIP = "pip" RUBYGEMS = "RubyGems" ecosystems = [CARGO, COMPOSER, GO, MAVEN, NPM, NUGET, PYPI, RUBYGEMS]
cargo = 'Cargo' composer = 'Composer' go = 'Go' maven = 'Maven' npm = 'npm' nuget = 'NuGet' pypi = pip = 'pip' rubygems = 'RubyGems' ecosystems = [CARGO, COMPOSER, GO, MAVEN, NPM, NUGET, PYPI, RUBYGEMS]
# CPU: 0.08 s n_villagers = int(input()) villagers = {key: set() for key in range(1, n_villagers + 1)} song_counter = 0 for _ in range(int(input())): _, *participants = map(int, input().split()) if 1 in participants: song_counter += 1 for participant in participants: villagers[participant].add(song_counter) e...
n_villagers = int(input()) villagers = {key: set() for key in range(1, n_villagers + 1)} song_counter = 0 for _ in range(int(input())): (_, *participants) = map(int, input().split()) if 1 in participants: song_counter += 1 for participant in participants: villagers[participant].add(s...
# Given an n x n array, return the array elements arranged from outermost elements to the middle element, traveling clockwise. def snail(array): snail_array = [] while len(array) > 0: snail_array.extend(array.pop(0)) length_array = len(array) for i in range(length_array): ...
def snail(array): snail_array = [] while len(array) > 0: snail_array.extend(array.pop(0)) length_array = len(array) for i in range(length_array): adder = array[i].pop(-1) snail_array.append(adder) if length_array > 0: array[-1].reverse() ...
class NodeRegistry: def __init__(self): self.nodes = set() def register(self, *nodes: List[Type[Node]]): self.nodes.update(nodes) def pipeline_factory(self, pipeline_spec): """Construct a pipeline according to the spec. """ ... @staticmethod def _port_to_tu...
class Noderegistry: def __init__(self): self.nodes = set() def register(self, *nodes: List[Type[Node]]): self.nodes.update(nodes) def pipeline_factory(self, pipeline_spec): """Construct a pipeline according to the spec. """ ... @staticmethod def _port_to_t...
db_config = { 'user': '##username##', 'passwd': '##password##', 'host': '##host##', 'db': 'employees', }
db_config = {'user': '##username##', 'passwd': '##password##', 'host': '##host##', 'db': 'employees'}
class Solution(object): def reachNumber(self, target): """ :type target: int :rtype: int """ target = abs(target) n = int((target * 2) ** 0.5) steps = n * (n+1) // 2 while steps < target or (steps - target) % 2: n += 1 steps += ...
class Solution(object): def reach_number(self, target): """ :type target: int :rtype: int """ target = abs(target) n = int((target * 2) ** 0.5) steps = n * (n + 1) // 2 while steps < target or (steps - target) % 2: n += 1 steps...
a="J`e^\x1cf_l]_WiUa\x12UQ]\x0esdj^hp\x1a\\mZ_\x15hT`XQ]\x0eumrrg\x1bg^fZ[\\U[\x12aU]gea_o]i\x1a<gm_Y!$+\x11iPOh-\x1e?pr\x1am``i\x15]f\x12j_d` ej^c\x1b4\x19;K<GoV&c#Ng0tp\\o.f_W+dYS'^h$ha_bs`-Zn-f^*cq!\x12=_eS sml\x1cn_^\x18`j\x15Vhf\x11]PYe\x1fwlqm\x1afaeZ\x15[_ah\x10d^" b="" for i in range(len(a)): print(a[i]) ...
a = "J`e^\x1cf_l]_WiUa\x12UQ]\x0esdj^hp\x1a\\mZ_\x15hT`XQ]\x0eumrrg\x1bg^fZ[\\U[\x12aU]gea_o]i\x1a<gm_Y!$+\x11iPOh-\x1e?pr\x1am``i\x15]f\x12j_d` ej^c\x1b4\x19;K<GoV&c#Ng0tp\\o.f_W+dYS'^h$ha_bs`-Zn-f^*cq!\x12=_eS sml\x1cn_^\x18`j\x15Vhf\x11]PYe\x1fwlqm\x1afaeZ\x15[_ah\x10d^" b = '' for i in range(len(a)): print(a[i]...
factor = int(input()) count = int(input()) list = [] counter = factor for _ in range(count): list.append(counter) counter += factor print(list)
factor = int(input()) count = int(input()) list = [] counter = factor for _ in range(count): list.append(counter) counter += factor print(list)
# 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: _TreeNode, q: _TreeNode) -> bool: # If both are none, the nodes are the same. ...
class _Treenode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right class Solution: def is_same_tree(self, p: _TreeNode, q: _TreeNode) -> bool: if p is None and q is None: return True if p is None or q is No...
"""Top-level package for DRF Compose.""" __author__ = """Sotunde Abiodun""" __email__ = "sotundeabiodun00@gmail.com" __version__ = "0.1.1"
"""Top-level package for DRF Compose.""" __author__ = 'Sotunde Abiodun' __email__ = 'sotundeabiodun00@gmail.com' __version__ = '0.1.1'
# Based on https://github.com/zricethezav/gitleaks/blob/6f5ad9dc0b385c872f652324188ce91da7157c7c/test_data/test_repos/test_dir_1/server.test2.py # Do not hard code credentials client = boto3.client( 's3', # Hard coded strings as credentials, not recommended. aws_access_key_id='AKIAIO5FODNN7EXAMPLE', aws...
client = boto3.client('s3', aws_access_key_id='AKIAIO5FODNN7EXAMPLE', aws_secret_access_key='ABCDEF+c2L7yXeGvUyrPgYsDnWRRC1AYEXAMPLE')
""" Bisect Squares. Given two squares on a two-dimensional plane, find a line that would cut these two squares in half. Assume that the top and the bottom sides of the square run parallel to the x-axis. """ class BisectSquares(): class Square(): class Line(): def __init_...
""" Bisect Squares. Given two squares on a two-dimensional plane, find a line that would cut these two squares in half. Assume that the top and the bottom sides of the square run parallel to the x-axis. """ class Bisectsquares: class Square: class Line: def __init__(self, p1, p2): ...
def find_range_values(curr_range): return list(map(int, curr_range.split(","))) def find_set(curr_range): start_value, end_value = find_range_values(curr_range) curr_set = set(range(start_value, end_value + 1)) return curr_set def find_longest_intersection(n): longest_intersection = set() ...
def find_range_values(curr_range): return list(map(int, curr_range.split(','))) def find_set(curr_range): (start_value, end_value) = find_range_values(curr_range) curr_set = set(range(start_value, end_value + 1)) return curr_set def find_longest_intersection(n): longest_intersection = set() fo...
# Complete solution # https://leetcode.com/problems/remove-sub-folders-from-the-filesystem/discuss/409028/JavaPython-3-3-methods-from-O(n-*-(logn-%2B-m-2))-to-O(n-*-m)-w-brief-explanation-and-analysis. # use startswith class Solution: def removeSubfolders(self, folder: List[str]) -> List[str]: """ So...
class Solution: def remove_subfolders(self, folder: List[str]) -> List[str]: """ Sort folders, so that parent will always occur in front of child For each folder, check if it starts with parent folder If it does, it's a subfolder, skip it. If not, make it next parent folder. """ fol...
CKAN_ROOT = "https://data.wprdc.org/" API_PATH = "api/3/action/" SQL_SEARCH_ENDPOINT = "datastore_search_sql" API_URL = CKAN_ROOT + API_PATH + SQL_SEARCH_ENDPOINT
ckan_root = 'https://data.wprdc.org/' api_path = 'api/3/action/' sql_search_endpoint = 'datastore_search_sql' api_url = CKAN_ROOT + API_PATH + SQL_SEARCH_ENDPOINT
"""Role testing files using testinfra""" def test_daemon_config(host): """Check docker daemon config""" f = host.file("/etc/docker/daemon.json") assert f.is_file assert f.user == "root" assert f.group == "root" config = ( "{\n" " \"live-restore\": true,\n" " \"log-dr...
"""Role testing files using testinfra""" def test_daemon_config(host): """Check docker daemon config""" f = host.file('/etc/docker/daemon.json') assert f.is_file assert f.user == 'root' assert f.group == 'root' config = '{\n "live-restore": true,\n "log-driver": "local",\n "log-opts": {\n ...
# variables 3 a = "abc" print("a:", a, type(a)) a = 3 print("a:", a, type(a))
a = 'abc' print('a:', a, type(a)) a = 3 print('a:', a, type(a))
#!/usr/bin/env python # -*- coding: utf-8 -*- ''' Copyright 2020, Yutong Xie, UIUC. Using Greedy Algorithm to solve balloon burst problem. ''' class Solution(object): def findMinArrowShots(self, points): """ :type points: List[List[int]] :rtype: int """ if not point...
""" Copyright 2020, Yutong Xie, UIUC. Using Greedy Algorithm to solve balloon burst problem. """ class Solution(object): def find_min_arrow_shots(self, points): """ :type points: List[List[int]] :rtype: int """ if not points: return 0 points = s...
def put_languages(self, root): if hasattr(self, "languages") and self.languages: lang_string = ",".join(["/".join(x) for x in self.languages]) root.attrib["languages"] = lang_string def put_address(self, root): if self.address: if isinstance(self.address, str): root.attrib...
def put_languages(self, root): if hasattr(self, 'languages') and self.languages: lang_string = ','.join(['/'.join(x) for x in self.languages]) root.attrib['languages'] = lang_string def put_address(self, root): if self.address: if isinstance(self.address, str): root.attrib['...
#!/usr/bin/env python # -*- coding: utf-8 -*- """RackTablesDB - a python library to access the racktables database. """ __author__ = "John van Zantvoort" __email__ = "john.van.zantvoort@snow.nl" __license__ = "The MIT License (MIT)" __version__ = "1.0.1"
"""RackTablesDB - a python library to access the racktables database. """ __author__ = 'John van Zantvoort' __email__ = 'john.van.zantvoort@snow.nl' __license__ = 'The MIT License (MIT)' __version__ = '1.0.1'
# n = nums.length # time = 0(n) # space = O(1) class Solution: def maxSubArray(self, nums: List[int]) -> int: ret = max(nums) sub_sum = 0 for num in nums: sub_sum = max(0, sub_sum) + num ret = max(ret, sub_sum) return ret
class Solution: def max_sub_array(self, nums: List[int]) -> int: ret = max(nums) sub_sum = 0 for num in nums: sub_sum = max(0, sub_sum) + num ret = max(ret, sub_sum) return ret
class Heroes3(object): def __init__(self): super(Heroes3, self).__init__() self._army_size = { "Few" : (1, 4), "Several" : (5, 9), "Pack" : (10, 19), "Lots" : (20, 49), "Horde" : (50, 100), "Throng" : (100, 249), "Sw...
class Heroes3(object): def __init__(self): super(Heroes3, self).__init__() self._army_size = {'Few': (1, 4), 'Several': (5, 9), 'Pack': (10, 19), 'Lots': (20, 49), 'Horde': (50, 100), 'Throng': (100, 249), 'Swarm': (250, 499), 'Zounds': (500, 999), 'Legion': (1000, float('inf'))} def get_all(s...
""" 572 subtree of another tree easy Given the roots of two binary trees root and subRoot, return true if there is a subtree of root with the same structure and node values of subRoot and false otherwise. A subtree of a binary tree tree is a tree that consists of a node in tree and all of this node's descendants. The...
""" 572 subtree of another tree easy Given the roots of two binary trees root and subRoot, return true if there is a subtree of root with the same structure and node values of subRoot and false otherwise. A subtree of a binary tree tree is a tree that consists of a node in tree and all of this node's descendants. The...
count = int(input()) for i in range(count): k = int(input()) n = int(input()) people = [j for j in range(1,n+1)] for x in range (k): for v in range(n-1): people[v+1] += people[v] print(people[-1])
count = int(input()) for i in range(count): k = int(input()) n = int(input()) people = [j for j in range(1, n + 1)] for x in range(k): for v in range(n - 1): people[v + 1] += people[v] print(people[-1])
class Solution: def canPlaceFlowers(self, flowerbed, n): """ :type flowerbed: List[int] :type n: int :rtype: bool """ num=n if len(flowerbed)<=1: if (num==1 and flowerbed==[0]) or (num==0): return True else: ...
class Solution: def can_place_flowers(self, flowerbed, n): """ :type flowerbed: List[int] :type n: int :rtype: bool """ num = n if len(flowerbed) <= 1: if num == 1 and flowerbed == [0] or num == 0: return True else: ...
class Solution: def removeDuplicates(self, nums): """ :type nums: List[int] :rtype: int """ if len(nums) <= 2: return len(nums) i, j = 2, 2 while i < len(nums): if not (nums[j-1] == nums[j-2] == nums[i]): nums[j] = num...
class Solution: def remove_duplicates(self, nums): """ :type nums: List[int] :rtype: int """ if len(nums) <= 2: return len(nums) (i, j) = (2, 2) while i < len(nums): if not nums[j - 1] == nums[j - 2] == nums[i]: nums[j]...
"""Project exceptions""" class ProjectImportError (Exception): """Failure to import a project from a repository.""" pass
"""Project exceptions""" class Projectimporterror(Exception): """Failure to import a project from a repository.""" pass
""" Remote repositories, used by this project itself """ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") def repositories(): _all_content = """filegroup(name = "all", srcs = glob(["**"]), visibility = ["//visibility:public"])""" http_archive( name = "bazel_skylib", sha256...
""" Remote repositories, used by this project itself """ load('@bazel_tools//tools/build_defs/repo:http.bzl', 'http_archive') def repositories(): _all_content = 'filegroup(name = "all", srcs = glob(["**"]), visibility = ["//visibility:public"])' http_archive(name='bazel_skylib', sha256='97e70364e9249702246c0e9...
"""Patch Server for Jamf Pro""" __title__ = "Patch Server" __version__ = "2020.10.02" __author__ = "Bryson Tyrrell"
"""Patch Server for Jamf Pro""" __title__ = 'Patch Server' __version__ = '2020.10.02' __author__ = 'Bryson Tyrrell'
def goTo(logic, x, y): hero.moveXY(x, y) hero.say(logic) hero.moveXY(26, 16); a = hero.findNearestFriend().getSecretA() b = hero.findNearestFriend().getSecretB() c = hero.findNearestFriend().getSecretC() goTo(a and b or c, 25, 26) goTo((a or b) and c, 26, 32) goTo((a or c) and (b or c), 35, 32) go...
def go_to(logic, x, y): hero.moveXY(x, y) hero.say(logic) hero.moveXY(26, 16) a = hero.findNearestFriend().getSecretA() b = hero.findNearestFriend().getSecretB() c = hero.findNearestFriend().getSecretC() go_to(a and b or c, 25, 26) go_to((a or b) and c, 26, 32) go_to((a or c) and (b or c), 35, 32) go_to(a and b...
def afl(x): """ If no 'l' key is included, add a list of None's the same length as key 'a'. """ if 'l' in x: return x else: x.update({'l': ['']*len(x['a'])}) return x class V1: def __init__(self,version='std',**kwargs): self.version=version @property def doms(self): return {'uc': 'qD', 'currapp': 'q...
def afl(x): """ If no 'l' key is included, add a list of None's the same length as key 'a'. """ if 'l' in x: return x else: x.update({'l': [''] * len(x['a'])}) return x class V1: def __init__(self, version='std', **kwargs): self.version = version @property de...
# http://code.activestate.com/recipes/119466-dijkstras-algorithm-for-shortest-paths/ """ G = {'s':{'u':10, 'x':5}, 'u':{'v':1, 'x':2}, 'v':{'y':4}, 'x':{'u':3, 'v':9, 'y':2}, 'y':{'s':7, 'v':6}} """ def graph_to_dot(G): s = """digraph G {\nnode [width=.3,height=.3,shape=octagon,style=filled,colo...
""" G = {'s':{'u':10, 'x':5}, 'u':{'v':1, 'x':2}, 'v':{'y':4}, 'x':{'u':3, 'v':9, 'y':2}, 'y':{'s':7, 'v':6}} """ def graph_to_dot(G): s = 'digraph G {\nnode [width=.3,height=.3,shape=octagon,style=filled,color=skyblue];\noverlap="false";\nrankdir="LR";\n%s}' r = '' for i in G: ...
def print_array(array): for i in array: print(i, end=" ") print("") def bubble_sort(array): for i in range(len(array)): swapped = False for j in range(0, len(array)-i-1): if array[j] >= array[j+1]: tmp = array[j+1] array[j+1] = array[j] ...
def print_array(array): for i in array: print(i, end=' ') print('') def bubble_sort(array): for i in range(len(array)): swapped = False for j in range(0, len(array) - i - 1): if array[j] >= array[j + 1]: tmp = array[j + 1] array[j + 1] = a...
class Solution: def findAnagrams(self, s: str, p: str) -> List[int]: size_s = len(s) size_p = len(p) counter1 = collections.defaultdict(int) counter2 = collections.defaultdict(int) ans = [] for c in p: counter2[c] += 1 for c in s[:size_p-1]...
class Solution: def find_anagrams(self, s: str, p: str) -> List[int]: size_s = len(s) size_p = len(p) counter1 = collections.defaultdict(int) counter2 = collections.defaultdict(int) ans = [] for c in p: counter2[c] += 1 for c in s[:size_p - 1]: ...
''' We have an array A of integers, and an array queries of queries. For the i-th query val = queries[i][0], index = queries[i][1], we add val to A[index]. Then, the answer to the i-th query is the sum of the even values of A. (Here, the given index = queries[i][1] is a 0-based index, and each query permanently modi...
""" We have an array A of integers, and an array queries of queries. For the i-th query val = queries[i][0], index = queries[i][1], we add val to A[index]. Then, the answer to the i-th query is the sum of the even values of A. (Here, the given index = queries[i][1] is a 0-based index, and each query permanently modi...
''' Created on Oct 3, 2015 @author: bcy-3 '''
""" Created on Oct 3, 2015 @author: bcy-3 """
app_name = "pusta2" prefix_url = "pusta2" static_files = { 'js': { 'pusta2/js/': ['main.js', ] }, 'css': { 'pusta2/css/': ['main.css', ] }, 'html': { 'pusta2/html/': ['index.html', ] } } permissions = { "edit": "Editing actualy nothing.", "sample1": "sample1longve...
app_name = 'pusta2' prefix_url = 'pusta2' static_files = {'js': {'pusta2/js/': ['main.js']}, 'css': {'pusta2/css/': ['main.css']}, 'html': {'pusta2/html/': ['index.html']}} permissions = {'edit': 'Editing actualy nothing.', 'sample1': 'sample1longversion'}
"""This problem was asked by Facebook. We have some historical clickstream data gathered from our site anonymously using cookies. The histories contain URLs that users have visited in chronological order. Write a function that takes two users' browsing histories as input and returns the longest contiguous sequence ...
"""This problem was asked by Facebook. We have some historical clickstream data gathered from our site anonymously using cookies. The histories contain URLs that users have visited in chronological order. Write a function that takes two users' browsing histories as input and returns the longest contiguous sequence ...
input = open('input.txt', 'r').read().split("\n") preamble_length = 25 invalid = 0 for i in range(preamble_length, len(input)): current = int(input[i]) found = False for j in range(i - preamble_length, i): for k in range (j + 1, i): sum = int(input[j]) + int(input[k]) if sum == current: found = True i...
input = open('input.txt', 'r').read().split('\n') preamble_length = 25 invalid = 0 for i in range(preamble_length, len(input)): current = int(input[i]) found = False for j in range(i - preamble_length, i): for k in range(j + 1, i): sum = int(input[j]) + int(input[k]) if sum =...
x,y = map(float, input().split()) if (x == y == 0): print("Origem") elif (y == 0): print("Eixo X") elif (x == 0): print("Eixo Y") elif (x > 0) and (y > 0): print("Q1") elif (x < 0) and (y > 0): print("Q2") elif (x < 0) and (y < 0): print("Q3") elif (x > 0) and (y < 0): print("Q4")
(x, y) = map(float, input().split()) if x == y == 0: print('Origem') elif y == 0: print('Eixo X') elif x == 0: print('Eixo Y') elif x > 0 and y > 0: print('Q1') elif x < 0 and y > 0: print('Q2') elif x < 0 and y < 0: print('Q3') elif x > 0 and y < 0: print('Q4')
"""ROM methods.""" def read_all_rom(self) -> list: """ Return the values of all the locations of ROM. Parameters ---------- self : Processor, mandatory The instance of the processor containing the registers, accumulator etc Returns ------- ROM The values of all the lo...
"""ROM methods.""" def read_all_rom(self) -> list: """ Return the values of all the locations of ROM. Parameters ---------- self : Processor, mandatory The instance of the processor containing the registers, accumulator etc Returns ------- ROM The values of all the loc...
class Point(object): def __init__(self, x, y): self._x = x self._y = y def get_x(self): return self._x def set_x(self, x): self._x = x def get_y(self): return self._y def set_y(self, y): self._y = y def euclidean_distance(a, b): ax = a.get_...
class Point(object): def __init__(self, x, y): self._x = x self._y = y def get_x(self): return self._x def set_x(self, x): self._x = x def get_y(self): return self._y def set_y(self, y): self._y = y def euclidean_distance(a, b): ax = a.get_x(...
print("Height: ", end='') while True: height = input() # check if int try: height = int(height) except ValueError: print("Retry: ", end='') continue # check if suitable value if height >= 0 and height <= 23: break else: print("Height: ", end='') # ...
print('Height: ', end='') while True: height = input() try: height = int(height) except ValueError: print('Retry: ', end='') continue if height >= 0 and height <= 23: break else: print('Height: ', end='') for i in range(height): hashes = '#' * (i + 1) ...
# In Search for the Lost Memory [Explorer Pirate + Jett] (3527) recoveredMemory = 7081 kyrin = 1090000 sm.setSpeakerID(kyrin) sm.sendNext("A stable position, with a calm demanor-- but I can tell you're hiding your explosive attacking abilities-- " "you've become quite an impressive pirate, #h #. It's been a while.")...
recovered_memory = 7081 kyrin = 1090000 sm.setSpeakerID(kyrin) sm.sendNext("A stable position, with a calm demanor-- but I can tell you're hiding your explosive attacking abilities-- you've become quite an impressive pirate, #h #. It's been a while.") sm.sendSay("You used to be a kid that was scared of water-- and look...
class Powerup: def __init__(self, coord): self.coord = coord def use(self, player): raise NotImplementedError def ascii(self): return "P"
class Powerup: def __init__(self, coord): self.coord = coord def use(self, player): raise NotImplementedError def ascii(self): return 'P'
languages = { "c": "c", "cpp": "cpp", "cc": "cpp", "cs": "csharp", "java": "java", "py": "python", "rb": "ruby" }
languages = {'c': 'c', 'cpp': 'cpp', 'cc': 'cpp', 'cs': 'csharp', 'java': 'java', 'py': 'python', 'rb': 'ruby'}
# Create database engine for data.db engine = create_engine('sqlite:///data.db') # Write query to get date, tmax, and tmin from weather query = """ SELECT date, tmax, tmin FROM weather; """ # Make a data frame by passing query and engine to read_sql() temperatures = pd.read_sql(query, engine) # Vie...
engine = create_engine('sqlite:///data.db') query = '\nSELECT date, \n tmax, \n tmin\n FROM weather;\n' temperatures = pd.read_sql(query, engine) print(temperatures) '\nscript.py> output:\n date tmax tmin\n 0 12/01/2017 52 42\n 1 12/02/2017 48 39\n 2 12/03/2017...
#Arquivo que contem os parametros do jogo quantidade_jogadores = 2 #quantidade de Jogadores jogadores = [] #array que contem os jogadores(na ordem de jogo) tamanho_tabuleiro = 40 #tamanho do array do tabuleiro (sempre multiplo de 4 para o tabuleiro ficar quadrado) quantidade_dados = 2 #quantos dados serao usados quant...
quantidade_jogadores = 2 jogadores = [] tamanho_tabuleiro = 40 quantidade_dados = 2 quantidade_reves = int(tamanho_tabuleiro / 5) dinheiro_inicial = 10000000 jogadas_default = 1 pos_vai_para_cadeia = int(tamanho_tabuleiro / 4) pos__cadeia = int(pos_vai_para_cadeia * 3) contrucoes = {'1': 'Nada', '2': 'Casa', '3': 'Hote...
s = 'azcbobobegghakl' num = 0 for i in range(0, len(s) - 2): if s[i] + s[i + 1] + s[i + 2] == 'bob': num += 1 print('Number of times bob occurs is: ' + str(num))
s = 'azcbobobegghakl' num = 0 for i in range(0, len(s) - 2): if s[i] + s[i + 1] + s[i + 2] == 'bob': num += 1 print('Number of times bob occurs is: ' + str(num))
# --- Day 14: Docking Data --- # As your ferry approaches the sea port, the captain asks for your help again. The computer system that runs this port isn't compatible with the docking program on the ferry, so the docking parameters aren't being correctly initialized in the docking program's memory. # After a brief ins...
def file_input(): f = open(inputFile, 'r') with open(inputFile) as f: read_data = f.read().split('\n') f.close() return read_data def split_data(data): data_line = [] max_size = 0 global mem for line in data: new_line = line.split(' = ') if newLine[0] != 'mask': ...
#!/usr/bin/env python3 class DNSMasq_DHCP_Generic_Switchable: def __init__(self, name, value): self.name = name self.value = value def __str__(self): if self.value is None: return self.name elif self.value is not None: return self.name + "=" + self.valu...
class Dnsmasq_Dhcp_Generic_Switchable: def __init__(self, name, value): self.name = name self.value = value def __str__(self): if self.value is None: return self.name elif self.value is not None: return self.name + '=' + self.value class Dnsmasq_Dhcp_Op...
df4 = pandas.read_csv('supermarkets-commas.txt') df4 df5 = pandas.read_csv('supermarkets-semi-colons.txt',sep=';') df5
df4 = pandas.read_csv('supermarkets-commas.txt') df4 df5 = pandas.read_csv('supermarkets-semi-colons.txt', sep=';') df5
class DummyScheduler(object): def __init__(self, optimizer): pass def step(self): pass
class Dummyscheduler(object): def __init__(self, optimizer): pass def step(self): pass
# -*- coding: utf-8 -*- """ Created on Wed May 8 12:07:42 2019 @author: DiPu """ for i in range(1,6): print("*"*i) for j in range(4,0,-1): print("*"*j)
""" Created on Wed May 8 12:07:42 2019 @author: DiPu """ for i in range(1, 6): print('*' * i) for j in range(4, 0, -1): print('*' * j)
a = [int(x) for x in input().split()] aset = set() for i in range(5): for j in range(i+1, 5): for k in range(j+1, 5): aset.add(a[i] + a[j] + a[k]) print(sorted(aset, reverse=True)[2])
a = [int(x) for x in input().split()] aset = set() for i in range(5): for j in range(i + 1, 5): for k in range(j + 1, 5): aset.add(a[i] + a[j] + a[k]) print(sorted(aset, reverse=True)[2])
""" Store a person's name, and include some whitespace characters at beginning and end of the name. Make sure you use each character combination "\t" and "\n" at least one. """ name = ' James ' print(name.lstrip()) print(name.rstrip()) print(name.strip()) print('\tJames Noria') print('Name:\nJames Noria')
""" Store a person's name, and include some whitespace characters at beginning and end of the name. Make sure you use each character combination " " and " " at least one. """ name = ' James ' print(name.lstrip()) print(name.rstrip()) print(name.strip()) print('\tJames Noria') print('Name:\nJames Noria')
def drive(start, end, step, parameters): step_results = { "P:sir.out.S": list(), "P:sir.out.I": list(), "P:sir.out.R": list(), "P:sir.in.dt": list(), } S = parameters["P:sir.in.S"] I = parameters["P:sir.in.I"] R = parameters["P:sir.in.R"] for i in range(start, e...
def drive(start, end, step, parameters): step_results = {'P:sir.out.S': list(), 'P:sir.out.I': list(), 'P:sir.out.R': list(), 'P:sir.in.dt': list()} s = parameters['P:sir.in.S'] i = parameters['P:sir.in.I'] r = parameters['P:sir.in.R'] for i in range(start, end + 1, step): (s, i, r) = sir(S,...
class RequestParseError(Exception): """Error raised when the inbound request could not be parsed.""" pass class AttachmentTooLargeError(Exception): """Error raised when an attachment is too large.""" def __init__(self, email, filename, size): super(AttachmentTooLargeError, self) self...
class Requestparseerror(Exception): """Error raised when the inbound request could not be parsed.""" pass class Attachmenttoolargeerror(Exception): """Error raised when an attachment is too large.""" def __init__(self, email, filename, size): super(AttachmentTooLargeError, self) self.e...
# Configuration file for interface "rpc". This interface is # used in conjunction with RPC resource for cage-to-cage RPC calls. # # If location discovery at runtime is used (which is recommended), # then all the cages that wish to share the same RPC "namespace" need # identical broadcast ports, broadcast addresses that...
config = dict(protocol='rpc', random_port=-63000, max_connections=100, broadcast_address=('0.0.0.0/255.255.255.255', 12480), ssl_ciphers=None, ssl_protocol=None, flock_id='DEFAULT', marshaling_methods=('msgpack', 'pickle'), max_packet_size=1048576) __all__ = ['get', 'copy'] get = lambda key, default=None: pmnc.config.g...
EXAMPLE_TWEETS = [ "Trump for President!!! #MAGA", "Trump is the best ever!", "RT @someuser: Trump is, by far, the best POTUS in history. \n\nBonus: He^s friggin^ awesome!\n\nTrump gave Pelosi and the Dems the ultimate\u2026 ", "If Clinton is elected, I'm moving to Canada", "Trump is doing a great ...
example_tweets = ['Trump for President!!! #MAGA', 'Trump is the best ever!', 'RT @someuser: Trump is, by far, the best POTUS in history. \n\nBonus: He^s friggin^ awesome!\n\nTrump gave Pelosi and the Dems the ultimate… ', "If Clinton is elected, I'm moving to Canada", 'Trump is doing a great job so far. Keep it up man....
""" 1. Use for position param, variable params, keyword argument """ def test(a, b, *args, m=1, n=2): print(a) print(b) print(args) print(m) print(n) test(1, 2, 3, 4, 5) print() test(1, 2, 3, 4, 5, m=10, n=20) print() """ 1. Use **kwargs for dict on keyword arguments """ def foo(**kwargs): ...
""" 1. Use for position param, variable params, keyword argument """ def test(a, b, *args, m=1, n=2): print(a) print(b) print(args) print(m) print(n) test(1, 2, 3, 4, 5) print() test(1, 2, 3, 4, 5, m=10, n=20) print() '\n 1. Use **kwargs for dict on keyword arguments\n' def foo(**kwargs): ...
test_item = { "stac_version": "1.0.0", "stac_extensions": [], "type": "Feature", "id": "20201211_223832_CS2", "bbox": [ 172.91173669923782, 1.3438851951615003, 172.95469614953714, 1.3690476620161975 ], "geometry": { "type": "Polygon", "coordina...
test_item = {'stac_version': '1.0.0', 'stac_extensions': [], 'type': 'Feature', 'id': '20201211_223832_CS2', 'bbox': [172.91173669923782, 1.3438851951615003, 172.95469614953714, 1.3690476620161975], 'geometry': {'type': 'Polygon', 'coordinates': [[[172.91173669923782, 1.3438851951615003], [172.95469614953714, 1.3438851...
# output: ok assert([x for x in ()] == []) assert([x for x in range(0, 3)] == [0, 1, 2]) assert([(x, y) for x in range(0, 2) for y in range(2, 4)] == [(0, 2), (0, 3), (1, 2), (1, 3)]) assert([x for x in range(0, 3) if x >= 1] == [1, 2]) def inc(x): return x + 1 assert([inc(y) for y in (1, 2, 3)] == [2, 3, ...
assert [x for x in ()] == [] assert [x for x in range(0, 3)] == [0, 1, 2] assert [(x, y) for x in range(0, 2) for y in range(2, 4)] == [(0, 2), (0, 3), (1, 2), (1, 3)] assert [x for x in range(0, 3) if x >= 1] == [1, 2] def inc(x): return x + 1 assert [inc(y) for y in (1, 2, 3)] == [2, 3, 4] a = 1 assert [a for y ...
# # PySNMP MIB module ASCEND-MIBVDSLNET-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ASCEND-MIBVDSLNET-MIB # Produced by pysmi-0.3.4 at Wed May 1 11:28:54 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (def...
(configuration,) = mibBuilder.importSymbols('ASCEND-MIB', 'configuration') (octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (single_value_constraint, constraints_union...
def __init__(self): self.meetings = [] def book(self, start: int, end: int) -> bool: for s, e in self.meetings: if s < end and start < e: return False self.meetings.append([start, end]) return True
def __init__(self): self.meetings = [] def book(self, start: int, end: int) -> bool: for (s, e) in self.meetings: if s < end and start < e: return False self.meetings.append([start, end]) return True
# Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. # # The number of elements initialized in nums1 and nums2 are m and n respectively. # You may assume that nums1 has enough space (size that is equal to m + n) to hold additional elements from nums2. # Source - https://leetcod...
class Solution: def merge(self, nums1, m: int, nums2, n: int): i = m - 1 j = n - 1 k = m + n - 1 while i >= 0 and j >= 0: if nums1[i] > nums2[j]: nums1[k] = nums1[i] i -= 1 else: nums1[k] = nums2[j] ...
#!/usr/bin/env python # -*- coding: utf-8 -*- """Advent of Code 2020, day five.""" INPUT_FILE = 'data/day_05.txt' def main() -> None: """Identify missing ticket.""" with open(INPUT_FILE, encoding='utf-8') as input_file: tkt = sorted([int(x.strip().replace('F', '0').replace('B', '1') ...
"""Advent of Code 2020, day five.""" input_file = 'data/day_05.txt' def main() -> None: """Identify missing ticket.""" with open(INPUT_FILE, encoding='utf-8') as input_file: tkt = sorted([int(x.strip().replace('F', '0').replace('B', '1').replace('L', '0').replace('R', '1'), 2) for x in input_file]) ...
"""Python3 Code to solve problem 1253: Reconstruct a 2-Row Binary Matrix. """ class Solution(object): def reconstructMatrix(self, upper: int, lower: int, colsum: list) -> list: zero_col = set() two_col = set() col_num = len(colsum) for col_id, col_sum in enumerate(colsum): ...
"""Python3 Code to solve problem 1253: Reconstruct a 2-Row Binary Matrix. """ class Solution(object): def reconstruct_matrix(self, upper: int, lower: int, colsum: list) -> list: zero_col = set() two_col = set() col_num = len(colsum) for (col_id, col_sum) in enumerate(colsum): ...
""" You're given a substring s of some cyclic string. What's the length of the smallest possible string that can be concatenated to itself many times to obtain this cyclic string? Example For s = "cabca", the output should be cyclicString(s) = 3. "cabca" is a substring of a cycle string "abcabcabcabc..." that can be...
""" You're given a substring s of some cyclic string. What's the length of the smallest possible string that can be concatenated to itself many times to obtain this cyclic string? Example For s = "cabca", the output should be cyclicString(s) = 3. "cabca" is a substring of a cycle string "abcabcabcabc..." that can be...
# Example of mutual recursion with even/odd. # # Eli Bendersky [http://eli.thegreenplace.net] # This code is in the public domain. def is_even(n): if n == 0: return True else: return is_odd(n - 1) def is_odd(n): if n == 0: return False else: return is_even(n - 1) de...
def is_even(n): if n == 0: return True else: return is_odd(n - 1) def is_odd(n): if n == 0: return False else: return is_even(n - 1) def is_even_thunked(n): if n == 0: return True else: return lambda : is_odd_thunked(n - 1) def is_odd_thunked(n)...
X = {} print(5 in X) print(X[4]) print(X[5])
x = {} print(5 in X) print(X[4]) print(X[5])
# -*- coding: utf-8 -*- # Author: Tonio Teran <tonio@stateoftheart.ai> # Copyright: Stateoftheart AI PBC 2021. '''NEAR AI's library wrapper. Dataset information taken from: ''' SOURCE_METADATA = { 'name': 'nearai', 'original_name': 'NEAR Program Synthesis', 'url': 'https://github.com/nearai/program_synthe...
"""NEAR AI's library wrapper. Dataset information taken from: """ source_metadata = {'name': 'nearai', 'original_name': 'NEAR Program Synthesis', 'url': 'https://github.com/nearai/program_synthesis'} datasets = {'Program Synthesis': ['AlgoLisp', 'Karel', 'NAPS']} def load_dataset(name: str) -> dict: return {'name...
#!/usr/bin/python inp = input(">> ") print(inp) count = 0 while True: print("hi") count += 1 if count == 3: break
inp = input('>> ') print(inp) count = 0 while True: print('hi') count += 1 if count == 3: break
class Solution: def longestCommonPrefix(self, strs): """ :type strs: List[str] :rtype: str """ if not strs: return '' zip_strs = zip(*strs) for i, letter_group in enumerate(zip_strs): if len(set(letter_group)) > 1: ...
class Solution: def longest_common_prefix(self, strs): """ :type strs: List[str] :rtype: str """ if not strs: return '' zip_strs = zip(*strs) for (i, letter_group) in enumerate(zip_strs): if len(set(letter_group)) > 1: ...
#VERSION: 1.0 INFO = {"example":("test","This is an example mod")} RLTS = {"cls":(),"funcs":("echo"),"vars":()} def test(cmd): echo(0,cmd)
info = {'example': ('test', 'This is an example mod')} rlts = {'cls': (), 'funcs': 'echo', 'vars': ()} def test(cmd): echo(0, cmd)
queries = [ """SELECT * WHERE { ?s ?p ?o }""", """SELECT ?point ?point_type WHERE { ?point rdf:type brick:Point . ?point rdf:type ?point_type }""", "SELECT ?meter WHERE { ?meter rdf:type brick:Green_Button_Meter }", """ SELECT ?t WHERE { ?t rdf:type brick:Weather_Temperature_Sensor }""", """SELECT ?sensor WHE...
queries = ['SELECT * WHERE { ?s ?p ?o }', 'SELECT ?point ?point_type WHERE {\n ?point rdf:type brick:Point .\n ?point rdf:type ?point_type \n}', 'SELECT ?meter WHERE { ?meter rdf:type brick:Green_Button_Meter }', ' SELECT ?t WHERE { ?t rdf:type brick:Weather_Temperature_Sensor }', 'SELECT ?sensor WHERE {\n ?se...
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def getIntersectionNode(self, headA, headB): """ :type head1, head1: ListNode :rtype: ListNode """ if headA =...
class Solution(object): def get_intersection_node(self, headA, headB): """ :type head1, head1: ListNode :rtype: ListNode """ if headA == headB: return headA head_a_start = headA head_b_start = headB len_a = 0 len_b = 0 whil...
#so sai quando escrever sair nome = str(input("Escreva nome :(sair para terminar)")) while nome != "sair": nome = str(input("Escreva nome: (sair para terminar)"))
nome = str(input('Escreva nome :(sair para terminar)')) while nome != 'sair': nome = str(input('Escreva nome: (sair para terminar)'))
def heap_sort(l: list): # flag is init def sort(num: int, node: int, flag: bool): # print(str(node) +' '+str(num)) if num == len(l) - 1: return if node < 0: l[0], l[-(num) - 1] = l[-(num) - 1], l[0] #swap topest num += 1 node = 0 if...
def heap_sort(l: list): def sort(num: int, node: int, flag: bool): if num == len(l) - 1: return if node < 0: (l[0], l[-num - 1]) = (l[-num - 1], l[0]) num += 1 node = 0 if node * 2 + 1 < len(l) - num: if l[node] < l[node * 2 + 1]: ...
# directories where to look for duplicates dir_list = [ r"C:\Users\Gamer\Documents\Projekte\azzap\azzap-docker-dev\data\html\pub\media\catalog\product", r"C:\Users\Gamer\Documents\Projekte\azzap\azzap-docker-dev\data\html\pub\media\import\multishopifystoremageconnect", r"C:\Users\Gamer\Documents\Projekte\a...
dir_list = ['C:\\Users\\Gamer\\Documents\\Projekte\\azzap\\azzap-docker-dev\\data\\html\\pub\\media\\catalog\\product', 'C:\\Users\\Gamer\\Documents\\Projekte\\azzap\\azzap-docker-dev\\data\\html\\pub\\media\\import\\multishopifystoremageconnect', 'C:\\Users\\Gamer\\Documents\\Projekte\\azzap\\azzap-docker-dev\\data\\h...
""" User assistance/help texts """ AGGREGATE_DATA = """ Here you can see an overview and aggregated data over all batches. Please note that only \ the data from instances that are part of experimental batches is considered here, not data from instances that \ have been started in between batches. """ CUSTOMER_CATEGOR...
""" User assistance/help texts """ aggregate_data = '\nHere you can see an overview and aggregated data over all batches. Please note that only the data from instances that are part of experimental batches is considered here, not data from instances that have been started in between batches.\n' customer_categories_inpu...
print("NFC West W L T") print("-----------------------") print("Seattle 13 3 0") print("San Francisco 12 4 0") print("Arizona 10 6 0") print("St. Louis 7 9 0\n") print("NFC North W L T") print("-----------------------") print("Green Bay 8 7 1") print("Chicago ...
print('NFC West W L T') print('-----------------------') print('Seattle 13 3 0') print('San Francisco 12 4 0') print('Arizona 10 6 0') print('St. Louis 7 9 0\n') print('NFC North W L T') print('-----------------------') print('Green Bay 8 7 1') print('Chicago ...
pallet_color = [ (231, 234, 238), # 010 White (252, 166, 0), # 020Golden yellow (232, 167, 0), # 019 Signal yellow (254, 198, 0), # 021 Yellow (242, 203, 0), # 022 Light yellow (241, 225, 14), # 025 Brimstone yellow (116, 2, 16), # 312 Burgundy (145, 8, 20), # 030 Dark red (1...
pallet_color = [(231, 234, 238), (252, 166, 0), (232, 167, 0), (254, 198, 0), (242, 203, 0), (241, 225, 14), (116, 2, 16), (145, 8, 20), (175, 0, 11), (199, 12, 0), (211, 48, 0), (221, 68, 0), (236, 102, 0), (255, 109, 0), (65, 40, 114), (93, 43, 104), (120, 95, 162), (186, 148, 188), (195, 40, 106), (239, 135, 184), (...
# All metrics are treated as gauge as the counter instrument don't provide a set # method and for performance, it's always good to avoid calculation when ever it's possible. # Using the inc() method require the diff to be calculated! metrics = [ ## Custom metrics ("up", "the status of the node (1=running, ...
metrics = [('up', 'the status of the node (1=running, 0=down, -1=connection issue, -2=node error)'), ('peers_count', 'how many peers the node is seeing'), ('sigs_count', 'how many nodes are currently validating'), ('header_nextValidators_count', 'how many nodes are in the validators set for the next epoch'), ('header_n...
""" Reference: https://leetcode.com/problems/strange-printer/discuss/106810/Java-O(n3)-DP-Solution-with-Explanation-and-Simple-Optimization """ class Solution: def strangePrinter(self, s: str) -> int: str_size = len(s) if str_size == 0: return 0 # init with the value...
""" Reference: https://leetcode.com/problems/strange-printer/discuss/106810/Java-O(n3)-DP-Solution-with-Explanation-and-Simple-Optimization """ class Solution: def strange_printer(self, s: str) -> int: str_size = len(s) if str_size == 0: return 0 dp = [[str_size] * str_size...
def test_slash_request_forbidden(client): assert client.get("/").status_code == 404 def test_api_root_request_forbidden(client): assert client.get("/api").status_code == 404 assert client.get("/api/").status_code == 404 def test_auth_root_request_forbidden(client): assert client.get("/auth").status_...
def test_slash_request_forbidden(client): assert client.get('/').status_code == 404 def test_api_root_request_forbidden(client): assert client.get('/api').status_code == 404 assert client.get('/api/').status_code == 404 def test_auth_root_request_forbidden(client): assert client.get('/auth').status_co...
def search_staff(): query = """ query ($id: Int, $search: String, $type: MediaType) { Media(search: $search, id: $id, type: $type) { id idMal type title { romaji english } staff { edge...
def search_staff(): query = '\n query ($id: Int, $search: String, $type: MediaType) {\n Media(search: $search, id: $id, type: $type) {\n id\n idMal\n type\n title {\n romaji\n english\n }\n staff {\n ...
a, b, c = map(int, input().split()) if (a == b and a != c) or (a ==c and a != b) or (b == c and b != a): print("Yes") else: print("No")
(a, b, c) = map(int, input().split()) if a == b and a != c or (a == c and a != b) or (b == c and b != a): print('Yes') else: print('No')
#Check for the existence of file no_of_items=0 try: f=open("./TODO (CLI-VER)/todolist.txt") p=0 for i in f.readlines():#Counting the number of items if the file exists already p+=1 no_of_items=p-2 except: f=open("./TODO (CLI-VER)/todolist.txt",'w') f.write("_________TODO LIST__________\...
no_of_items = 0 try: f = open('./TODO (CLI-VER)/todolist.txt') p = 0 for i in f.readlines(): p += 1 no_of_items = p - 2 except: f = open('./TODO (CLI-VER)/todolist.txt', 'w') f.write('_________TODO LIST__________\n') f.write(' TIME WORK') finally: f.close() p...
class Solution: def minFlips(self, target: str) -> int: nflips = 0 for ison in map(lambda x : x == '1', target): if ((not ison) and nflips % 2 == 1) or (ison and nflips % 2 == 0): nflips += 1 return nflips
class Solution: def min_flips(self, target: str) -> int: nflips = 0 for ison in map(lambda x: x == '1', target): if not ison and nflips % 2 == 1 or (ison and nflips % 2 == 0): nflips += 1 return nflips
""" Leetcode #464 """ class Solution: def canIWin(self, maxChoosableInteger: int, desiredTotal: int) -> bool: seen = {} def helper(choices, total): if choices[-1] >= total: return True # check if subproblem is already solved key = tuple(ch...
""" Leetcode #464 """ class Solution: def can_i_win(self, maxChoosableInteger: int, desiredTotal: int) -> bool: seen = {} def helper(choices, total): if choices[-1] >= total: return True key = tuple(choices) if key in seen: r...
class Solution: def searchMatrix(self, matrix: List[List[int]], target: int) -> bool: for i in matrix: for j in i: if j==target:return True return False
class Solution: def search_matrix(self, matrix: List[List[int]], target: int) -> bool: for i in matrix: for j in i: if j == target: return True return False
class FermiDataGetter(object): def __init__(self) -> None: raise NotImplementedError()
class Fermidatagetter(object): def __init__(self) -> None: raise not_implemented_error()
# -*- coding: utf-8 -*- ''' >>> from pycm import * >>> import os >>> import json >>> y_actu = [2, 0, 2, 2, 0, 1, 1, 2, 2, 0, 1, 2] >>> y_pred = [0, 0, 2, 1, 0, 2, 1, 0, 2, 0, 2, 2] >>> cm = ConfusionMatrix(y_actu, y_pred) >>> cm pycm.ConfusionMatrix(classes: [0, 1, 2]) >>> len(cm) 3 >>> print(cm) Predict 0 ...
""" >>> from pycm import * >>> import os >>> import json >>> y_actu = [2, 0, 2, 2, 0, 1, 1, 2, 2, 0, 1, 2] >>> y_pred = [0, 0, 2, 1, 0, 2, 1, 0, 2, 0, 2, 2] >>> cm = ConfusionMatrix(y_actu, y_pred) >>> cm pycm.ConfusionMatrix(classes: [0, 1, 2]) >>> len(cm) 3 >>> print(cm) Predict 0 1 2 Actual 0 ...
#encoding:utf-8 subreddit = 'talesfromtechsupport' t_channel = '@r_talesfromtechsupport' def send_post(submission, r2t): return r2t.send_simple(submission)
subreddit = 'talesfromtechsupport' t_channel = '@r_talesfromtechsupport' def send_post(submission, r2t): return r2t.send_simple(submission)
def factors(n): factorlist=[] for i in range(1,n+1): if n%i==0: factorlist=factorlist+[i] return(factorlist) def isprime(n): return(factors(n)==[1,n]) def sumprimes(l): sum=0 for i in range(0,len(l)): if isprime(l[i]): sum=s...
def factors(n): factorlist = [] for i in range(1, n + 1): if n % i == 0: factorlist = factorlist + [i] return factorlist def isprime(n): return factors(n) == [1, n] def sumprimes(l): sum = 0 for i in range(0, len(l)): if isprime(l[i]): sum = sum + l[i] ...
def for_A(): """We are creating user defined function for alphabetical pattern of capital A with "*" symbol""" row=7 col=5 for i in range(row): for j in range(col): if ((j==0 or j==4)and i>0)or ((i==0 or i==4)and j>0 and j<4): print("*",end=" ") else: ...
def for_a(): """We are creating user defined function for alphabetical pattern of capital A with "*" symbol""" row = 7 col = 5 for i in range(row): for j in range(col): if (j == 0 or j == 4) and i > 0 or ((i == 0 or i == 4) and j > 0 and (j < 4)): print('*', end=' ') ...
# A python method for an optimized Bubble Sort Algorithm def bubble_sort(arr): n = len(arr) # Traverse through all array elements for i in range(n): swapped = False # Last i elements are already in place for j in range(0, n-i-1): # Traverse the array from - to n-i-1 ...
def bubble_sort(arr): n = len(arr) for i in range(n): swapped = False for j in range(0, n - i - 1): if arr[j] > arr[j + 1]: (arr[j], arr[j + 1]) = (arr[j + 1], arr[j]) swapped = True if swapped == False: break return arr ' arr =...