content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
lst = [8, 3, 9, 6, 4, 7, 5, 2, 1] def main(): test(lst) def test(lst): line_one = [] reverse_line_two = lst shifted_num = [] reverse_line_two = reverse_line_two[::-1] limit = len(reverse_line_two) for i in range(limit): line_one.append(i + 1) line_one.pop(0) left = reverse_...
lst = [8, 3, 9, 6, 4, 7, 5, 2, 1] def main(): test(lst) def test(lst): line_one = [] reverse_line_two = lst shifted_num = [] reverse_line_two = reverse_line_two[::-1] limit = len(reverse_line_two) for i in range(limit): line_one.append(i + 1) line_one.pop(0) left = reverse_...
# -*- coding: utf-8 -*- """ Created on Sun Sep 3 23:45:39 2017 @author: ASUS This code snippet takes the complement and reverse of a DNA string """ string = 'GTGGTTACGCTCCCGGGGGGGTTCTACGTGCAGATACTGTTCGGGAAGAAGGAGGCACGTCAGGGAGCGCACCCCCCGGTCTACTTGACGGTGGTGAACGTTATCGGCTGGGCCATGTCGTGGAGATAGGAAGCAGGGGAAGTGTGTAAGACAAGTGTA...
""" Created on Sun Sep 3 23:45:39 2017 @author: ASUS This code snippet takes the complement and reverse of a DNA string """ string = 'GTGGTTACGCTCCCGGGGGGGTTCTACGTGCAGATACTGTTCGGGAAGAAGGAGGCACGTCAGGGAGCGCACCCCCCGGTCTACTTGACGGTGGTGAACGTTATCGGCTGGGCCATGTCGTGGAGATAGGAAGCAGGGGAAGTGTGTAAGACAAGTGTACGTGTGTGCATATCTTTTCGTTTGT...
def age_predict(): name = input("What is your name?\n") print("Hello " + name + " it is nice to meet you!") x = True while x: age = input("How old are you " + name + "?\n") if age.isnumeric(): x = False else: print("Please try again.") age_date = ((100...
def age_predict(): name = input('What is your name?\n') print('Hello ' + name + ' it is nice to meet you!') x = True while x: age = input('How old are you ' + name + '?\n') if age.isnumeric(): x = False else: print('Please try again.') age_date = 100 -...
def get_eben(n: list): if sum(n) % 2 == 0: return int("".join(map(str, n))) num = n s = sum(num) while s % 2 != 0: s def main(): t = int(input()) for _ in range(t): length = int(input()) n = map(int, input().split()) print(get_eben(n...
def get_eben(n: list): if sum(n) % 2 == 0: return int(''.join(map(str, n))) num = n s = sum(num) while s % 2 != 0: s def main(): t = int(input()) for _ in range(t): length = int(input()) n = map(int, input().split()) print(get_eben(n)) if __name__ == '__m...
# encoding: utf-8 class Enum(object): @classmethod def get_keys(cls): return filter(lambda x: not x.startswith('_'), cls.__dict__.keys()) @classmethod def items(cls): return map(lambda x: (x, getattr(cls, x)), cls.get_keys()) @classmethod def get_values(cls): return map...
class Enum(object): @classmethod def get_keys(cls): return filter(lambda x: not x.startswith('_'), cls.__dict__.keys()) @classmethod def items(cls): return map(lambda x: (x, getattr(cls, x)), cls.get_keys()) @classmethod def get_values(cls): return map(lambda x: getatt...
def euro(b, m, c): czas = dict() mecze = dict() baza = dict() wynik = ['', float('inf')] for baz in b: baza[baz[0]] = baz[1] for mecz in m: if mecz[0] not in mecze.keys(): mecze[mecz[0]] = [mecz[2]] else: mecze[mecz[0]].append(mecz[2]) if...
def euro(b, m, c): czas = dict() mecze = dict() baza = dict() wynik = ['', float('inf')] for baz in b: baza[baz[0]] = baz[1] for mecz in m: if mecz[0] not in mecze.keys(): mecze[mecz[0]] = [mecz[2]] else: mecze[mecz[0]].append(mecz[2]) if m...
dataset_type = 'CocoDataset' data_root = '/work/u5216579/ctr/data/PCB_v3/'#'/home/u5216579/vf/data/coco/' #'data/coco/' img_norm_cfg = dict( #mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) mean=[38.720, 51.155, 40.22], std=[53.275, 52.273, 46.819], to_rgb=True) train_pipeline = [ ...
dataset_type = 'CocoDataset' data_root = '/work/u5216579/ctr/data/PCB_v3/' img_norm_cfg = dict(mean=[38.72, 51.155, 40.22], std=[53.275, 52.273, 46.819], to_rgb=True) train_pipeline = [dict(type='LoadImageFromFile'), dict(type='LoadAnnotations', with_bbox=True), dict(type='Resize', img_scale=(512, 512), keep_ratio=True...
def get_nd_par(ref_len, read_type, basecaller): if read_type: if read_type == "dRNA": return drna_nd_par(ref_len, basecaller) else: return cdna_nd_par(ref_len, read_type) else: return dna_nd_par(ref_len, basecaller) def seg_par(ref_len, changepoint): if ref_...
def get_nd_par(ref_len, read_type, basecaller): if read_type: if read_type == 'dRNA': return drna_nd_par(ref_len, basecaller) else: return cdna_nd_par(ref_len, read_type) else: return dna_nd_par(ref_len, basecaller) def seg_par(ref_len, changepoint): if ref_l...
if __name__ == "__main__": T = int(input().strip()) correct = 1 << 32 for _ in range(T): num = int(input().strip()) print(~num + correct)
if __name__ == '__main__': t = int(input().strip()) correct = 1 << 32 for _ in range(T): num = int(input().strip()) print(~num + correct)
def format_user(userdata, format): result = "" u = userdata["name"] if format == "greeting": result = "{}, {} {}".format(u["title"], u["first"], u["last"]) elif format == "short": result = "{}{}".format(u["title"], u["last"]) elif format == "country": result = userdata["nat"]...
def format_user(userdata, format): result = '' u = userdata['name'] if format == 'greeting': result = '{}, {} {}'.format(u['title'], u['first'], u['last']) elif format == 'short': result = '{}{}'.format(u['title'], u['last']) elif format == 'country': result = userdata['nat']...
""" DEVA AI Oversight Tool. Copyright 2021-2022 Gradient Institute Ltd. <info@gradientinstitute.org> """
""" DEVA AI Oversight Tool. Copyright 2021-2022 Gradient Institute Ltd. <info@gradientinstitute.org> """
t = ['a', 'b', 'c', 'd', 'e', 'f', 'g'] print(t[3]) print(t[-99:-7]) print(t[-99:-5]) print(t[::])
t = ['a', 'b', 'c', 'd', 'e', 'f', 'g'] print(t[3]) print(t[-99:-7]) print(t[-99:-5]) print(t[:])
SCHEMA = { "$schema": "http://json-schema.org/draft-04/schema#", "definitions": { "DEB_REPO_SCHEMA": { "type": "object", "required": [ "name", "uri", "suite", "section" ], "properties": { ...
schema = {'$schema': 'http://json-schema.org/draft-04/schema#', 'definitions': {'DEB_REPO_SCHEMA': {'type': 'object', 'required': ['name', 'uri', 'suite', 'section'], 'properties': {'name': {'type': 'string'}, 'type': {'type': 'string', 'enum': ['deb']}, 'uri': {'type': 'string'}, 'priority': {'anyOf': [{'type': 'integ...
# -*- coding: utf-8 -*- # Author: Rodrigo E. Principe # Email: fitoprincipe82 at gmail # Make a prediction with weights # one vector has n elements # p = (element1*weight1) + (element2*weight2) + (elementn*weightn) + bias # if p >= 0; 1; 0 def predict(vector, bias, weights): pairs = zip(vector, weights) # [[eleme...
def predict(vector, bias, weights): pairs = zip(vector, weights) for (element, weight) in pairs: bias += element * weight return 1.0 if bias >= 0.0 else 0.0 def train_weights(train, l_rate, n_epoch, bias=0): first_vector = train[0][0] weights = [random() for i in range(len(first_vector))] ...
{ "variables": { "buffer_impl" : "<!(node -pe 'v=process.versions.node.split(\".\");v[0] > 0 || v[0] == 0 && v[1] >= 11 ? \"POS_0_11\" : \"PRE_0_11\"')", "callback_style" : "<!(node -pe 'v=process.versions.v8.split(\".\");v[0] > 3 || v[0] == 3 && v[1] >= 20 ? \"POS_3_20\" : \"PRE_3_20\"')" }, "targets": [...
{'variables': {'buffer_impl': '<!(node -pe \'v=process.versions.node.split(".");v[0] > 0 || v[0] == 0 && v[1] >= 11 ? "POS_0_11" : "PRE_0_11"\')', 'callback_style': '<!(node -pe \'v=process.versions.v8.split(".");v[0] > 3 || v[0] == 3 && v[1] >= 20 ? "POS_3_20" : "PRE_3_20"\')'}, 'targets': [{'target_name': 'openvg', '...
#method 'find' finds index positon of specified string #index position starts with 0 my_fruit = "My favorite fruit is apple".find('apple') print(my_fruit)
my_fruit = 'My favorite fruit is apple'.find('apple') print(my_fruit)
"""Constants for Seat Connect library.""" BASE_SESSION = 'https://msg.volkswagen.de' BASE_AUTH = 'https://identity.vwgroup.io' CLIENT_ID = '7f045eee-7003-4379-9968-9355ed2adb06%40apps_vw-dilab_com' XCLIENT_ID = '28cd30c6-dee7-4529-a0e6-b1e07ff90b79' XAPPVERSION = '3.2.6' XAPPNAME = 'es.seatauto.connect' USER_AGENT = '...
"""Constants for Seat Connect library.""" base_session = 'https://msg.volkswagen.de' base_auth = 'https://identity.vwgroup.io' client_id = '7f045eee-7003-4379-9968-9355ed2adb06%40apps_vw-dilab_com' xclient_id = '28cd30c6-dee7-4529-a0e6-b1e07ff90b79' xappversion = '3.2.6' xappname = 'es.seatauto.connect' user_agent = 'o...
# File: Slicing_in_Python.py # Description: How to slice strings in Python # Environment: PyCharm and Anaconda environment # # MIT License # Copyright (c) 2018 Valentyn N Sichkar # github.com/sichkar-valentyn # # Reference to: # [1] Valentyn N Sichkar. Slicing in Python // GitHub platform [Electronic resource]. URL: ht...
dna = 'ATTCGGAGCT' print(dna[1]) print(dna[1:4]) print(dna[:4]) print(dna[4:]) print(dna[-4:]) print(dna[1:-1]) print(dna[1:-1:2]) print(dna[::-1])
class Hund: def __init__(self, alder, vekt): self._alder = alder self._vekt = vekt self._metthet = 10 def hentAlder(self): return self._alder def hentVekt(self): return self._vekt def spring(self): self._metthet -= 1 if self._metthet < 5: ...
class Hund: def __init__(self, alder, vekt): self._alder = alder self._vekt = vekt self._metthet = 10 def hent_alder(self): return self._alder def hent_vekt(self): return self._vekt def spring(self): self._metthet -= 1 if self._metthet < 5: ...
# # PySNMP MIB module LLDP-EXT-DOT1-PE-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/LLDP-EXT-DOT1-PE-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 19:57:50 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (defau...
(object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_union, value_range_constraint, constraints_intersection, value_size_constraint, single_value_constraint) ...
# Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode: output = ListNode(None) outputPointer = output carry = 0 ...
class Solution: def add_two_numbers(self, l1: ListNode, l2: ListNode) -> ListNode: output = list_node(None) output_pointer = output carry = 0 (pointer1, pointer2) = (l1, l2) while pointer1 or pointer2: if pointer1 and pointer2: new = pointer1.val ...
class Trackable(object): def __init__(self, name): self.name = name print('CREATE {}'.format(name)) def __del__(self): print('DELETE {}'.format(self.name))
class Trackable(object): def __init__(self, name): self.name = name print('CREATE {}'.format(name)) def __del__(self): print('DELETE {}'.format(self.name))
CURRENCY_ALGO = "ALGO" EXCHANGE_ALGORAND_BLOCKCHAIN = "algorand_blockchain" TRANSACTION_TYPE_PAYMENT = "pay" TRANSACTION_TYPE_ASSET_TRANSFER = "axfer" TRANSACTION_TYPE_APP_CALL = "appl" APPLICATION_ID_TINYMAN_v10 = 350338509 APPLICATION_ID_TINYMAN_v11 = 552635992 APPLICATION_ID_YIELDLY = 233725848 APPLI...
currency_algo = 'ALGO' exchange_algorand_blockchain = 'algorand_blockchain' transaction_type_payment = 'pay' transaction_type_asset_transfer = 'axfer' transaction_type_app_call = 'appl' application_id_tinyman_v10 = 350338509 application_id_tinyman_v11 = 552635992 application_id_yieldly = 233725848 application_id_yieldl...
XK_emspace = 0xaa1 XK_enspace = 0xaa2 XK_em3space = 0xaa3 XK_em4space = 0xaa4 XK_digitspace = 0xaa5 XK_punctspace = 0xaa6 XK_thinspace = 0xaa7 XK_hairspace = 0xaa8 XK_emdash = 0xaa9 XK_endash = 0xaaa XK_signifblank = 0xaac XK_ellipsis = 0xaae XK_doubbaselinedot = 0xaaf XK_onethird = 0xab0 XK_twothirds = 0xab1 XK_onefif...
xk_emspace = 2721 xk_enspace = 2722 xk_em3space = 2723 xk_em4space = 2724 xk_digitspace = 2725 xk_punctspace = 2726 xk_thinspace = 2727 xk_hairspace = 2728 xk_emdash = 2729 xk_endash = 2730 xk_signifblank = 2732 xk_ellipsis = 2734 xk_doubbaselinedot = 2735 xk_onethird = 2736 xk_twothirds = 2737 xk_onefifth = 2738 xk_tw...
firstname = str(input("Enter your first name: ")) lastname = str(input("Enter your last name: ")) print("Initials: " + firstname[0] + "." + lastname[0] + ".")
firstname = str(input('Enter your first name: ')) lastname = str(input('Enter your last name: ')) print('Initials: ' + firstname[0] + '.' + lastname[0] + '.')
""" The module for training the SVM classifer. """ def train(database_num=3): """ use SVM provided by sklearn with databases to train the classifier and dump it into a pickle. :param database_num: 3 means NUAA, CASIA, REPLAY-ATTACK; 2 means CASIA, REPLAY-ATTACK. """
""" The module for training the SVM classifer. """ def train(database_num=3): """ use SVM provided by sklearn with databases to train the classifier and dump it into a pickle. :param database_num: 3 means NUAA, CASIA, REPLAY-ATTACK; 2 means CASIA, REPLAY-ATTACK. """
POST_JSON_RESPONSES = { '/auth/realms/test/protocol/openid-connect/token': { 'access_token': '54604e3b-4d6a-419d-9173-4b1af0530bfb', 'token_type': 'bearer', 'expires_in': 42695, 'scope': 'read write'}, '/v2/observations': { 'dimensionDeclarations': [ { ...
post_json_responses = {'/auth/realms/test/protocol/openid-connect/token': {'access_token': '54604e3b-4d6a-419d-9173-4b1af0530bfb', 'token_type': 'bearer', 'expires_in': 42695, 'scope': 'read write'}, '/v2/observations': {'dimensionDeclarations': [{'name': 'study', 'dimensionType': 'attribute', 'sortIndex': None, 'value...
def ends_with_punctuation(string): if string is None: return False for punctuation in ['.', '!', '?']: if string.rstrip().endswith(punctuation): return True return False
def ends_with_punctuation(string): if string is None: return False for punctuation in ['.', '!', '?']: if string.rstrip().endswith(punctuation): return True return False
# PREDSTORM L1 input parameters file # ---------------------------------- # If True, show interpolated data points on the DSCOVR input plot showinterpolated = True # Time interval for both the observed and predicted windDelta T (hours), start with 24 hours here (covers 1 night of aurora) deltat = 24 # Time range of ...
showinterpolated = True deltat = 24 trainstart = '2006-01-01 00:00' trainend = '2010-01-01 00:00'
size = int(input()) matrix = [] for _ in range(size): matrix.append([int(x) for x in input().split()]) primary_diagonal_sum = 0 secondary_diagonal_sum = 0 for i in range(len(matrix)): primary_diagonal_sum += matrix[i][i] secondary_diagonal_sum += matrix[i][size - i - 1] total = abs(primary_diagonal_sum...
size = int(input()) matrix = [] for _ in range(size): matrix.append([int(x) for x in input().split()]) primary_diagonal_sum = 0 secondary_diagonal_sum = 0 for i in range(len(matrix)): primary_diagonal_sum += matrix[i][i] secondary_diagonal_sum += matrix[i][size - i - 1] total = abs(primary_diagonal_sum - se...
class BlockLinkedList: def __init__(self): self.size = 0 self.header = None self.trailer = None def addbh(self, block): if self.size == 0: self.trailer = block else: block.set_next(self.header) self.header.set_previous(block) self.header = block self.size += 1 def addbt(self, block): i...
class Blocklinkedlist: def __init__(self): self.size = 0 self.header = None self.trailer = None def addbh(self, block): if self.size == 0: self.trailer = block else: block.set_next(self.header) self.header.set_previous(block) ...
# -*- coding:utf-8 -*- # package information. INFO = dict( name = "exputils", description = "Utilities for experiment analysis", author = "Yohsuke T. Fukai", author_email = "ysk@yfukai.net", license = "MIT License", url = "", classifiers = [ "Programming Language :: Python ::...
info = dict(name='exputils', description='Utilities for experiment analysis', author='Yohsuke T. Fukai', author_email='ysk@yfukai.net', license='MIT License', url='', classifiers=['Programming Language :: Python :: 3.6', 'License :: OSI Approved :: MIT License'])
""" from rest_framework.serializers import ModelSerializer from netbox_newplugin.models import MyModel1 class MyModel1Serializer(ModelSerializer): class Meta: model = MyModel1 fields = '__all__' """
""" from rest_framework.serializers import ModelSerializer from netbox_newplugin.models import MyModel1 class MyModel1Serializer(ModelSerializer): class Meta: model = MyModel1 fields = '__all__' """
# Given a linked list, determine if it has a cycle in it. # # To represent a cycle in the given linked list, we use an integer pos which # represents the position (0-indexed) in the linked list where tail connects to. # If pos is -1, then there is no cycle in the linked list. # # Input: head = [3,2,0,-4], pos = 1 # Out...
class Listnode: def __init__(self, val): self.val = val self.next = None class Solution: def is_cycle(self, head): pointer1 = head pointer2 = head.next while pointer1 != pointer2: if pointer2 is None or pointer2.next is None: return False ...
def print_table(n): """ (int) -> NoneType Print the multiplication table for numbers 1 through n inclusive. >>> print_table(5) 1 2 3 4 5 1 1 2 3 4 5 2 2 4 6 8 10 3 3 6 9 12 15 4 4 8 12 16 20 5 5 10 15 20 25 """ # The numbers to include in the table. numbers = list(...
def print_table(n): """ (int) -> NoneType Print the multiplication table for numbers 1 through n inclusive. >>> print_table(5) 1 2 3 4 5 1 1 2 3 4 5 2 2 4 6 8 10 3 3 6 9 12 15 4 4 8 12 16 20 5 5 10 15 20 25 """ numbers = list(range(1, n + 1)) for i in numbers: ...
# %% [492. Construct the Rectangle](https://leetcode.com/problems/construct-the-rectangle/) class Solution: def constructRectangle(self, area: int) -> List[int]: w = int(area ** 0.5) while area % w: w -= 1 return area // w, w
class Solution: def construct_rectangle(self, area: int) -> List[int]: w = int(area ** 0.5) while area % w: w -= 1 return (area // w, w)
"""Empty test. Empty so that tox can be used for CI in Github actions """ # def test_sum(): # assert sum([1, 2, 3]) == 6, "Should be 6" def test(): assert True is True
"""Empty test. Empty so that tox can be used for CI in Github actions """ def test(): assert True is True
def generateMatrix(n): """ :type n: int :rtype: List[List[int]] """ ans = [[0 for i in range(n)] for j in range(n)] # i = j = 0 # blow = 0 # bhigh = n-1 # for num in range(1, n ** 2 +1): # ans[i][j] = num # if j < bhigh and i == blow: # j += 1 # ...
def generate_matrix(n): """ :type n: int :rtype: List[List[int]] """ ans = [[0 for i in range(n)] for j in range(n)] row = list(range(n)) col = list(range(n)) num = 1 while row or col: for j in col: ans[row[0]][j] = num num += 1 row.pop(0) ...
# config.py class Config(object): embed_size = 300 in_channels = 1 num_channels = 100 kernel_size = [3,4,5] output_size = 4 max_epochs = 10 lr = 0.25 batch_size = 64 max_sen_len = 20 dropout_keep = 0.6
class Config(object): embed_size = 300 in_channels = 1 num_channels = 100 kernel_size = [3, 4, 5] output_size = 4 max_epochs = 10 lr = 0.25 batch_size = 64 max_sen_len = 20 dropout_keep = 0.6
# Byte code returned from flask-http in the case of auth failure. NOT_AUTHORIZED_BYTE_STRING = b'Unauthorized Access' def check_for_unauthorized_response(res): """ Raise an Unauthorized exception only if the response object contains the Not Authorized byte string. :param res: Response object to check...
not_authorized_byte_string = b'Unauthorized Access' def check_for_unauthorized_response(res): """ Raise an Unauthorized exception only if the response object contains the Not Authorized byte string. :param res: Response object to check. :raise Unauthorized: If the response object contains the Not ...
class Color: def __init__(self, r, g, b, alpha=255): self.r = r self.g = g self.b = b self.alpha = alpha if self.r < 0 or self.g < 0 or self.b < 0 or self.alpha < 0: raise ValueError("color values can't be below 0") if self.r > 255 or self.g > 255 or self...
class Color: def __init__(self, r, g, b, alpha=255): self.r = r self.g = g self.b = b self.alpha = alpha if self.r < 0 or self.g < 0 or self.b < 0 or (self.alpha < 0): raise value_error("color values can't be below 0") if self.r > 255 or self.g > 255 or s...
def ConverterTempo(tempo, unidade): if unidade == "m": return tempo*60 if unidade == "s": return tempo def ConverteMetros(quantidade, unidade): if unidade == "M": return quantidade*100 if unidade == "m": return quantidade
def converter_tempo(tempo, unidade): if unidade == 'm': return tempo * 60 if unidade == 's': return tempo def converte_metros(quantidade, unidade): if unidade == 'M': return quantidade * 100 if unidade == 'm': return quantidade
class TokenType(object): END = "" ILLEGAL = "ILLEGAL" # Operators PLUS = "+" MINUS = "-" SLASH = "/" AT = "@" # Identifiers NUMBER = "NUMBER" MODIFIER = "MODIFIER" # keywords NOW = "NOW" class Token(object): def __init__(self, tok_type, tok_literal): self.to...
class Tokentype(object): end = '' illegal = 'ILLEGAL' plus = '+' minus = '-' slash = '/' at = '@' number = 'NUMBER' modifier = 'MODIFIER' now = 'NOW' class Token(object): def __init__(self, tok_type, tok_literal): self.token_type = tok_type self.token_literal = ...
def sort(L): n = len(L) # Build Heap for i in range(n-1, -1, -1): L = heapify(L, i, n) for i in range(n-1, 0, -1): L[i], L[0] = L[0], L[i] n -= 1 heapify(L, 0, n) return L def heapify(L, _v, n): # v is index to be passed v = _v + 1 largest = v if 2*v <=...
def sort(L): n = len(L) for i in range(n - 1, -1, -1): l = heapify(L, i, n) for i in range(n - 1, 0, -1): (L[i], L[0]) = (L[0], L[i]) n -= 1 heapify(L, 0, n) return L def heapify(L, _v, n): v = _v + 1 largest = v if 2 * v <= n: if L[2 * v - 1] > L[v -...
#################################################### # # Components applicable to all types of items # #################################################### # what type of item is this entity # this is primarily used in iterable statements as a filter class TypeOfItem: def __init__(self, label=''): self...
class Typeofitem: def __init__(self, label=''): self.label = label class Actionlist: def __init__(self, action_list=''): self.actions = action_list class Name: def __init__(self, label=''): self.label = label class Description: def __init__(self, label=''): self.la...
def get_ages() -> list[int]: with open('input.txt') as f: line, = f.readlines() return list(map(int, line.split(','))) def step_day(ages: list[int]): for i, age in enumerate(ages[:]): age, *newborn = tick(age) ages[i] = age ages.extend(newborn) def tick(age: int) -> list[...
def get_ages() -> list[int]: with open('input.txt') as f: (line,) = f.readlines() return list(map(int, line.split(','))) def step_day(ages: list[int]): for (i, age) in enumerate(ages[:]): (age, *newborn) = tick(age) ages[i] = age ages.extend(newborn) def tick(age: int) -> l...
''' Given an array of integers A sorted in non-decreasing order, return an array of the squares of each number, also in sorted non-decreasing order. Example 1: Input: [-4,-1,0,3,10] Output: [0,1,9,16,100] Example 2: Input: [-7,-3,2,3,11] Output: [4,9,9,49,121] Note: 1 <= A.length <= 10000 -10000 <= A[i] <= 1...
""" Given an array of integers A sorted in non-decreasing order, return an array of the squares of each number, also in sorted non-decreasing order. Example 1: Input: [-4,-1,0,3,10] Output: [0,1,9,16,100] Example 2: Input: [-7,-3,2,3,11] Output: [4,9,9,49,121] Note: 1 <= A.length <= 10000 -10000 <= A[i] <= 1...
tuple1 = ("apple", "banana", "cherry") tuple2 = (1, 5, 7, 9, 3) tuple3 = (True, False, False) print(tuple1) print(tuple2) print(tuple3)
tuple1 = ('apple', 'banana', 'cherry') tuple2 = (1, 5, 7, 9, 3) tuple3 = (True, False, False) print(tuple1) print(tuple2) print(tuple3)
class Node: def __init__(self,data): self.data = data self.previous = None self.next = None class removeDuplicates: def __init__(self): self.head = None self.tail = None def remove_duplicates(self): if (self.head == None): return else: ...
class Node: def __init__(self, data): self.data = data self.previous = None self.next = None class Removeduplicates: def __init__(self): self.head = None self.tail = None def remove_duplicates(self): if self.head == None: return else: ...
class Parameter: def __init__(self, name: str, klass: str, data_member, required=True, array=False): self._name = name self._klass = klass self._data_member = data_member self._required = required self._array = array def __eq__(self, other): return True if \ ...
class Parameter: def __init__(self, name: str, klass: str, data_member, required=True, array=False): self._name = name self._klass = klass self._data_member = data_member self._required = required self._array = array def __eq__(self, other): return True if self....
# coding: utf-8 # # Copyright 2022 :Barry-Thomas-Paul: Moss # # 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 applicab...
class Duplexmode(object): """ Const Class These constants specify available duplex modes. See Also: `API DuplexMode <https://api.libreoffice.org/docs/idl/ref/namespacecom_1_1sun_1_1star_1_1view_1_1DuplexMode.html>`_ """ __ooo_ns__: str = 'com.sun.star.view' __ooo_full_ns__: str = '...
"""Calculation history Class""" class Calculations: """Calculation history Class""" history = [] @staticmethod def clear_history(): """ clear the history items""" Calculations.history.clear() return True @staticmethod def count_history(): """ get the length of h...
"""Calculation history Class""" class Calculations: """Calculation history Class""" history = [] @staticmethod def clear_history(): """ clear the history items""" Calculations.history.clear() return True @staticmethod def count_history(): """ get the length of ...
fname = input('Enter the name of the file: ') if(len(fname) < 1) : fname = 'clown.txt' hand = open(fname) di = dict() for line in hand: line = line.rstrip() wds = line.split() for w in wds: ##if not there, the count is zero ##if it is there, just add + 1 di[w] = di.get(w, 0) + 1 ...
fname = input('Enter the name of the file: ') if len(fname) < 1: fname = 'clown.txt' hand = open(fname) di = dict() for line in hand: line = line.rstrip() wds = line.split() for w in wds: di[w] = di.get(w, 0) + 1 "\n if w in di:\n di[w] = di[w] + 1\n print('*...
class Solution(object): def setZeroes(self, matrix): """ :type matrix: List[List[int]] :rtype: void Do not return anything, modify matrix in-place instead. """ rows_to_zero = set() cols_to_zero = set() for row in range(len(matrix)): for col in rang...
class Solution(object): def set_zeroes(self, matrix): """ :type matrix: List[List[int]] :rtype: void Do not return anything, modify matrix in-place instead. """ rows_to_zero = set() cols_to_zero = set() for row in range(len(matrix)): for col in ra...
def distinct(iterable, keyfunc=None): seen = set() for item in iterable: key = item if keyfunc is None else keyfunc(item) if key not in seen: seen.add(key) yield item
def distinct(iterable, keyfunc=None): seen = set() for item in iterable: key = item if keyfunc is None else keyfunc(item) if key not in seen: seen.add(key) yield item
''' URL: https://leetcode.com/problems/binary-tree-level-order-traversal/ Difficulty: Medium Description: Binary Tree Level Order Traversal Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). For example: Given binary tree [3,9,20,null,null,15,7], ...
""" URL: https://leetcode.com/problems/binary-tree-level-order-traversal/ Difficulty: Medium Description: Binary Tree Level Order Traversal Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). For example: Given binary tree [3,9,20,null,null,15,7], ...
def read_file(): content = open("C:/Users/DIPANSH KHANDELWAL/Desktop/Python Codes/PythonFiles/read_file/read_file.txt") text = content.read() print (text) content.close() read_file()
def read_file(): content = open('C:/Users/DIPANSH KHANDELWAL/Desktop/Python Codes/PythonFiles/read_file/read_file.txt') text = content.read() print(text) content.close() read_file()
NAME='syslog' CFLAGS = [] LDFLAGS = [] LIBS = [] GCC_LIST = ['syslog_plugin']
name = 'syslog' cflags = [] ldflags = [] libs = [] gcc_list = ['syslog_plugin']
class DisjointSets(object): """A simple implementation of the Disjoint Sets data structure. Implements path compression but not union-by-rank. """ def __init__(self, elements): self.num_elements = len(elements) self.num_sets = len(elements) self.parents = {element: element for ...
class Disjointsets(object): """A simple implementation of the Disjoint Sets data structure. Implements path compression but not union-by-rank. """ def __init__(self, elements): self.num_elements = len(elements) self.num_sets = len(elements) self.parents = {element: element for ...
"""This module provides the client to make the connection with the given database.""" class DatabaseClient: """Initializes the connector with the DatabaseFactory object and provides a connector.""" def __init__(self, factory_obj) -> None: """ Initializes the factory object. :factory_...
"""This module provides the client to make the connection with the given database.""" class Databaseclient: """Initializes the connector with the DatabaseFactory object and provides a connector.""" def __init__(self, factory_obj) -> None: """ Initializes the factory object. :factory_o...
#lambda is used to create an anonymous function (function with no name) # It is an inline function that does not contain a return statement a = lambda x: x*2 for i in range(1,6): print(a(i))
a = lambda x: x * 2 for i in range(1, 6): print(a(i))
def solve(a, b): return a + b def driver(): a, b = list(map(int, input().split(' '))) result = solve(a, b) print(solve(a, b)) return result def main(): return driver() if __name__ == '__main__': main()
def solve(a, b): return a + b def driver(): (a, b) = list(map(int, input().split(' '))) result = solve(a, b) print(solve(a, b)) return result def main(): return driver() if __name__ == '__main__': main()
# Program to convert Miles to Kilometers # Taking miles input from the user miles = float(input("Enter value in miles: ")) # conversion factor convFac = 0.621371 # calculate kilometers kilometers = miles / convFac print("%0.2f miles is equal to %0.2f kilometers" % (miles, kilometers))
miles = float(input('Enter value in miles: ')) conv_fac = 0.621371 kilometers = miles / convFac print('%0.2f miles is equal to %0.2f kilometers' % (miles, kilometers))
#!/usr/bin/python # -*- coding: utf-8 -*- # # Copyright &copy; 2014-2016 NetApp, Inc. All Rights Reserved. # # CONFIDENTIALITY NOTICE: THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION OF # NETAPP, INC. USE, DISCLOSURE OR REPRODUCTION IS PROHIBITED WITHOUT THE PRIOR # EXPRESS WRITTEN PERMISSION OF NETAPP, INC. """API Uti...
"""API Utilities""" def ascii_art(version): """ Used to build SolidFire ASCII art. :return: a string with the SolidFire ASCII art. """ art = '\n' art += '\n' art += ' 77 \n' art += ' ...
def venda_mensal(*args): telaCaixa = args[0] telaMensal = args[1] cursor = args[2] QtWidgets = args[3] data1 = telaMensal.data_mensal.text() cursor.execute("select sum(qt_pizzas), sum(qt_esfihas), sum(qt_bebidas), sum(qt_outros), sum(total) from caixa where extract(year_month from data2) = %s ...
def venda_mensal(*args): tela_caixa = args[0] tela_mensal = args[1] cursor = args[2] qt_widgets = args[3] data1 = telaMensal.data_mensal.text() cursor.execute('select sum(qt_pizzas), sum(qt_esfihas), sum(qt_bebidas), sum(qt_outros), sum(total) from caixa where extract(year_month from data2) = %s...
class ApiException(Exception): pass class ResourceNotFound(ApiException): pass class InternalServerException(ApiException): pass class UserNotFound(ApiException): pass class Ratelimited(ApiException): pass class InvalidMetric(ApiException): pass class Authenti...
class Apiexception(Exception): pass class Resourcenotfound(ApiException): pass class Internalserverexception(ApiException): pass class Usernotfound(ApiException): pass class Ratelimited(ApiException): pass class Invalidmetric(ApiException): pass class Authenticationexception(ApiException):...
class Solution: def findDisappearedNumbers(self, nums: List[int]) -> List[int]: arr = [0 for _ in range(len(nums))] for num in nums: arr[num - 1] += 1 ans = [] for i in range(len(arr)): if arr[i] == 0: ans.append(i + ...
class Solution: def find_disappeared_numbers(self, nums: List[int]) -> List[int]: arr = [0 for _ in range(len(nums))] for num in nums: arr[num - 1] += 1 ans = [] for i in range(len(arr)): if arr[i] == 0: ans.append(i + 1) return ans
s = "abdcd" count = 0 for vowelsItem in s: if vowelsItem in "aeiou": count += 1 print("Number of vowels: " + str(count))
s = 'abdcd' count = 0 for vowels_item in s: if vowelsItem in 'aeiou': count += 1 print('Number of vowels: ' + str(count))
# Python3 implementation to # find first element # occurring k times # function to find the # first element occurring # k number of times def firstElement(arr, n, k): # dictionary to count # occurrences of # each element count_map = {}; for i in range(0, n): ...
def first_element(arr, n, k): count_map = {} for i in range(0, n): if arr[i] in count_map.keys(): count_map[arr[i]] += 1 else: count_map[arr[i]] = 1 i += 1 for i in range(0, n): if count_map[arr[i]] == k: return arr[i] i += 1 if __n...
rooms = int(input()) free_chairs = 0 game_on = True for current_room in range(1, rooms + 1): command = input().split() chairs = len(command[0]) visitors = int(command[1]) if chairs > visitors: free_chairs += chairs - visitors elif chairs < visitors: needed_chairs_in_room = visito...
rooms = int(input()) free_chairs = 0 game_on = True for current_room in range(1, rooms + 1): command = input().split() chairs = len(command[0]) visitors = int(command[1]) if chairs > visitors: free_chairs += chairs - visitors elif chairs < visitors: needed_chairs_in_room = visitors -...
def main(): students = [] number_students = int(input()) while number_students > 0: student = input() students.append(student) number_students -= 1 number_days = int(input()) all_missing_students = [] while number_days > 0: curr_num_students = int(input()) ...
def main(): students = [] number_students = int(input()) while number_students > 0: student = input() students.append(student) number_students -= 1 number_days = int(input()) all_missing_students = [] while number_days > 0: curr_num_students = int(input()) ...
""" Input Options ------------- model_path : Input path to generated models - hdf5 file input_catalog : Input catalog path input_format : Input catalog format, see astropy.Table documentation for available formats z_col : Column name for source redshifts ID_col : Column name for source IDs flux_col_end...
""" Input Options ------------- model_path : Input path to generated models - hdf5 file input_catalog : Input catalog path input_format : Input catalog format, see astropy.Table documentation for available formats z_col : Column name for source redshifts ID_col : Column name for source IDs flux_col_end...
def AAsInPeptideListCount(PeptidesListFileLocation): PeptidesListFile = open(PeptidesListFileLocation, 'r') Lines = PeptidesListFile.readlines() PeptidesListFile.close AminoAcidsCount = {'A':0, 'C':0, 'D':0, 'E':0, 'F':0, 'G':0, 'H':0, 'I':0, 'K':0, '...
def a_as_in_peptide_list_count(PeptidesListFileLocation): peptides_list_file = open(PeptidesListFileLocation, 'r') lines = PeptidesListFile.readlines() PeptidesListFile.close amino_acids_count = {'A': 0, 'C': 0, 'D': 0, 'E': 0, 'F': 0, 'G': 0, 'H': 0, 'I': 0, 'K': 0, 'L': 0, 'M': 0, 'N': 0, 'P': 0, 'Q':...
a = 25 b = 0o31 c = 0x19 print(a) print(b) print(c)
a = 25 b = 25 c = 25 print(a) print(b) print(c)
class MaxSparseList: def __init__(self, firstMember, limit: int, weight: callable = lambda x: x[0], value: callable = lambda x: x[1]): self.weight = weight self.value = value self.data = [firstMember] self.limit = limit return def append...
class Maxsparselist: def __init__(self, firstMember, limit: int, weight: callable=lambda x: x[0], value: callable=lambda x: x[1]): self.weight = weight self.value = value self.data = [firstMember] self.limit = limit return def append(self, newMember): w = self.w...
""" Python implementation of Paradox HD7X cameras (and future other modules).""" class ParadoxModuleError(Exception): """Generic exception for Paradox modules.""" class ParadoxCameraError(ParadoxModuleError): """Generic exception for Camera modules."""
""" Python implementation of Paradox HD7X cameras (and future other modules).""" class Paradoxmoduleerror(Exception): """Generic exception for Paradox modules.""" class Paradoxcameraerror(ParadoxModuleError): """Generic exception for Camera modules."""
## Editing same list and then separating at the end """ # Definition for a Node. class Node: def __init__(self, x: int, next: 'Node' = None, random: 'Node' = None): self.val = int(x) self.next = next self.random = random """ class Solution: def copyRandomList(self, head: 'Node') -> 'No...
""" # Definition for a Node. class Node: def __init__(self, x: int, next: 'Node' = None, random: 'Node' = None): self.val = int(x) self.next = next self.random = random """ class Solution: def copy_random_list(self, head: 'Node') -> 'Node': if head == None: return h...
class RGBColor: def __init__(self, r, g, b): self.r = r self.g = g self.b = b def __str__(self): return "rgb({},{},{})".format(self.r, self.g, self.b) def as_hex(self): return HexColor("#%02x%02x%02x" % (self.r, self.g, self.b)) def as_cmyk(self): k = m...
class Rgbcolor: def __init__(self, r, g, b): self.r = r self.g = g self.b = b def __str__(self): return 'rgb({},{},{})'.format(self.r, self.g, self.b) def as_hex(self): return hex_color('#%02x%02x%02x' % (self.r, self.g, self.b)) def as_cmyk(self): k =...
class HightonConstants: # is used for requests GET = 'GET' POST = 'POST' PUT = 'PUT' DELETE = 'DELETE' HIGHRISE_URL = 'highrisehq.com' # Company COMPANIES = 'companies' COMPANY = 'company' COMPANY_NAME = 'company-name' COMPANY_ID = 'company-id' # Case KASES = 'kases...
class Hightonconstants: get = 'GET' post = 'POST' put = 'PUT' delete = 'DELETE' highrise_url = 'highrisehq.com' companies = 'companies' company = 'company' company_name = 'company-name' company_id = 'company-id' kases = 'kases' deals = 'deals' task = 'task' tasks = 't...
""" we define a video object to record video information. """ # coding: utf-8 class Video: """ obj """ def __init__(self, video_id): self.video_id = video_id self.user_id = '' self.title = '' self.upload_time = '' # timestamp self.avatar_path = '' se...
""" we define a video object to record video information. """ class Video: """ obj """ def __init__(self, video_id): self.video_id = video_id self.user_id = '' self.title = '' self.upload_time = '' self.avatar_path = '' self.avatar_url = '' self....
""" GLSL shader code to render bitmap glyphs.\ :download:`[source] <../../../litGL/glsl_bitmap.py>` Author: 2020-2021 Nicola Creati Copyright: 2020-2021 Nicola Creati <ncreati@inogs.it> License: MIT/X11 License (see :download:`license.txt <../../../license.txt>`) "...
""" GLSL shader code to render bitmap glyphs. :download:`[source] <../../../litGL/glsl_bitmap.py>` Author: 2020-2021 Nicola Creati Copyright: 2020-2021 Nicola Creati <ncreati@inogs.it> License: MIT/X11 License (see :download:`license.txt <../../../license.txt>`) """...
# Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: def oddEvenList(self, head): """ :type head: ListNode :rtype: ListNode """ if head is None or head.next is None: return ...
class Listnode: def __init__(self, x): self.val = x self.next = None class Solution: def odd_even_list(self, head): """ :type head: ListNode :rtype: ListNode """ if head is None or head.next is None: return head odd = head ev...
class BraviaProtocol: # def __init__(): # def makeQuery(self, parameters): # queries = []; # while parameters: # if parameters[0] in self.protocol.keys(): # queries.append(self.protocol[parameters[0]] + "?") # parameters = parameters[1:] # retu...
class Braviaprotocol: def parse_events(self, events): has_changed = True return has_changed
class Value(): def __init__(self): self._value = None def __set__(self, obj, value): self._value = value def __get__(self, obj, obj_type): return self._value - obj.commission * self._value
class Value: def __init__(self): self._value = None def __set__(self, obj, value): self._value = value def __get__(self, obj, obj_type): return self._value - obj.commission * self._value
# Given nums = [2, 7, 11, 15], target = 9, # Because nums[0] + nums[1] = 2 + 7 = 9, # return [0, 1]. # brute force - time complexity O(n^2) def two_sum(list, target): for f_index, f_value in enumerate(list): for s_index, s_value in enumerate(list[f_index+1:]): if (f_value + s_value) == target:...
def two_sum(list, target): for (f_index, f_value) in enumerate(list): for (s_index, s_value) in enumerate(list[f_index + 1:]): if f_value + s_value == target: return [f_index, list.index(s_value)] return None
SECRET_KEY = 'XXX' DEBUG=False # API-specific API_500PX_KEY = 'XXX' API_500PX_SECRET = 'XXX' API_RIJKS = 'XXX' FLICKR_KEY = 'XXX' FLICKR_SECRET = 'XXX' # Database-specific SQLALCHEMY_DATABASE_URI = 'postgresql://{}:{}@{}:{}/{}'.format('cctest', 'cctest', ...
secret_key = 'XXX' debug = False api_500_px_key = 'XXX' api_500_px_secret = 'XXX' api_rijks = 'XXX' flickr_key = 'XXX' flickr_secret = 'XXX' sqlalchemy_database_uri = 'postgresql://{}:{}@{}:{}/{}'.format('cctest', 'cctest', 'localhost', '5432', 'openledgertest') sqlalchemy_track_modifications = False debug_tb_enabled =...
#!/usr/bin/env python3 """Project Euler - Problem 17 Module""" def problem17(limit): """Problem 17 - Number letter counts""" # store known results result = 0 for x in range(1, limit+1): wl = 0 # thousends t = int(x/THOUSAND) if t > 0: wl += len(LANGUAGE_DICT...
"""Project Euler - Problem 17 Module""" def problem17(limit): """Problem 17 - Number letter counts""" result = 0 for x in range(1, limit + 1): wl = 0 t = int(x / THOUSAND) if t > 0: wl += len(LANGUAGE_DICT[t]) + len(LANGUAGE_DICT[THOUSAND]) h = int(x % THOUSAND /...
_runs_on_key = "runs-on" def execute(obj: dict) -> None: default_runner = obj.get(_runs_on_key) if not default_runner: return for job in obj.get("jobs", {}).values(): if _runs_on_key not in job: job[_runs_on_key] = default_runner # Clean up the left-overs obj.pop(_run...
_runs_on_key = 'runs-on' def execute(obj: dict) -> None: default_runner = obj.get(_runs_on_key) if not default_runner: return for job in obj.get('jobs', {}).values(): if _runs_on_key not in job: job[_runs_on_key] = default_runner obj.pop(_runs_on_key)
class SisCheckpointSubstage(basestring): """ sis checkpoint sub-stage Possible values: <ul> <li> "Sort_pass2" - Sorting the fingerprints for deduplication </ul> """ @staticmethod def get_api_name(): return "sis-checkpoint-substage"
class Sischeckpointsubstage(basestring): """ sis checkpoint sub-stage Possible values: <ul> <li> "Sort_pass2" - Sorting the fingerprints for deduplication </ul> """ @staticmethod def get_api_name(): return 'sis-checkpoint-substage'
# **args def save_user(**user): print(user['name']) #**user retorna um dict save_user(id=1, name='admin')
def save_user(**user): print(user['name']) save_user(id=1, name='admin')
class Service(object): class Version(object): def __init__(self, number, created_at, updated_at, deleted_at): self.number = number self.created_at = created_at self.updated_at = updated_at self.deleted_at = deleted_at def __init__(self, id, name, versi...
class Service(object): class Version(object): def __init__(self, number, created_at, updated_at, deleted_at): self.number = number self.created_at = created_at self.updated_at = updated_at self.deleted_at = deleted_at def __init__(self, id, name, versio...
# keys TabbinPoint OFFSET_DX = 'OFFSET_DX' # DOUBLE OFFSET_DY = 'OFFSET_DY' # DOUBLE OFFSET_DZ = 'OFFSET_DZ' ...
offset_dx = 'OFFSET_DX' offset_dy = 'OFFSET_DY' offset_dz = 'OFFSET_DZ' offset_dlength = 'OFFSET_DLENGTH' offset_lintensity = 'OFFSET_LINTENSITY' offset_ifilter_obsolete = 'OFFSET_IFILTER_OBSOLETE' offset_isymsetting_obsolete = 'OFFSET_ISYMSETTING_OBSOLETE' offset_iswsmode_obsolete = 'OFFSET_ISWSMODE_OBSOLETE' offset_i...
# -*- coding: utf-8 -*- """ TSPL - TimScriptProgrammingLanguage A simple programming language and interpreter in python - more of a learning device than a practical use language Created on Sat May 9 20:24:51 2020 @author: tim_s """ class Exp: """ An expression to be evaluated can put default...
""" TSPL - TimScriptProgrammingLanguage A simple programming language and interpreter in python - more of a learning device than a practical use language Created on Sat May 9 20:24:51 2020 @author: tim_s """ class Exp: """ An expression to be evaluated can put default behaviour here ""...
# Tests Python 3.5+'s ops # BINARY_MATRIX_MULTIPLY and INPLACE_MATRIX_MULTIPLY # code taken from pycdc tests/35_matrix_mult_oper.pyc.src m = [1, 2] @ [3, 4] m @= [5, 6]
m = [1, 2] @ [3, 4] m @= [5, 6]
apple=map(int,input().split()) high=int(input())+30 sum=0 for i in apple: if i<=high:sum+=1 print(sum)
apple = map(int, input().split()) high = int(input()) + 30 sum = 0 for i in apple: if i <= high: sum += 1 print(sum)
TEST = """initial state: #..#.#..##......###...### ...## => # ..#.. => # .#... => # .#.#. => # .#.## => # .##.. => # .#### => # #.#.# => # #.### => # ##.#. => # ##.## => # ###.. => # ###.# => # ####. => # """.splitlines() def read_lines(): with open('input.txt', 'r') as f: return [l.strip() for l in f.re...
test = 'initial state: #..#.#..##......###...###\n\n...## => #\n..#.. => #\n.#... => #\n.#.#. => #\n.#.## => #\n.##.. => #\n.#### => #\n#.#.# => #\n#.### => #\n##.#. => #\n##.## => #\n###.. => #\n###.# => #\n####. => #\n'.splitlines() def read_lines(): with open('input.txt', 'r') as f: return [l.strip() fo...
# -*- coding: utf-8 -*- SYSTEM = "O" USER = "I" TYPE_CHAT = ( (SYSTEM, u'Gozokia'), (USER, u'User'), )
system = 'O' user = 'I' type_chat = ((SYSTEM, u'Gozokia'), (USER, u'User'))
class FluidSettings: type = None
class Fluidsettings: type = None
class AtbashCipher: def encrypt(self, string): lst = [] for elem in string.lower(): if elem.isalpha(): lst+=chr(219-ord(elem)) else: lst+=[elem] return ''.join(lst).lower() def decrypt(self, string): return self.encrypt(str...
class Atbashcipher: def encrypt(self, string): lst = [] for elem in string.lower(): if elem.isalpha(): lst += chr(219 - ord(elem)) else: lst += [elem] return ''.join(lst).lower() def decrypt(self, string): return self.encr...
def forward(t): t.penup() t.forward(3) def no_draw_forward(t): t.pendown() t.forward(3) axiom = 'A' n = 5 subs = { 'A': 'ABA', 'B': 'BBB' } graphics = { 'A': lambda t: forward(t), 'B': lambda t: no_draw_forward(t) }
def forward(t): t.penup() t.forward(3) def no_draw_forward(t): t.pendown() t.forward(3) axiom = 'A' n = 5 subs = {'A': 'ABA', 'B': 'BBB'} graphics = {'A': lambda t: forward(t), 'B': lambda t: no_draw_forward(t)}