content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
#!/usr/bin/env python3 # -*- coding: utf-8 -*- def anything_to_string(input_data): if isinstance(input_data, str): return input_data elif isinstance(input_data, bytes): # return input_data.decode('utf-8', 'ignore') return input_data.decode('utf-8') elif isinstance(input_data, int):...
def anything_to_string(input_data): if isinstance(input_data, str): return input_data elif isinstance(input_data, bytes): return input_data.decode('utf-8') elif isinstance(input_data, int): return str(input_data) else: return input_data.__str__() def anything_to_bytes(in...
# Find the factorial of a given number def factorial(n): return 1 if (n == 1 or n == 0) else n * factorial(n - 1) factorial(5) # 120 factorial(11) # 39916800
def factorial(n): return 1 if n == 1 or n == 0 else n * factorial(n - 1) factorial(5) factorial(11)
#The hailstone sequence starting at a positive integer n. Is generated by following two simple rules: # (1) If n even, the next number in the sequence is n/ 2. # (2) If n is odd, the next number in the sequence is 3*n+1 # A recursive function hailstone (n) Which prints the hailstone sequence beginning at 1. Stop when...
def generate_hailstone_using_recursion(n): if n == 1: return 1 elif n % 2 == 0: print(int(n), end=',') return generate_hailstone_using_recursion(n / 2) else: print(int(n), end=',') return generate_hailstone_using_recursion(3 * n + 1) print('Enter a number to generate ...
class FoxAndClassroom: def ableTo(self, n, m): s, i, j = set(), 0, 0 while (i, j) not in s: s.add((i, j)) i, j = (i + 1) % n, (j + 1) % m return "Possible" if len(s) == n * m else "Impossible"
class Foxandclassroom: def able_to(self, n, m): (s, i, j) = (set(), 0, 0) while (i, j) not in s: s.add((i, j)) (i, j) = ((i + 1) % n, (j + 1) % m) return 'Possible' if len(s) == n * m else 'Impossible'
class Node: def __init__(self, val): self.val = val self.l = None self.r = None def __repr__(self): return "{}=[l={}, r={}]".format(self.val, self.l, self.r) def get_hbal_tree(arr): if not arr: return None mid = len(arr) // 2 node = Node(arr[mid]) node...
class Node: def __init__(self, val): self.val = val self.l = None self.r = None def __repr__(self): return '{}=[l={}, r={}]'.format(self.val, self.l, self.r) def get_hbal_tree(arr): if not arr: return None mid = len(arr) // 2 node = node(arr[mid]) node....
option_numbers = 5 factors_names = ('raw') reverse_scoring_numbers =(1,3,8,10,11) factors_interpretation = { (16,32) :'mild' , (33,48):'moderate' , (49,1000):'severe' }
option_numbers = 5 factors_names = 'raw' reverse_scoring_numbers = (1, 3, 8, 10, 11) factors_interpretation = {(16, 32): 'mild', (33, 48): 'moderate', (49, 1000): 'severe'}
# dependencies_map.py # # Map of GitHub project names to clone target paths, relative to the GPUPerfAPI # project root on the local disk. # This script is used by the UpdateCommon.py script # GitHub GPUOpen-Tools projects map # Define a set of dependencies that exist as separate git projects. The parameters a...
git_mapping = {'common-lib-amd-ADL': ['../Common/Lib/AMD/ADL', None], 'common-lib-amd-APPSDK-3.0': ['../Common/Lib/AMD/APPSDK', None], 'common-lib-ext-OpenGL': ['../Common/Lib/Ext/OpenGL', None], 'common-lib-ext-WindowsKits': ['../Common/Lib/Ext/Windows-Kits', None], 'googletest': ['../Common/Lib/Ext/GoogleTest', 'v1.8...
data = [ { 'var': 'total', 'exp': {'var': 'registration.donation'}, }, ]
data = [{'var': 'total', 'exp': {'var': 'registration.donation'}}]
config = { 'account': '618537831167', 'region': 'us-west-1', }
config = {'account': '618537831167', 'region': 'us-west-1'}
#!/usr/bin/env python ''' Copyright (C) 2019, WAFW00F Developers. See the LICENSE file for copying permission. ''' NAME = 'Approach (Approach)' def is_waf(self): schemes = [ # This method of detection is old (though most reliable), so we check it first self.matchContent(r'approach.{0,10}?web appl...
""" Copyright (C) 2019, WAFW00F Developers. See the LICENSE file for copying permission. """ name = 'Approach (Approach)' def is_waf(self): schemes = [self.matchContent('approach.{0,10}?web application (firewall|filtering)'), self.matchContent('approach.{0,10}?infrastructure team')] if any((i for i in schemes)...
''' These sub-modules were created to support the calibration of specific L4C model variants (which are also implemented in the corresponding sub-module for forward-run simulations, `pyl4c.apps.l4c.extensions`). '''
""" These sub-modules were created to support the calibration of specific L4C model variants (which are also implemented in the corresponding sub-module for forward-run simulations, `pyl4c.apps.l4c.extensions`). """
# Derived from https://github.com/nightrome/cocostuff/blob/master/labels.md # Labels start from 0:person, and removed labels are backfilled label_map = { 0: 'person', 1: 'bicycle', 2: 'car', 3: 'motorcycle', 4: 'airplane', 5: 'bus', 6: 'train', 7: 'truck', 8:'boat', 9:...
label_map = {0: 'person', 1: 'bicycle', 2: 'car', 3: 'motorcycle', 4: 'airplane', 5: 'bus', 6: 'train', 7: 'truck', 8: 'boat', 9: 'traffic light', 10: 'fire hydrant', 11: 'stop sign', 12: 'parking meter', 13: 'bench', 14: 'bird', 15: 'cat', 16: 'dog', 17: 'horse', 18: 'sheep', 19: 'cow', 20: 'elephant', 21: 'bear', 22:...
pkgname = "cups-pk-helper" pkgver = "0.2.6_git20210504" # using git because last release was years ago and needs intltool _commit = "151fbac90f62f959ccc648d4f73ca6aafc8f8e6a" pkgrel = 0 build_style = "meson" hostmakedepends = ["meson", "pkgconf", "glib-devel", "gettext-tiny"] makedepends = ["libglib-devel", "cups-devel...
pkgname = 'cups-pk-helper' pkgver = '0.2.6_git20210504' _commit = '151fbac90f62f959ccc648d4f73ca6aafc8f8e6a' pkgrel = 0 build_style = 'meson' hostmakedepends = ['meson', 'pkgconf', 'glib-devel', 'gettext-tiny'] makedepends = ['libglib-devel', 'cups-devel', 'polkit-devel'] pkgdesc = 'PolicyKit helper to configure CUPS w...
# operators description # == if the values of two operands are equal, then the condition become true # != if values of two operands are not equal, then the condition become true # > if the value of left operand is greater than the value of right operand, then the condition is true ...
print(1 == 1) print(1 != 1) print(1 != 10) print(5 > 3) print(6 > 9) print(4 < 7) print(6 < 5) print(4 >= 4) print(6 >= 8) print(3 <= 3) print(3 <= 2)
words = ['one', 'fish', 'two', 'fish', 'red', 'fish', 'blue', 'fish'] word_lengths = list(map(len, words)) comp_word_lengths = [len(word) for word in words] print(word_lengths) print(comp_word_lengths)
words = ['one', 'fish', 'two', 'fish', 'red', 'fish', 'blue', 'fish'] word_lengths = list(map(len, words)) comp_word_lengths = [len(word) for word in words] print(word_lengths) print(comp_word_lengths)
filename = 'programming.txt' with open(filename, 'w') as file_object: file_object.write("I love python programming.\n") file_object.write("I love creating games.\n") with open(filename, 'a') as file_object: file_object.write("I also like analyzing large data sets.\n")
filename = 'programming.txt' with open(filename, 'w') as file_object: file_object.write('I love python programming.\n') file_object.write('I love creating games.\n') with open(filename, 'a') as file_object: file_object.write('I also like analyzing large data sets.\n')
doc = open("./doctor.csv", "r") #hosp = open("./hospital.csv", "r") xml_doc = open("./doctor_final.xml", "w") #xml_hosp = open("./hospital_mini.xml", "w") # def find_ind(lista, name): # for x in range(len(lista)): # if lista[x] == name: # return x doc2 = doc.read().splitlines()...
doc = open('./doctor.csv', 'r') xml_doc = open('./doctor_final.xml', 'w') doc2 = doc.read().splitlines() doc3 = [] for x in doc2: doc3.append(x.split(',')) ind_npi = doc3[0].index('NPI') ind_first_name = doc3[0].index('First Name') ind_middle_name = doc3[0].index('Middle Name') ind_last_name = doc3[0].index('Last N...
#script to print first N odd natural no.s in reverse order print("enter the value of n") n=int(input()) i=1 while(i<=2*n-1): print(2*n-i) i+=2
print('enter the value of n') n = int(input()) i = 1 while i <= 2 * n - 1: print(2 * n - i) i += 2
HEIGHT = 600 WIDTH = 600 LINE_WIDTH = 10 GRID = 4 # NxN Grid COLORS = { 'background': (200, 200, 200), 'line': (0, 0, 0), 'red': (255, 0, 0), 'dark_red': (150, 0, 0), 'blue': (0, 0, 255), 'dark_blue': (0, 0, 150), 'gray': (100, 100, 100) }
height = 600 width = 600 line_width = 10 grid = 4 colors = {'background': (200, 200, 200), 'line': (0, 0, 0), 'red': (255, 0, 0), 'dark_red': (150, 0, 0), 'blue': (0, 0, 255), 'dark_blue': (0, 0, 150), 'gray': (100, 100, 100)}
def count_trees(): pos = 0 trees = 0 for line in open('3/input.txt'): if line[pos] == "#": trees += 1 pos = (pos + 3) % len(line.rstrip()) return trees print(count_trees())
def count_trees(): pos = 0 trees = 0 for line in open('3/input.txt'): if line[pos] == '#': trees += 1 pos = (pos + 3) % len(line.rstrip()) return trees print(count_trees())
class Solution: def numDistinct(self, s: str, t: str) -> int: N, M = len(t), len(s) dp = [[0] * (M + 1) for _ in range(N + 1)] for i in range(N + 1): dp[i][ 0] = 0 # Number of subsequences of zero length S can be formed which equal t[0:i] for j in range(...
class Solution: def num_distinct(self, s: str, t: str) -> int: (n, m) = (len(t), len(s)) dp = [[0] * (M + 1) for _ in range(N + 1)] for i in range(N + 1): dp[i][0] = 0 for j in range(M + 1): dp[0][j] = 1 for i in range(1, N + 1): for j in ...
#!/bin/bash/ env python3 ### Should be #!/usr/bin/env python3 def compute_sum(tol): k = 1 conv_sum = 0 term = (1/k**2) while tol < term: term = (1/k**2) conv_sum += term k += 1 return conv_sum ### This return breaks the while loop immediately ...
def compute_sum(tol): k = 1 conv_sum = 0 term = 1 / k ** 2 while tol < term: term = 1 / k ** 2 conv_sum += term k += 1 return conv_sum if __name__ == '__main__': convergence = compute_sum(tol=0.01) print('If tol is 1e-2, sum converges at', convergence) smaller...
def getNextIndex(str, command): i = 0 while i < len(str): if str[i] == command: return i + 1 i += 1 return None def getNextValue(str, command, default): i = 0 while i < len(str): if str[i] == command: return str[i + 1] i += 1 return de...
def get_next_index(str, command): i = 0 while i < len(str): if str[i] == command: return i + 1 i += 1 return None def get_next_value(str, command, default): i = 0 while i < len(str): if str[i] == command: return str[i + 1] i += 1 return de...
# # PySNMP MIB module VERILINK-ENTERPRISE-NCMGENERIC-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/VERILINK-ENTERPRISE-NCMGENERIC-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 21:26:48 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using...
(octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_size_constraint, single_value_constraint, constraints_intersection, constraints_union, value_range_constraint) ...
# Maximum Pairwise Product # Author: jerrybelmonte # Input: First line contains an integer n. # Second line contains n non-negative integers separated by spaces. # Output: Integer of the maximum pairwise product. def maximum_pairwise_product(numbers): # sorting in descending order is O(n*logn) numbers.sort(r...
def maximum_pairwise_product(numbers): numbers.sort(reverse=True) return numbers[0] * numbers[1] if __name__ == '__main__': input_n = int(input()) input_numbers = [int(num) for num in input().split()] print(maximum_pairwise_product(input_numbers))
# https://www.codewars.com/kata/55f2b110f61eb01779000053/train/python def get_sum(a,b): sum=0 higher=b if b>a else a lower=a if b>a else b while lower<=higher: sum+=lower lower+=1 return sum print(get_sum(-1,2))
def get_sum(a, b): sum = 0 higher = b if b > a else a lower = a if b > a else b while lower <= higher: sum += lower lower += 1 return sum print(get_sum(-1, 2))
{ "targets": [{ "target_name": "registry-changes-detector", "sources": [ 'addon.cpp' ], 'include_dirs': [ "<!@(node -p \"require('node-addon-api').include\")", "<!@(node -p \"var a = require('node-addon-api').include; var b = a.substr(0, a.length ...
{'targets': [{'target_name': 'registry-changes-detector', 'sources': ['addon.cpp'], 'include_dirs': ['<!@(node -p "require(\'node-addon-api\').include")', '<!@(node -p "var a = require(\'node-addon-api\').include; var b = a.substr(0, a.length - 15); b + \'event-source-base\' + a[a.length-1]")'], 'dependencies': ['<!(no...
#https://docs.python.org/3.4/library/string.html #Refer to Format Specification Mini-Language section to understand class Solution: def hammingDistance(self, x: int, y: int) -> int: a = bin(x) b = bin(y) a = "{:0>33}".format(a[2:]) b = "{:0>33}".format(b[2:]) ...
class Solution: def hamming_distance(self, x: int, y: int) -> int: a = bin(x) b = bin(y) a = '{:0>33}'.format(a[2:]) b = '{:0>33}'.format(b[2:]) ham = 0 for i in range(len(a)): if a[i] != b[i]: ham += 1 return ham
class BinaryTree: '''A simple binary tree. ''' def __init__(self, root, left=None, right=None): '''Construct a binary tree. Arguments: root (str or int): The value of the root node. left (BinaryTree or None): The left subtree. right (BinaryTree or None):...
class Binarytree: """A simple binary tree. """ def __init__(self, root, left=None, right=None): """Construct a binary tree. Arguments: root (str or int): The value of the root node. left (BinaryTree or None): The left subtree. right (BinaryTree or None):...
def grade(input_data, quality_data, submission): score = 0.0 scoreUB = 1.0 feedback = '' lines = input_data.split('\n') first_line = lines[0].split(); items = int(first_line[0]); capacity = int(first_line[1]); values = [] weights = [] for i in range(1,items+1): line =...
def grade(input_data, quality_data, submission): score = 0.0 score_ub = 1.0 feedback = '' lines = input_data.split('\n') first_line = lines[0].split() items = int(first_line[0]) capacity = int(first_line[1]) values = [] weights = [] for i in range(1, items + 1): line = li...
# address configuration for running test LOCAL_IF="igb0" LOCAL_ADDR6="2001:630:42:110:ae1f:6bff:fe46:9eda" LOCAL_MAC="ac:1f:6b:46:9e:da" REMOTE_ADDR6="2001:630:42:110:2a0:98ff:fe15:ece7" REMOTE_MAC="00:a0:98:15:ec:e7"
local_if = 'igb0' local_addr6 = '2001:630:42:110:ae1f:6bff:fe46:9eda' local_mac = 'ac:1f:6b:46:9e:da' remote_addr6 = '2001:630:42:110:2a0:98ff:fe15:ece7' remote_mac = '00:a0:98:15:ec:e7'
print(f'Enter a number and I will let you know if it is an even or odd number') a = int(input()) print(a) while a != 0: if a % 2 == 0: print(f'The number {a} is an even number') else: print(f'The number {a} is an odd number') print(f'please re-enter a new nonzero number or enter 0 if you wa...
print(f'Enter a number and I will let you know if it is an even or odd number') a = int(input()) print(a) while a != 0: if a % 2 == 0: print(f'The number {a} is an even number') else: print(f'The number {a} is an odd number') print(f'please re-enter a new nonzero number or enter 0 if you wan...
class Solution: def checkRecord(self, n: int) -> int: dp00 = dp01 = dp10 = 1 dp11 = dp02 = dp12 = 0 for i in range(n): dp00, dp01, dp02 = (dp00 + dp01 + dp02) % (10 ** 9 + 7), dp00, dp01 dp10, dp11, dp12 = (dp00 + dp10 + dp11 + dp12) % (10 ** 9 + 7), dp10, dp11 ...
class Solution: def check_record(self, n: int) -> int: dp00 = dp01 = dp10 = 1 dp11 = dp02 = dp12 = 0 for i in range(n): (dp00, dp01, dp02) = ((dp00 + dp01 + dp02) % (10 ** 9 + 7), dp00, dp01) (dp10, dp11, dp12) = ((dp00 + dp10 + dp11 + dp12) % (10 ** 9 + 7), dp10, dp...
# -*- coding: utf-8 -*- # Copyright 2015 Donne Martin. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"). You # may not use this file except in compliance with the License. A copy of # the License is located at # # http://www.apache.org/licenses/LICENSE-2.0 # # or in the "lice...
formatted_gitignores = u'\x1b[35m 1. \x1b[0mActionscript \x1b[0m\n\x1b[35m 2. \x1b[0mAda \x1b[0m\n\x1b[35m 3. \x1b[0mAgda \x1b[0m\n\x1b[35m 4. \x1b[0mAndroid \x1b[0m\n\x1b[35m 5. \x1b[0mAppEngine \x1b[0m\n\x1b[0m' formatted_gitignores_tip = u' Run the following command to view or download a .gitignore f...
#formatter class formatter: def format(self, message, synonym): return message.format(**synonym.getForFormatting())
class Formatter: def format(self, message, synonym): return message.format(**synonym.getForFormatting())
class Solution: def findContentChildren(self, g: 'List[int]', s: 'List[int]') -> 'int': g.sort() s.sort() i = j = 0 while i < len(g) and j < len(s): if s[j] >= g[i]: i += 1 j += 1 return i
class Solution: def find_content_children(self, g: 'List[int]', s: 'List[int]') -> 'int': g.sort() s.sort() i = j = 0 while i < len(g) and j < len(s): if s[j] >= g[i]: i += 1 j += 1 return i
class Parcel: pass class DBParcelBuilder: query_obj = None class ImageDBModel: name = None description = None image_url = None thumb_url = None dimensions = None tags = None class WebImageParcel(ImageDBModel): source_id = None source_url = None width = None height =...
class Parcel: pass class Dbparcelbuilder: query_obj = None class Imagedbmodel: name = None description = None image_url = None thumb_url = None dimensions = None tags = None class Webimageparcel(ImageDBModel): source_id = None source_url = None width = None height = No...
#!/usr/bin/env python3 challenge = '((((()(()(((((((()))(((()((((()())(())()(((()((((((()((()(()(((()(()((())))()((()()())))))))))()((((((())((()))(((((()(((((((((()()))((()(())()((())((()(()))((()))()))()(((((()(((()()))()())((()((((())()())()((((())()(()(()(((()(())(()(())(((((((())()()(((())(()(()(()(())))(()((((()...
challenge = '((((()(()(((((((()))(((()((((()())(())()(((()((((((()((()(()(((()(()((())))()((()()())))))))))()((((((())((()))(((((()(((((((((()()))((()(())()((())((()(()))((()))()))()(((((()(((()()))()())((()((((())()())()((((())()(()(()(((()(())(()(())(((((((())()()(((())(()(()(()(())))(()((((())((()))(((()(()()(((((()...
class Objective(object): def __init__(self, hparams): super(Objective, self).__init__() self.hparams = hparams def task_error(self, w, x, y): raise NotImplementedError def oracle(w, x, y): raise NotImplementedError
class Objective(object): def __init__(self, hparams): super(Objective, self).__init__() self.hparams = hparams def task_error(self, w, x, y): raise NotImplementedError def oracle(w, x, y): raise NotImplementedError
# -*- coding: utf-8 -*- LUMIA_925 = { 'mode': 'RGBA', 'header_height': 232, 'footer_height': 116, 'additional_message_gap': 2, 'reply_message_gap': 7 }
lumia_925 = {'mode': 'RGBA', 'header_height': 232, 'footer_height': 116, 'additional_message_gap': 2, 'reply_message_gap': 7}
#proper way to create a class and object class Parrot: #define attributes species = 'bird' #instance_attribute def __init__(self, name, age): self.name = name self.age = age #instantiate the parrot class blu = Parrot('Blu',10) woo = Parrot('woo',15) #access the class attributes prin...
class Parrot: species = 'bird' def __init__(self, name, age): self.name = name self.age = age blu = parrot('Blu', 10) woo = parrot('woo', 15) print('Blu is a {}'.format(blu.species)) print('woo is a {}'.format(woo.species)) print('{} is {} years old '.format(blu.name, blu.age)) print('{} is {} ...
message = "hello python world!" print(message) message = "hello world!" print(message)
message = 'hello python world!' print(message) message = 'hello world!' print(message)
__title__ = "dj-rest-auth-social" __description__ = "Authentication and Registration in Django Rest Framework." __url__ = "https://github.com/robertwt7/dj-rest-auth-social" __version__ = "2.2.4" __author__ = "@robertwt7 https://github.com/robertwt7" __author_email__ = "robert@sharkware.org" __license__ = "MIT" __copyri...
__title__ = 'dj-rest-auth-social' __description__ = 'Authentication and Registration in Django Rest Framework.' __url__ = 'https://github.com/robertwt7/dj-rest-auth-social' __version__ = '2.2.4' __author__ = '@robertwt7 https://github.com/robertwt7' __author_email__ = 'robert@sharkware.org' __license__ = 'MIT' __copyri...
def isInt(n): return int(n) == float(n) def bin_pow(num, p): if p == 0: return 1 if p % 2: return num * bin_pow(num, p - 1) else: b = bin_pow(num, p // 2) return b * b num = float(input()) p = int(input()) ans = bin_pow(num, p) print(ans)
def is_int(n): return int(n) == float(n) def bin_pow(num, p): if p == 0: return 1 if p % 2: return num * bin_pow(num, p - 1) else: b = bin_pow(num, p // 2) return b * b num = float(input()) p = int(input()) ans = bin_pow(num, p) print(ans)
def revertNumber(n): result = 0 while n != 0: result = (result * 10) + (n % 10) n = n // 10 else: return result def main(): n = int(input('Enter a integer number: ')) result = revertNumber(n) print(result) if __name__ == "__main__": main()
def revert_number(n): result = 0 while n != 0: result = result * 10 + n % 10 n = n // 10 else: return result def main(): n = int(input('Enter a integer number: ')) result = revert_number(n) print(result) if __name__ == '__main__': main()
class BaseModel(object): def __init__(self): pass def build_inputs(self): raise NotImplementedError def build_inference(self): raise NotImplementedError def build_loss(self): raise NotImplementedError def build_solver(self): raise NotImplementedError ...
class Basemodel(object): def __init__(self): pass def build_inputs(self): raise NotImplementedError def build_inference(self): raise NotImplementedError def build_loss(self): raise NotImplementedError def build_solver(self): raise NotImplementedError ...
pos = { 'I': 0.09, 'always': 0.07, 'like': 0.29, 'foreign': 0.04, 'films': 0.08 } neg = { 'I': 0.16, 'always': 0.06, 'like': 0.06, 'foreign': 0.15, 'films': 0.11 } prior_pos = 0.4 prior_neg = 0.6 sentence = 'I always like foreign films' pos_pro = prior_pos neg_pro = prior_neg...
pos = {'I': 0.09, 'always': 0.07, 'like': 0.29, 'foreign': 0.04, 'films': 0.08} neg = {'I': 0.16, 'always': 0.06, 'like': 0.06, 'foreign': 0.15, 'films': 0.11} prior_pos = 0.4 prior_neg = 0.6 sentence = 'I always like foreign films' pos_pro = prior_pos neg_pro = prior_neg for word in sentence.split(): pos_pro *= po...
coordinator_a = int(input()) coordinator_b = int(input()) if 1 < coordinator_a < 8 and 1 < coordinator_b < 8: print('8') elif (coordinator_a == 1 and coordinator_b == 1) or (coordinator_a == 8 and coordinator_b == 8): print('3') elif (coordinator_a == 1 and coordinator_b == 8) or (coordinator_a == 8 and coordi...
coordinator_a = int(input()) coordinator_b = int(input()) if 1 < coordinator_a < 8 and 1 < coordinator_b < 8: print('8') elif coordinator_a == 1 and coordinator_b == 1 or (coordinator_a == 8 and coordinator_b == 8): print('3') elif coordinator_a == 1 and coordinator_b == 8 or (coordinator_a == 8 and coordinator...
double = "She said, \"that's a greate tasting apple!\"" print (double) single = 'she said, "that\'s a great tasting apple!"' print (single) print (' i ' + 'eat ' + 'you') #concatenation first = "I" second = "EAT" third = "python" sentence = first + ' ' + second +' ' + third print(sentence) print ('-' * 50) # ha...
double = 'She said, "that\'s a greate tasting apple!"' print(double) single = 'she said, "that\'s a great tasting apple!"' print(single) print(' i ' + 'eat ' + 'you') first = 'I' second = 'EAT' third = 'python' sentence = first + ' ' + second + ' ' + third print(sentence) print('-' * 50) happines = 'happy ' * 3 print(h...
file_read = open("input.txt", "r") line = file_read.readline() freq = 0 while line: number = int(line[1:]) if line[0] == '-': freq -= int(number) else: freq += int(number) line = file_read.readline() print(f'Current freq = {freq}')
file_read = open('input.txt', 'r') line = file_read.readline() freq = 0 while line: number = int(line[1:]) if line[0] == '-': freq -= int(number) else: freq += int(number) line = file_read.readline() print(f'Current freq = {freq}')
def part1(image): return image def part2(lines): return 0 if __name__ == '__main__': with open('input.txt', 'r') as f: image = f.read().splitlines() print(part1(image)) print(part2(image))
def part1(image): return image def part2(lines): return 0 if __name__ == '__main__': with open('input.txt', 'r') as f: image = f.read().splitlines() print(part1(image)) print(part2(image))
code = "set" answer = "" for index in range(1, 3): answer = answer + code[index] + "ab" print(answer)
code = 'set' answer = '' for index in range(1, 3): answer = answer + code[index] + 'ab' print(answer)
text = input() arr = text.split() last_list =[] for i in range(0,len(arr)): if (i%2 ==0): last_list.append(arr[i]) print(*last_list)
text = input() arr = text.split() last_list = [] for i in range(0, len(arr)): if i % 2 == 0: last_list.append(arr[i]) print(*last_list)
class Spaceship: SPACESHIP_FULL = "Spaceship is full" ASTRONAUT_EXISTS = "Astronaut {} Exists" ASTRONAUT_NOT_FOUND = "Astronaut Not Found" ASTRONAUT_ADD = "Added astronaut {}" ASTRONAUT_REMOVED = "Removed {}" ZERO_CAPACITY = 0 def __init__(self, name: str, capacity: int): self.name ...
class Spaceship: spaceship_full = 'Spaceship is full' astronaut_exists = 'Astronaut {} Exists' astronaut_not_found = 'Astronaut Not Found' astronaut_add = 'Added astronaut {}' astronaut_removed = 'Removed {}' zero_capacity = 0 def __init__(self, name: str, capacity: int): self.name ...
first_value = ' FIRST challenge ' second_value = '- second challenge -' third_value = 'tH IR D-C HALLE NGE' fourth_value = 'fourth' fifth_value = 'fifth' sixth_value = 'sixth' # First challenge first_value = ' ' + (first_value.strip()).title() # Second challenge second_value = ((second_value.replace...
first_value = ' FIRST challenge ' second_value = '- second challenge -' third_value = 'tH IR D-C HALLE NGE' fourth_value = 'fourth' fifth_value = 'fifth' sixth_value = 'sixth' first_value = ' ' + first_value.strip().title() second_value = second_value.replace('-', ' ').strip().capitalize() third_value ...
# --- Day 15: Rambunctious Recitation --- # You catch the airport shuttle and try to book a new flight to your vacation island. Due to the storm, all direct flights have been cancelled, but a route is available to get around the storm. You take it. # # While you wait for your flight, you decide to check in with the Elv...
data = {18: [1], 8: [2], 0: [3], 5: [4], 4: [5], 1: [6], 20: [7]} spoken = 20 for turn in range(8, 30000001): if len(data[spoken]) < 2: spoken = 0 if 0 not in data: data[0] = [turn] else: data[0].append(turn) else: spoken = data[spoken][-1] - data[spoken][...
def jwt_response_payload_handler(token, user, request): return { "token": token, "user": str(user.username), "active": user.is_active }
def jwt_response_payload_handler(token, user, request): return {'token': token, 'user': str(user.username), 'active': user.is_active}
# Exemplary development configuration for a public site SECRET_KEY = b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' SESSION_COOKIE_SECURE = True SQLALCHEMY_DATABASE_URI = 'postgresql+psycopg2://byceps:boioioing@127.0.0.1/byceps' REDIS_URL = 'redis://127.0.0.1:6379...
secret_key = b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' session_cookie_secure = True sqlalchemy_database_uri = 'postgresql+psycopg2://byceps:boioioing@127.0.0.1/byceps' redis_url = 'redis://127.0.0.1:6379/0' app_mode = 'site' site_id = 'example-site' mail_debug =...
fname = input("Enter file name: ") ff=open(fname) for line in ff: line=line.rstrip() print(line.upper())
fname = input('Enter file name: ') ff = open(fname) for line in ff: line = line.rstrip() print(line.upper())
print ('hello world') print("Hello, CS1301") print("This is line 1") print("This is line 2") print("This is line 3") print("This is line 4") #pritn("This is line 5") #Line 9 will not run, as there is a function error. "pritn does not exist" #General errors in Python begin with "Traceback" #File "/Users/jstorey/github/...
print('hello world') print('Hello, CS1301') print('This is line 1') print('This is line 2') print('This is line 3') print('This is line 4')
class Solution: def maxSubArray(self, nums): for q in range(1, len(nums)): if nums[q - 1] > 0: nums[q] += nums[q - 1] return max(nums)
class Solution: def max_sub_array(self, nums): for q in range(1, len(nums)): if nums[q - 1] > 0: nums[q] += nums[q - 1] return max(nums)
# This helps pylint find all subcommands. __all__ = ["aws_batch_init", "aws_batch_submit", "init", \ "import_uhgg", "annotate_genome", "build_pangenome", \ "infer_markers", "build_markerdb", "generate_dbmisc", \ "midas_run_species", "midas_run_genes", "midas_run_snps", \ ...
__all__ = ['aws_batch_init', 'aws_batch_submit', 'init', 'import_uhgg', 'annotate_genome', 'build_pangenome', 'infer_markers', 'build_markerdb', 'generate_dbmisc', 'midas_run_species', 'midas_run_genes', 'midas_run_snps', 'midas_merge_species', 'midas_merge_snps', 'midas_merge_genes', 'build_bowtie2_indexes', 'download...
somadorA = 0 somadorB = 0 somadorC = 0 somadorD = 0 desnivel_A = 0 desnivel_B = 0 desnivel_C = 0 desnivel_D = 0 linhas, colunas = [int(z) for z in input().split()] matriz = [] for z in range(linhas): linha = [int(x) for x in input().split()] matriz.append(linha) lin, col = [int(z) for z in input().split()] to...
somador_a = 0 somador_b = 0 somador_c = 0 somador_d = 0 desnivel_a = 0 desnivel_b = 0 desnivel_c = 0 desnivel_d = 0 (linhas, colunas) = [int(z) for z in input().split()] matriz = [] for z in range(linhas): linha = [int(x) for x in input().split()] matriz.append(linha) (lin, col) = [int(z) for z in input().split...
# you can write to stdout for debugging purposes, e.g. # print("this is a debug message") def solution(S): # write your code in Python 3.6 if len(S) == 0: return 1 stack = [] for c in S: if c == '(': stack.append(c) elif c == ')': if len(stack) == 0: ...
def solution(S): if len(S) == 0: return 1 stack = [] for c in S: if c == '(': stack.append(c) elif c == ')': if len(stack) == 0: return 0 last_char = stack[-1] if last_char == '(': stack.pop() return ...
# Kenny Sprite Sheet Slicer # Error.py # Copyright Will Blankenship 2015 class Error(Exception): def __init__(self, message): self.message = message
class Error(Exception): def __init__(self, message): self.message = message
# Golden Nimbus Cloud Mount Permanent Coupon (2435372) mount = 80011350 if sm.hasSkill(mount): sm.chat("You already have the 'Golden Nimbus Cloud' mount.") else: sm.consumeItem() sm.giveSkill(mount) sm.chat("Successfully added the 'Golden Nimbus Cloud' mount.")
mount = 80011350 if sm.hasSkill(mount): sm.chat("You already have the 'Golden Nimbus Cloud' mount.") else: sm.consumeItem() sm.giveSkill(mount) sm.chat("Successfully added the 'Golden Nimbus Cloud' mount.")
# https://www.codewars.com/kata/530e15517bc88ac656000716/train/python def rot13(message): string = [] for letter in message: if(ord(letter) <= 122 and ord(letter) >= 65): letter = ord(letter) + 13 if(letter >= 110 and letter > 122 or letter < 110 and letter > 90): ...
def rot13(message): string = [] for letter in message: if ord(letter) <= 122 and ord(letter) >= 65: letter = ord(letter) + 13 if letter >= 110 and letter > 122 or (letter < 110 and letter > 90): letter -= 26 string.append(chr(letter)) else: ...
# Copyright 2019 The Jetstack cert-manager contributors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable l...
load('@io_k8s_repo_infra//defs:go.bzl', 'go_genrule') def generated_crds(name, go_prefix, paths, out, visibility=[], deps=[]): go_genrule(name=name, tools=['@io_k8s_sigs_controller_tools//cmd/controller-gen', '@go_sdk//:bin/go'], cmd=' '.join(['go=$$(pwd)/$(location @go_sdk//:bin/go);', 'export PATH=$$(dirname "$$...
# easy O(n) time and O(n?) space solution def solve(seq, stop): mem = {seq[i]: i+1 for i in range(len(seq)-1)} i = len(seq) cur = seq[-1] while i < stop: next_cur = 0 if cur in mem: next_cur = i - mem[cur] mem[cur] = i cur = next_cur i += 1 return cur if __name__ == '__main_...
def solve(seq, stop): mem = {seq[i]: i + 1 for i in range(len(seq) - 1)} i = len(seq) cur = seq[-1] while i < stop: next_cur = 0 if cur in mem: next_cur = i - mem[cur] mem[cur] = i cur = next_cur i += 1 return cur if __name__ == '__main__': seq...
def printMenu(): print("************************************") print("**EDTODO****************************") print("************************************") print("Seleccione una opcion") print("* 1. Agregar tarea") print("* 2. Editar tarea") print("* 3. Marcar como hecha") print("* 4 Borrar tarea...
def print_menu(): print('************************************') print('**EDTODO****************************') print('************************************') print('Seleccione una opcion') print('* 1. Agregar tarea') print('* 2. Editar tarea') print('* 3. Marcar como hecha') print('* 4 Bor...
class Solution: def superPow(self, a: int, b: List[int]) -> int: res = 1 for x in b: res = self.pow(res, 10) * self.pow(a, x) % 1337 return res def pow(self, a, b): if b == 0 or a == 1: return 1 if b % 2: return a * self.pow(a, b - 1) % 1337 ...
class Solution: def super_pow(self, a: int, b: List[int]) -> int: res = 1 for x in b: res = self.pow(res, 10) * self.pow(a, x) % 1337 return res def pow(self, a, b): if b == 0 or a == 1: return 1 if b % 2: return a * self.pow(a, b - 1...
class Solution: def shortestCompletingWord(self, licensePlate: str, words: List[str]) -> str: l=list(re.sub(r'\s|[0-9]+', '', licensePlate).lower()) #print(l) words=sorted(words, key=len) for i in words: i_l=list(i) #print(i_l) for k in l: ...
class Solution: def shortest_completing_word(self, licensePlate: str, words: List[str]) -> str: l = list(re.sub('\\s|[0-9]+', '', licensePlate).lower()) words = sorted(words, key=len) for i in words: i_l = list(i) for k in l: flag = 1 ...
TEST_ENTRY_MUTATION = ''' mutation { createEntry(content: "this is a test entry") { id content postedBy { username } } } ''' TEST_DELETE_MUTATION = lambda id: ''' mutation { deleteEntry(id: %d) { id ...
test_entry_mutation = '\n mutation {\n createEntry(content: "this is a test entry") {\n id\n content\n postedBy {\n username\n }\n }\n }\n' test_delete_mutation = lambda id: '\n mutation {\n deleteEntry(id: %d) {\n id\n ...
''' set_paramters.py : set gp_dla_detection default parameters for cddf module ''' # physical constants lya_wavelength = 1215.6701 lyb_wavelength = 1025.7223 lyman_limit = 911.7633 speed_of_light = 299792458 # oscillator strengths lya_oscillator_strength = 0.416400 lyb_oscillator_strength = 0.079120 # all transit...
""" set_paramters.py : set gp_dla_detection default parameters for cddf module """ lya_wavelength = 1215.6701 lyb_wavelength = 1025.7223 lyman_limit = 911.7633 speed_of_light = 299792458 lya_oscillator_strength = 0.4164 lyb_oscillator_strength = 0.07912 all_transition_wavelengths = [1.2156701e-05, 1.0257223e-05, 9.7253...
# # PySNMP MIB module DELL-NETWORKING-TRAP-EVENT-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/DELL-NETWORKING-TRAP-EVENT-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 18:22:47 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python ...
(integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (single_value_constraint, value_size_constraint, constraints_union, value_range_constraint, constraints_intersection) ...
print("NOTE: NumberCrunch is not a random number generator.") print("NumberCrunch") while 0 == 0: number = input("Enter in a number to crunch: ") print("Crunching...") number = int(number) number2 = (((number * number) * 2) - number + (number * 2)) * number * (number * number) - (number * number - numbe...
print('NOTE: NumberCrunch is not a random number generator.') print('NumberCrunch') while 0 == 0: number = input('Enter in a number to crunch: ') print('Crunching...') number = int(number) number2 = (number * number * 2 - number + number * 2) * number * (number * number) - (number * number - number * (n...
# prompt word_one = input("Word 1: ") word_two = input("Word 2: ") # response print("{0}{1}".format(word_one, word_two) * 4)
word_one = input('Word 1: ') word_two = input('Word 2: ') print('{0}{1}'.format(word_one, word_two) * 4)
# # PySNMP MIB module HPN-ICF-MPLS-BGP-VPN-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HPN-ICF-MPLS-BGP-VPN-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 19:28:07 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7....
(object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_range_constraint, value_size_constraint, constraints_intersection, single_value_constraint, constraints_union) ...
# problem 17 # Project Euler __author__ = 'Libao Jin' __date__ = 'July 14, 2015' def oneDigitTransform(number): if number == 1: numberInString = 'one' elif number == 2: numberInString = 'two' elif number == 3: numberInString = 'three' elif number == 4: numberInString = 'four' elif number == 5: numberIn...
__author__ = 'Libao Jin' __date__ = 'July 14, 2015' def one_digit_transform(number): if number == 1: number_in_string = 'one' elif number == 2: number_in_string = 'two' elif number == 3: number_in_string = 'three' elif number == 4: number_in_string = 'four' elif numb...
string = input() set = set() for i in string: set.add(i) ll = [x for x in set] for j in sorted(ll): print(f'{j}: {string.count(j)} time/s')
string = input() set = set() for i in string: set.add(i) ll = [x for x in set] for j in sorted(ll): print(f'{j}: {string.count(j)} time/s')
src = Split(''' service_manager.c ''') component = aos_component('alink', src) dependencis = Split(''' framework/connectivity/wsf utility/digest_algorithm utility/cjson utility/base64 utility/hashtable utility/log kernel/yloop kernel/modules/fs/kv framewo...
src = split('\n service_manager.c\n') component = aos_component('alink', src) dependencis = split('\n framework/connectivity/wsf \n utility/digest_algorithm \n utility/cjson \n utility/base64 \n utility/hashtable \n utility/log \n kernel/yloop \n kernel/modules/fs/kv \n framework/cloud \n ...
# -*- coding: utf-8 -*- class Singleton(object): def __new__(type): if not '_the_instance' in type.__dict__: type._the_instance = object.__new__(type) return type._the_instance if __name__ == "__main__": a = Singleton() a.hw = 'hello world' b = Singleton() print(b.hw)...
class Singleton(object): def __new__(type): if not '_the_instance' in type.__dict__: type._the_instance = object.__new__(type) return type._the_instance if __name__ == '__main__': a = singleton() a.hw = 'hello world' b = singleton() print(b.hw) print(hex(id(a))) ...
__AUTHOR__="Goichi (Iisaka) Yukawa" __VERSION__="0.2.3" __LICENSE__="MIT" __MYPROG__="sphinx-express"
__author__ = 'Goichi (Iisaka) Yukawa' __version__ = '0.2.3' __license__ = 'MIT' __myprog__ = 'sphinx-express'
# 6. Write a program that takes a user input string and outputs every second word. n = str(input("Please enter a sentence: ")) print (n.split()[0]) print (n.split()[2]) print (n.split()[4]) print (n.split()[6])
n = str(input('Please enter a sentence: ')) print(n.split()[0]) print(n.split()[2]) print(n.split()[4]) print(n.split()[6])
# When you become mighty at math, you'll find it a lot less stressful! # might + math = happy for ia in range(1, 10): for ib in range(0, 10): for ic in range(0, 10): for id in range(1, 10): for ie in range(0, 10): for ig in range(0, 10): ...
for ia in range(1, 10): for ib in range(0, 10): for ic in range(0, 10): for id in range(1, 10): for ie in range(0, 10): for ig in range(0, 10): for ih in range(0, 10): for ii in range(0, 10): ...
n = int(input("Enter a number: ")) s = "" for i in range(n): if (i + 1) % 3 == 0 and (i + 1) % 5 == 0: s = "FizzBuzz" elif (i + 1) % 3 == 0: s = "Fizz" elif (i + 1) % 5 ==0: s = "Buzz" else: s = i + 1 print(s) i += 1
n = int(input('Enter a number: ')) s = '' for i in range(n): if (i + 1) % 3 == 0 and (i + 1) % 5 == 0: s = 'FizzBuzz' elif (i + 1) % 3 == 0: s = 'Fizz' elif (i + 1) % 5 == 0: s = 'Buzz' else: s = i + 1 print(s) i += 1
#percent error wrt to first argument with default accuracy of 2 decimal places def err_percent(baseline, final, acc = 2): reduction = round(((final - baseline)/ baseline) * 100, acc) print('Error percentage change : {} %'.format(reduction))
def err_percent(baseline, final, acc=2): reduction = round((final - baseline) / baseline * 100, acc) print('Error percentage change : {} %'.format(reduction))
letters = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"] points = [1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 4, 1, 3, 10, 1, 1, 1, 1, 4, 4, 8, 4, 10] letters += [letter.lower() for letter in letters] points *= 2 letter_to_points = {key:va...
letters = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'] points = [1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 4, 1, 3, 10, 1, 1, 1, 1, 4, 4, 8, 4, 10] letters += [letter.lower() for letter in letters] points *= 2 letter_to_points = {key: va...
def validate_users(users): if len(users)>=3: print(users + " is valid") else: print(users + " is invalid") validate_users("purplecat")
def validate_users(users): if len(users) >= 3: print(users + ' is valid') else: print(users + ' is invalid') validate_users('purplecat')
# functions of list in python myCourses = ["Python", "Kotlin", "Java", "JavaScript"] myCourses2 = ["VueJs", "JQuary"] print(myCourses) print("----------------------") myCourses.append("Blander") print(myCourses) print(len(myCourses)) myCourses.append(myCourses2) print(myCourses) print(len(myCour...
my_courses = ['Python', 'Kotlin', 'Java', 'JavaScript'] my_courses2 = ['VueJs', 'JQuary'] print(myCourses) print('----------------------') myCourses.append('Blander') print(myCourses) print(len(myCourses)) myCourses.append(myCourses2) print(myCourses) print(len(myCourses)) myCourses.extend(['Asp.net', 'C#']) print(myCo...
def main(): zeros = 0 negatives = 0 positives = 0 for step in range(10): number = float(input(f"Number {step + 1}: ")) if number > 0: positives += 1 elif number < 0: negatives += 1 else: zeros += 1 print(f"Number of zeros: {zeros}")...
def main(): zeros = 0 negatives = 0 positives = 0 for step in range(10): number = float(input(f'Number {step + 1}: ')) if number > 0: positives += 1 elif number < 0: negatives += 1 else: zeros += 1 print(f'Number of zeros: {zeros}')...
N,M = map(int, input().split()) connect = [[0,0,0]] on_off = [0]*(N+1) result = 0 for _ in range(M): k = list(map(int, input().split())) connect.append(k[1:]) p = list(map(int, input().split())) for cnt in range(0,2**N): bin_str = list(format(cnt, 'b')) i = len(on_off)-len(bin_str) for ...
(n, m) = map(int, input().split()) connect = [[0, 0, 0]] on_off = [0] * (N + 1) result = 0 for _ in range(M): k = list(map(int, input().split())) connect.append(k[1:]) p = list(map(int, input().split())) for cnt in range(0, 2 ** N): bin_str = list(format(cnt, 'b')) i = len(on_off) - len(bin_str) for...
class Foo(object): def no_arg(self): pass def one_arg(arg): return arg
class Foo(object): def no_arg(self): pass def one_arg(arg): return arg
# -*- coding: utf-8 -*- __version__ = '{{cookiecutter.project_version}}' __description__ = '{{cookiecutter.project_description}}.' __author__ = 'rgb-24bit' __author_email__ = 'rgb-24bit@foxmail.com' __license__ = '{{cookiecutter.license}}' __copyright__ = 'Copyright 2019 rgb-24bit'
__version__ = '{{cookiecutter.project_version}}' __description__ = '{{cookiecutter.project_description}}.' __author__ = 'rgb-24bit' __author_email__ = 'rgb-24bit@foxmail.com' __license__ = '{{cookiecutter.license}}' __copyright__ = 'Copyright 2019 rgb-24bit'
a = [1, 2, 5] b = [ [1, 2, 3], [4, 5, 6], [7, 8, 9], ] c = { "firstname": "John", "lastname": "Doe", "age": 42, "children": [ { "name": "Sara", "age": 4, }, ], } print(a[1]) print(b[0][1]) print(c["firstname"], c["lastname"]) ch = c["children"][...
a = [1, 2, 5] b = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] c = {'firstname': 'John', 'lastname': 'Doe', 'age': 42, 'children': [{'name': 'Sara', 'age': 4}]} print(a[1]) print(b[0][1]) print(c['firstname'], c['lastname']) ch = c['children'][0] print(ch['name'], ch['age'])
#!/usr/bin/env python3 _v4_len = 32 _v6_len = 128 def eng_exponent(n): return len(("{:,d}".format(n)).split(",")) - 1 def num_addresses(prefix_length, address_length): return 2 ** (address_length - prefix_length) if __name__ == "__main__": prefix = int(input("Network prefix length: "), 10) network =...
_v4_len = 32 _v6_len = 128 def eng_exponent(n): return len('{:,d}'.format(n).split(',')) - 1 def num_addresses(prefix_length, address_length): return 2 ** (address_length - prefix_length) if __name__ == '__main__': prefix = int(input('Network prefix length: '), 10) network = input('IP version (4 or 6)...
n = input() arr = list(map(int, input().split())) def podziel(arr, start, end): pivot = arr[end] low = start high = end - 1 while True: while low <= high and arr[low] <= pivot: low += 1 while low <= high and arr[high] >= pivot: high -= 1 if low <= hig...
n = input() arr = list(map(int, input().split())) def podziel(arr, start, end): pivot = arr[end] low = start high = end - 1 while True: while low <= high and arr[low] <= pivot: low += 1 while low <= high and arr[high] >= pivot: high -= 1 if low <= high: ...
def fib(x): if(x == 0): return 0 ant = 1 atual = 1 prox = ant + atual for x in range(2, x): prox = ant + atual ant = atual atual = prox return atual vezes = int(input()) for z in range(0, vezes): i = int(input()) print('Fib(%d) = %d' %(i, fib(i)))
def fib(x): if x == 0: return 0 ant = 1 atual = 1 prox = ant + atual for x in range(2, x): prox = ant + atual ant = atual atual = prox return atual vezes = int(input()) for z in range(0, vezes): i = int(input()) print('Fib(%d) = %d' % (i, fib(i)))
#!/usr/bin/python3 with open('04_input', 'r') as f: lines = f.readlines() num_list = [int(n) for n in lines[0].strip().split(',')] lines = lines[2:] class Board: def __init__(self, lines): self.called = [[False for i in range(5)] for j in range(5)] self.remaining = set() se...
with open('04_input', 'r') as f: lines = f.readlines() num_list = [int(n) for n in lines[0].strip().split(',')] lines = lines[2:] class Board: def __init__(self, lines): self.called = [[False for i in range(5)] for j in range(5)] self.remaining = set() self.pos_map = dict() for...
''' Created on 2014-03-31 @author: Nich ''' class VisibleThingsSystem(object): ''' Attach all the things that a person can see to that person so that the parser knows what's available ''' def __init__(self, node_factory): self.node_factory = node_factory def get_nodes(s...
""" Created on 2014-03-31 @author: Nich """ class Visiblethingssystem(object): """ Attach all the things that a person can see to that person so that the parser knows what's available """ def __init__(self, node_factory): self.node_factory = node_factory def get_nodes(self): node...