content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
#!/usr/bin/env python AMAZON_ACCESS_KEY = 'YOUR_AMAZON_ACCESS_KEY' AMAZON_SECRET_KEY = 'YOUR_AMAZON_SECRET_KEY' AMAZON_ASSOC_TAG = 'YOUR_AMAZON_ASSOC_TAG'
amazon_access_key = 'YOUR_AMAZON_ACCESS_KEY' amazon_secret_key = 'YOUR_AMAZON_SECRET_KEY' amazon_assoc_tag = 'YOUR_AMAZON_ASSOC_TAG'
def read_log(filename): with open(filename, "r") as f: lines = f.readlines() return [l.strip() for l in lines] def only_success(log_lines): return [l for l in log_lines if "processed user" in l] def only_errors(log_lines): return [l for l in log_lines if "processing error" in l] def get_stats(line): unparse...
def read_log(filename): with open(filename, 'r') as f: lines = f.readlines() return [l.strip() for l in lines] def only_success(log_lines): return [l for l in log_lines if 'processed user' in l] def only_errors(log_lines): return [l for l in log_lines if 'processing error' in l] def get_stats...
''' Configuration File. ''' ## # Learning Loss for Active Learning NUM_TRAIN = 50000 # N NUM_VAL = 50000 - NUM_TRAIN BATCH = 128 # B SUBSET = 10000 # M ADDENDUM = 1000 # K MARGIN = 1.0 # xi WEIGHT = 1.0 # lambda TRIALS = 3 CYCLES = 10 EPOCH = 200 LR = 0.1 MILESTONES = [160] EPOCHL = 120 # After 120 epochs...
""" Configuration File. """ num_train = 50000 num_val = 50000 - NUM_TRAIN batch = 128 subset = 10000 addendum = 1000 margin = 1.0 weight = 1.0 trials = 3 cycles = 10 epoch = 200 lr = 0.1 milestones = [160] epochl = 120 momentum = 0.9 wdecay = 0.0005 ' CIFAR-10 | ResNet-18 | 93.6%\nNUM_TRAIN = 50000 # N\nNUM_VAL = 500...
# read test.txt with open("test.txt") as file: for line in file: print(line[0])
with open('test.txt') as file: for line in file: print(line[0])
# Pirple: Python is Easy # Homework Assignment 07 - Dictionaries and Sets # Written by Franz A. Tapia Chaca # on 01 Feburary 2021 # Practice using dictionaries # Program: # 1) Details of a song are stored in a dictionary, and a single loop # prints out the song's details # 2) The user is prompted to guess the dictiona...
favourite_song = {'title': 'Christ is Mine Forevermore', 'artist': 'CityAlight', 'releaseYear': 2016, 'album': 'Only a Holy God', 'durationInSeconds': 5 * 60 + 28, 'genre': 'Christian worship', 'CCLInum': 7036096} print('favouriteSong Dictionary keys and values:') for key in favouriteSong.keys(): print(key + ': ' +...
def login(_id): members = ['dongmin', 'ldm8191', 'leezche'] for member in members: if member == _id: return True return False
def login(_id): members = ['dongmin', 'ldm8191', 'leezche'] for member in members: if member == _id: return True return False
""" Copyright 2013 Rackspace Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dist...
""" Copyright 2013 Rackspace Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dist...
#Martin Quinn month = [31,28,31,30,31,30,31,31,30,31,30,31] day = 1 year = 1901 sunday = 1 count = 0 i = 0 daycount = 0 monthcount = 0; yearcount = 0; #this is a for loop to count the years for year in range(1900,2000): yearcount = yearcount + 1 #this checks to see wether it is a leap year or not if((year%4)...
month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] day = 1 year = 1901 sunday = 1 count = 0 i = 0 daycount = 0 monthcount = 0 yearcount = 0 for year in range(1900, 2000): yearcount = yearcount + 1 if year % 4 == 0: month[2] = month[2] + 1 for i in range(0, 12): monthcount = mon...
for _ in range(int(input())): s = input().split() o = [] for x in s: if len(x) == 4: o.append("****") else: o.append(x) print(*o)
for _ in range(int(input())): s = input().split() o = [] for x in s: if len(x) == 4: o.append('****') else: o.append(x) print(*o)
#!/usr/bin/python # class_attribute.py class Cat: species = 'mammal' def __init__(self, name, age): self.name = name self.age = age missy = Cat('Missy', 3) lucky = Cat('Lucky', 5) print(missy.name, missy.age) print(lucky.name, lucky.age) print(Cat.species) print(missy.__class__.species)...
class Cat: species = 'mammal' def __init__(self, name, age): self.name = name self.age = age missy = cat('Missy', 3) lucky = cat('Lucky', 5) print(missy.name, missy.age) print(lucky.name, lucky.age) print(Cat.species) print(missy.__class__.species) print(lucky.__class__.species)
""" Write a program which accepts a sequence of comma-separated numbers from console and generate a list and a tuple which contains every number. Suppose the following input is supplied to the program: 34,67,55,33,12,98 Then, the output should be: ['34', '67', '55', '33', '12', '98'] ('34', '67', '55', '33', '12', ...
""" Write a program which accepts a sequence of comma-separated numbers from console and generate a list and a tuple which contains every number. Suppose the following input is supplied to the program: 34,67,55,33,12,98 Then, the output should be: ['34', '67', '55', '33', '12', '98'] ('34', '67', '55', '33', '12', ...
"""Helper methods for the Stats class""" def get_numeric_series(): """Creates a list of numbers (float) Returns: [nums]: a list of numbers """ nums = [] inp = get_number() while (inp): nums.append(inp) inp = get_number() return nums def get_number(): """Reads a...
"""Helper methods for the Stats class""" def get_numeric_series(): """Creates a list of numbers (float) Returns: [nums]: a list of numbers """ nums = [] inp = get_number() while inp: nums.append(inp) inp = get_number() return nums def get_number(): """Reads a nu...
'''Square root approximation to demstrate the use of While loop''' value = int(input('Enter value to approximate its root: ')) #Guess a root root = 1.0 diff = root * root - value while diff > 0.0000001 or diff < -0.0000001: root = (root + value / root) / 2 diff = root * root - value print(root)
"""Square root approximation to demstrate the use of While loop""" value = int(input('Enter value to approximate its root: ')) root = 1.0 diff = root * root - value while diff > 1e-07 or diff < -1e-07: root = (root + value / root) / 2 diff = root * root - value print(root)
#!/usr/bin/env python # coding: utf-8 # ### Reminder Regarding dividing stuff in Python: # IF you divide two integers: python considers this as an integer division ! # dividing one float by an integer: the result is always a float -> so we should convert one of them to float ! # In[8]: L = 2 #k = 0.78 # float k = 1...
l = 2 k = 1 a = 50 r = float(L) / (k * A) print(R) name1 = 'Santiago ' type(name1) name2 = 'Luca' name3 = 5 * name2 names_in_order = name1 + name2 print(name3) print('The value of R is ' + str(R) + ' DegC/W') f = 1 f = float(f) f = 21 l_string = raw_input('Please insert the length of this layer: ') k = 0.78 a = 50 l_va...
class Solution: def maxSlidingWindow(self, nums: List[int], k: int) -> List[int]: que = collections.deque() res = [] for i, num in enumerate(nums): if que and i - que[0][0] >= k: que.popleft() while que and que[-1][1] <= num: que.pop() que.append([i, num])...
class Solution: def max_sliding_window(self, nums: List[int], k: int) -> List[int]: que = collections.deque() res = [] for (i, num) in enumerate(nums): if que and i - que[0][0] >= k: que.popleft() while que and que[-1][1] <= num: que.p...
""" Some top-level exceptions that are generally useful. """ class UploadedImageIsUnreadableError(Exception): """ Raise this when the image generation backend can't read the image being uploaded. This doesn't necessarily mean that the image is definitely mal-formed or corrupt, but the imaging library ...
""" Some top-level exceptions that are generally useful. """ class Uploadedimageisunreadableerror(Exception): """ Raise this when the image generation backend can't read the image being uploaded. This doesn't necessarily mean that the image is definitely mal-formed or corrupt, but the imaging library (...
#%% 1-misol list1=[1,2,3] list2=[11, 22, 33] list3=[] if(len(list1)==len(list2)): list3 = [i for j in zip(list1, list2) for i in j] print(list3) elif(len(list1)>len(list2)): list3 = [i for j in zip(list1, list2) for i in j] list3.append(list1[len(list2):len(list1)]) print(list3) elif(len(list1)<l...
list1 = [1, 2, 3] list2 = [11, 22, 33] list3 = [] if len(list1) == len(list2): list3 = [i for j in zip(list1, list2) for i in j] print(list3) elif len(list1) > len(list2): list3 = [i for j in zip(list1, list2) for i in j] list3.append(list1[len(list2):len(list1)]) print(list3) elif len(list1) < len(...
# -*- coding:utf-8 -*- class SyntaxException(Exception): pass
class Syntaxexception(Exception): pass
FRANCHISES = """ select t1.aliases, overall, firsts, seconds, third, y1,y2, unique_a, unique_1, unique_12 from (select Count(A."PlayerID") as overall,T."Aliases" as aliases, MAX(A."year") as y1, MIN(A."year") as y2, Count (distinct A."PlayerID") as unique_a from public."all-nba-teams_list" A, public.teams T where A...
franchises = '\nselect t1.aliases, overall, firsts, seconds, third, y1,y2, unique_a, unique_1, unique_12\nfrom \n\t(select Count(A."PlayerID") as overall,T."Aliases" as aliases, MAX(A."year") as y1, MIN(A."year") as y2, Count (distinct A."PlayerID") as unique_a\n\tfrom public."all-nba-teams_list" A, public.teams T\n\tw...
# # Copyright 2020 The FATE Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable ...
class Basestatus(object): @classmethod def status_list(cls): return [cls.__dict__[k] for k in cls.__dict__.keys() if not callable(getattr(cls, k)) and (not k.startswith('__'))] @classmethod def contains(cls, status): return status in cls.status_list() class Basestatetransitionrule(obj...
# # PySNMP MIB module SENAO-ENTERPRISE-INDOOR-AP-CB-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/SENAO-ENTERPRISE-INDOOR-AP-CB-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 20:53:40 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using P...
(integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_union, value_size_constraint, single_value_constraint, constraints_intersection, value_range_constraint) ...
class ModelNotFoundException(Exception): pass class UnknownFunctionException(Exception): pass
class Modelnotfoundexception(Exception): pass class Unknownfunctionexception(Exception): pass
def DivisiblePairCount(arr) : count = 0 k = len(arr) for i in range(0, k): for j in range(i+1, k): if (arr[i] % arr[j] == 0 or arr[j] % arr[i] == 0): count += 1 return count if __name__ == "__main__": #give input in form of a list -- [1,2,3] arr = [int...
def divisible_pair_count(arr): count = 0 k = len(arr) for i in range(0, k): for j in range(i + 1, k): if arr[i] % arr[j] == 0 or arr[j] % arr[i] == 0: count += 1 return count if __name__ == '__main__': arr = [int(item) for item in ''.join(list(input())[1:-1]).spli...
# # Copyright (c) 2019 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to...
def test_get_model_status_successful(client): response = client.simulate_request(method='GET', path='/v1/models/test', headers={'Content-Type': 'application/json'}) assert response.status_code == 200 def test_get_model_status_successful_with_specific_version(client): response = client.simulate_request(meth...
computers = int ( input () ) total_computers = computers total_rating = 0 total_sales = 0 while not computers == 0: command = int ( input () ) possible_sales = 0 last_digit = command % 10 first_two_digits = command // 10 rating = last_digit if rating == 3: possible_sales = first_two_digi...
computers = int(input()) total_computers = computers total_rating = 0 total_sales = 0 while not computers == 0: command = int(input()) possible_sales = 0 last_digit = command % 10 first_two_digits = command // 10 rating = last_digit if rating == 3: possible_sales = first_two_digits * 0.5...
#-*- coding:utf-8 -*- ############################################################################## # # Copyright (C) 2012 Michael Telahun Makonnen <mmakonnen@gmail.com>. # All Rights Reserved. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero G...
{'name': 'Ethiopia - Accounting', 'version': '1.0', 'category': 'Localization/Account Charts', 'description': '\nBase Module for Ethiopian Localization\n======================================\n\nThis is the latest Ethiopian OpenERP localization and consists of:\n - Chart of Accounts\n - VAT tax structure\n - W...
# name, image, value, uses, [effect] software_list = [ ["Smokescreen", "PLACEHOLDER.JPG", 50, 1], ["Fork", "PLACEHOLDER.JPG", 150, 2], ["Fortify", "PLACEHOLDER.JPG", 75, 2], ["Disrupt", "PLACEHOLDER.JPG", 100, 1], ["Sleep", "PLACEHOLDER.JPG", 200, 4], ["Glamour", "PLACEHOLDER.JPG", 100, 1], ...
software_list = [['Smokescreen', 'PLACEHOLDER.JPG', 50, 1], ['Fork', 'PLACEHOLDER.JPG', 150, 2], ['Fortify', 'PLACEHOLDER.JPG', 75, 2], ['Disrupt', 'PLACEHOLDER.JPG', 100, 1], ['Sleep', 'PLACEHOLDER.JPG', 200, 4], ['Glamour', 'PLACEHOLDER.JPG', 100, 1]] hardware_list = [['RAM Upgrade', 'PLACEHOLDER.JPG', 100, -1], ['CP...
# Leo colorizer control file for embperl mode. # This file is in the public domain. # Properties for embperl mode. properties = { "commentEnd": "-->", "commentStart": "<!--", } # Attributes dict for embperl_main ruleset. embperl_main_attributes_dict = { "default": "null", "digit_re": "", ...
properties = {'commentEnd': '-->', 'commentStart': '<!--'} embperl_main_attributes_dict = {'default': 'null', 'digit_re': '', 'escape': '', 'highlight_digits': 'false', 'ignore_case': 'true', 'no_word_sep': ''} attributes_dict_dict = {'embperl_main': embperl_main_attributes_dict} embperl_main_keywords_dict = {} keyword...
# # PySNMP MIB module RH-ATT-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/RH-ATT-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 20:48:48 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 2019, 09:...
(object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_union, value_range_constraint, constraints_intersection, single_value_constraint, value_size_constraint) ...
""" Write a Python program to sum all the items in a list. """ list1 = [1, 2, -8] sum_numbers = 0 for x in list1: sum_numbers += x print(sum_numbers)
""" Write a Python program to sum all the items in a list. """ list1 = [1, 2, -8] sum_numbers = 0 for x in list1: sum_numbers += x print(sum_numbers)
################################################################################ # # # ____ _ # # | _ \ ___ __| |_ __ _ _ _ __ ___ ...
class Text_Format: bold: str = '\x1b[1m' obfuscated: str = '' italic: str = '\x1b[3m' underline: str = '\x1b[4m' strike_through: str = '\x1b[9m' reset: str = '\x1b[m' black: str = '\x1b[38;5;16m' dark_blue: str = '\x1b[38;5;19m' dark_green: str = '\x1b[38;5;34m' dark_aqua: str = ...
class FragmentChain: """Class to represent a set of DNA fragments that can assemble into a linear or circular construct. Parameters ---------- fragments A list of fragments that can be assembled into a linear/cicular construct. is_standardized Indicates whether the fragment is in ...
class Fragmentchain: """Class to represent a set of DNA fragments that can assemble into a linear or circular construct. Parameters ---------- fragments A list of fragments that can be assembled into a linear/cicular construct. is_standardized Indicates whether the fragment is in ...
"""Here we have "scanners" for the different Python versions. "scanner" is a compiler-centric term, but it is really a bit different from a traditional compiler scanner/lexer. Here we start out with text disasembly and change that to be more ameanable to parsing in which we look only at the opcode name, and not and i...
"""Here we have "scanners" for the different Python versions. "scanner" is a compiler-centric term, but it is really a bit different from a traditional compiler scanner/lexer. Here we start out with text disasembly and change that to be more ameanable to parsing in which we look only at the opcode name, and not and i...
while True: try: num = int(input("Enter the number to find factorial: ")) except: print("Entered value is not valid. Please try again.") continue factorial = 1 if num < 0: print("We can not find the factorial of a negative number.") elif num == 0: ...
while True: try: num = int(input('Enter the number to find factorial: ')) except: print('Entered value is not valid. Please try again.') continue factorial = 1 if num < 0: print('We can not find the factorial of a negative number.') elif num == 0: print('The f...
# Coffee Break Python a = 'hello' b = 'world' print(a, b, sep=' Python ', end='!')
a = 'hello' b = 'world' print(a, b, sep=' Python ', end='!')
d = int(input('dias: ')) k = float(input('Km rodados :')) p = 60*d + 0,15*k print(f'R$ {p: .2f}' )
d = int(input('dias: ')) k = float(input('Km rodados :')) p = (60 * d + 0, 15 * k) print(f'R$ {p: .2f}')
class K8sRepository: def __init__(self): pass @staticmethod def create_k8s_pods_view_model(result): success = [] try: for each_host in result['success']: for each_resource in result['success'][each_host.encode('raw_unicode_escape')]['resources']: ...
class K8Srepository: def __init__(self): pass @staticmethod def create_k8s_pods_view_model(result): success = [] try: for each_host in result['success']: for each_resource in result['success'][each_host.encode('raw_unicode_escape')]['resources']: ...
""" # Purpose of the bisection method is to find an interval where there exists a root # Programmed by Aladdin Persson # 2019-10-07 Initial programming """ def function(x): # return (x**2 - 2) return x ** 2 + 2 * x - 1 def bisection(a0, b0, eps, delta, maxit): # Initialize search bracket s.t a <= b ...
""" # Purpose of the bisection method is to find an interval where there exists a root # Programmed by Aladdin Persson # 2019-10-07 Initial programming """ def function(x): return x ** 2 + 2 * x - 1 def bisection(a0, b0, eps, delta, maxit): alpha = min(a0, b0) beta = max(a0, b0) a = [] b = [] ...
# Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. { 'variables': { 'conditions': [ ['OS == "linux" and chromeos==0', { 'use_system_libexif%': 1, }, { # OS != "linux" and chrome...
{'variables': {'conditions': [['OS == "linux" and chromeos==0', {'use_system_libexif%': 1}, {'use_system_libexif%': 0}]]}, 'conditions': [['use_system_libexif==0', {'targets': [{'target_name': 'libexif', 'type': 'loadable_module', 'sources': ['sources/libexif/exif-byte-order.c', 'sources/libexif/exif-content.c', 'sourc...
'''Node class. :copyright: 2021, Jeroen van der Heijden <jeroen@cesbit.com> ''' class Node: __slots__ = ('element', '_string', 'start', 'end', 'children') def __init__(self, element, string, start, end=None): self.element = element self.start = start self.end = end self._str...
"""Node class. :copyright: 2021, Jeroen van der Heijden <jeroen@cesbit.com> """ class Node: __slots__ = ('element', '_string', 'start', 'end', 'children') def __init__(self, element, string, start, end=None): self.element = element self.start = start self.end = end self._strin...
#PROCESSAMENTO def concatenar(frase): escopo_frase = frase.strip().upper().split() concatenada = '' for a in range(len(escopo_frase)): concatenada += escopo_frase[a] return concatenada def fraseFormatada(frase): frase_escopo = [] for i in range(len(frase), 0, -1): frase_escopo...
def concatenar(frase): escopo_frase = frase.strip().upper().split() concatenada = '' for a in range(len(escopo_frase)): concatenada += escopo_frase[a] return concatenada def frase_formatada(frase): frase_escopo = [] for i in range(len(frase), 0, -1): frase_escopo.append(frase[-i...
# Paula Daly Solution to Problem 5 March 2019 # Prime Numbers # taking input from user number = int(input("Enter any number: ")) # prime number is always greater than 1 if number > 1: for i in range(2, number): if (number % i) == 0: print(number, "is not a prime number") break e...
number = int(input('Enter any number: ')) if number > 1: for i in range(2, number): if number % i == 0: print(number, 'is not a prime number') break else: print(number, 'is a prime number') else: print(number, 'is not a prime number')
n, m = map(int, input().split()) wa = [0 for _ in range(n)] ac = [0 for _ in range(n)] for _ in range(m): p, s = input().split() if s == 'WA' and ac[int(p)-1] == 0: wa[int(p)-1] += 1 else: if ac[int(p)-1] == 0: ac[int(p)-1] = 1 wa_ans = 0 ac_ans = sum(ac) for i in range(n): ...
(n, m) = map(int, input().split()) wa = [0 for _ in range(n)] ac = [0 for _ in range(n)] for _ in range(m): (p, s) = input().split() if s == 'WA' and ac[int(p) - 1] == 0: wa[int(p) - 1] += 1 elif ac[int(p) - 1] == 0: ac[int(p) - 1] = 1 wa_ans = 0 ac_ans = sum(ac) for i in range(n): if ac...
class Solution(object): def uniquePathsWithObstacles(self, obstacleGrid): row = len(obstacleGrid) col = len(obstacleGrid[0]) grid = [[0 for c in range(col)] for r in range(row)] for c in range(col): if (obstacleGrid[0][c] == 0): grid[0][c...
class Solution(object): def unique_paths_with_obstacles(self, obstacleGrid): row = len(obstacleGrid) col = len(obstacleGrid[0]) grid = [[0 for c in range(col)] for r in range(row)] for c in range(col): if obstacleGrid[0][c] == 0: grid[0][c] = 1 ...
class FizzBuzz: start = 1 stop = 100 factor_1 = 3 factor_2 = 5 word_1 = "Fizz" word_2 = "Buzz" def __init__(self, *args, **kwargs): self.start = kwargs.get("start", self.start) self.stop = kwargs.get("stop", self.stop) + 1 # non inclusive self.factor_1 = kwargs.get(...
class Fizzbuzz: start = 1 stop = 100 factor_1 = 3 factor_2 = 5 word_1 = 'Fizz' word_2 = 'Buzz' def __init__(self, *args, **kwargs): self.start = kwargs.get('start', self.start) self.stop = kwargs.get('stop', self.stop) + 1 self.factor_1 = kwargs.get('factor_1', self....
class Config: SCALE=600 MAX_SCALE=1200 TEXT_PROPOSALS_WIDTH=16 MIN_NUM_PROPOSALS = 2 MIN_RATIO=0.5 #0.5 LINE_MIN_SCORE=0.8 #0.9 MAX_HORIZONTAL_GAP=50 #50 TEXT_PROPOSALS_MIN_SCORE=0.7 #0.7 TEXT_PROPOSALS_NMS_THRESH=0.2 #0.2 MIN_V_OVERLAPS=0.7 #0.7 MIN_SIZE_SIM=0.7 ...
class Config: scale = 600 max_scale = 1200 text_proposals_width = 16 min_num_proposals = 2 min_ratio = 0.5 line_min_score = 0.8 max_horizontal_gap = 50 text_proposals_min_score = 0.7 text_proposals_nms_thresh = 0.2 min_v_overlaps = 0.7 min_size_sim = 0.7
""" Given two strings text and pattern, return the list of start indexes in text that matches with the pattern using knuth_morris_pratt algorithm. If idx is in the list, text[idx : idx + M] matches with pattern. Time complexity : O(N+M) N and M is the length of text and pattern, respectively. """ def knuth_morris_pr...
""" Given two strings text and pattern, return the list of start indexes in text that matches with the pattern using knuth_morris_pratt algorithm. If idx is in the list, text[idx : idx + M] matches with pattern. Time complexity : O(N+M) N and M is the length of text and pattern, respectively. """ def knuth_morris_pra...
class Sample: def __init__(slf,name) -> None: slf.name = name s = Sample("Deepak") print(s.name)
class Sample: def __init__(slf, name) -> None: slf.name = name s = sample('Deepak') print(s.name)
__all__ = [ "ability","entity","logic","event" #"simple" ]
__all__ = ['ability', 'entity', 'logic', 'event']
""" Network related code. """ __author__ = "Brian Allen Vanderburg II" __copyright__ = "Copyright (C) 2017 Brian Allen Vanderburg II" __license__ = "Apache License 2.0"
""" Network related code. """ __author__ = 'Brian Allen Vanderburg II' __copyright__ = 'Copyright (C) 2017 Brian Allen Vanderburg II' __license__ = 'Apache License 2.0'
""" Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. Assume that there is only one duplicate number, find the duplicate one. Example 1: Input: [1,3,4,2,2] Output: 2 Example 2: Input: [3,1,3,4,2] Output: 3 """ ...
""" Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. Assume that there is only one duplicate number, find the duplicate one. Example 1: Input: [1,3,4,2,2] Output: 2 Example 2: Input: [3,1,3,4,2] Output: 3 """ ...
class SQLQuery: class solves: createTable = """ CREATE TABLE IF NOT EXISTS ctf_solves ( user INTEGER NOT NULL, question INTEGER NOT NULL, FOREIGN KEY (user) REFERENCES users (id), FOREIGN KEY (question) REFERENCES ctf_q...
class Sqlquery: class Solves: create_table = '\n CREATE TABLE IF NOT EXISTS ctf_solves (\n user INTEGER NOT NULL,\n question INTEGER NOT NULL,\n \n FOREIGN KEY (user) REFERENCES users (id),\n FOREIGN KEY (question) REFERENCES...
class User: def __init__(self, id, name, passwd): self.id = id self.name = name self.passwd = passwd class Game: def __init__(self, name, category, game_console, id=None): self.id = id self.name = name self.category = category self.game_console = game_co...
class User: def __init__(self, id, name, passwd): self.id = id self.name = name self.passwd = passwd class Game: def __init__(self, name, category, game_console, id=None): self.id = id self.name = name self.category = category self.game_console = game_c...
class no_grad: def __enter__(self): return None def __exit__(self, *args): return True def __call__(self, func): return self class enable_grad: def __enter__(self): return None def __exit__(self, *args): return True def __call__(self, func): ...
class No_Grad: def __enter__(self): return None def __exit__(self, *args): return True def __call__(self, func): return self class Enable_Grad: def __enter__(self): return None def __exit__(self, *args): return True def __call__(self, func): ...
class Point(object): """ Creates Class Point. """ def __init__(self, x=0, y=0): """ Defines x and y Variables. """ self.__coords = [x, y] # get functions series def get_x(self): return self.__coords[0] def get_y(self): return self.__coords[1] def get_c(self, po...
class Point(object): """ Creates Class Point. """ def __init__(self, x=0, y=0): """ Defines x and y Variables. """ self.__coords = [x, y] def get_x(self): return self.__coords[0] def get_y(self): return self.__coords[1] def get_c(self, pos): try: ...
result = DATA result[:, 0] = result[:, 0].clip(50, 80)
result = DATA result[:, 0] = result[:, 0].clip(50, 80)
#!/usr/bin/env python __all__ = [ "test_blast", "test_blast_xml", "test_cigar", "test_clustal", "test_dialign", "test_ebi", "test_fasta", "test_genbank", "test_locuslink", "test_ncbi_taxonomy", "test_nexus", "test_phylip", "test_record", "test_record_finder", ...
__all__ = ['test_blast', 'test_blast_xml', 'test_cigar', 'test_clustal', 'test_dialign', 'test_ebi', 'test_fasta', 'test_genbank', 'test_locuslink', 'test_ncbi_taxonomy', 'test_nexus', 'test_phylip', 'test_record', 'test_record_finder', 'test_tree', 'test_unigene'] __author__ = '' __copyright__ = 'Copyright 2007-2020, ...
# # PySNMP MIB module QB-QOS-MGMT-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/QB-QOS-MGMT-MIB # Produced by pysmi-0.3.4 at Wed May 1 14:43:34 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27...
(object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (single_value_constraint, value_range_constraint, constraints_union, constraints_intersection, value_size_constraint) ...
class BaseLines(object): def __init__(self, tc_freq, t_freq): # get probability of context given target <likelihood> self.row_sums = tc_freq.astype(float).sum(axis=1) self.p_c_given_t = (tc_freq.astype(float)+1) / (self.row_sums[:, np.newaxis] + 1 + corpus_size) # get probability of target <prior> self.p_t ...
class Baselines(object): def __init__(self, tc_freq, t_freq): self.row_sums = tc_freq.astype(float).sum(axis=1) self.p_c_given_t = (tc_freq.astype(float) + 1) / (self.row_sums[:, np.newaxis] + 1 + corpus_size) self.p_t = t_freq.astype(float) / sum(t_freq) def prior(self): retur...
# For the complete list of possible settings and their documentation, see # https://docs.djangoproject.com/en/1.11/ref/settings/ and # https://github.com/taigaio/taiga-back/tree/stable/settings. Documentation for # custom Taiga settings can be found at https://taigaio.github.io/taiga-doc/dist/. # Make sure to read http...
databases = {'default': {'ENGINE': 'django.db.backends.postgresql', 'NAME': 'taiga', 'USER': 'taiga', 'PASSWORD': 'changeme', 'HOST': 'database', 'PORT': '5432'}}
class Customer: def __init__(self, first_name, last_name, phone_number, email, national_id, driving_license, customer_id=None, creation_date=None): self.customer_id = customer_id self.first_name = first_name self.last_name = last_name self.phone_number = phone_numb...
class Customer: def __init__(self, first_name, last_name, phone_number, email, national_id, driving_license, customer_id=None, creation_date=None): self.customer_id = customer_id self.first_name = first_name self.last_name = last_name self.phone_number = phone_number self.em...
t = int(input()) for _ in range(t): n = int(input()) a = list(map(int, input().split())) minimum = min(a) min_count = a.count(minimum) if min_count < 2 or not (n * minimum == sum([(num & minimum) for num in a])): print(0) else: total = 2 total *= min_count * (min_count - ...
t = int(input()) for _ in range(t): n = int(input()) a = list(map(int, input().split())) minimum = min(a) min_count = a.count(minimum) if min_count < 2 or not n * minimum == sum([num & minimum for num in a]): print(0) else: total = 2 total *= min_count * (min_count - 1) /...
""" Shoots balls using cardboard and paper plates, tastefully decorated with EDM artists. """ class Shooter(object): def __init__(self, shooterM, hopperM, shooterS, hopperS): self.shooterM = shooterM self.hopperM = hopperM self.shooterS = shooterS self.hopperS = hopperS s...
""" Shoots balls using cardboard and paper plates, tastefully decorated with EDM artists. """ class Shooter(object): def __init__(self, shooterM, hopperM, shooterS, hopperS): self.shooterM = shooterM self.hopperM = hopperM self.shooterS = shooterS self.hopperS = hopperS sel...
# ch4/ch01_ex01.py n_files = 254 files = [] # method 1 for i in range(n_files): files.append(open('output1/sample%i.txt' % i, 'w')) # method 2 '''for i in range(n_files): f = open('output1/sample%i.txt' % i, 'w') files.append(f) f.close()''' # method 3 '''for i in range(n_files): with open('outp...
n_files = 254 files = [] for i in range(n_files): files.append(open('output1/sample%i.txt' % i, 'w')) "for i in range(n_files):\n f = open('output1/sample%i.txt' % i, 'w')\n files.append(f)\n f.close()" "for i in range(n_files):\n with open('output1/sample%i.txt' % i, 'w') as f:\n files.append(f)...
""" Linked List: - Linked List is a collection of node that connected through their references. - It is a linear data structure. - It provides faster insertion and deletion over array. Doubly Linked List: Doubly Linked List is type of linked list in which every node bi-directionally connected...
""" Linked List: - Linked List is a collection of node that connected through their references. - It is a linear data structure. - It provides faster insertion and deletion over array. Doubly Linked List: Doubly Linked List is type of linked list in which every node bi-directionally connected...
# input.py get users input email = 'username@gmail.com' password = 'password' title = 'software engineer' zipCode = '91101' name = 'John Do' phone = '(xxx) xxx-xxxx'
email = 'username@gmail.com' password = 'password' title = 'software engineer' zip_code = '91101' name = 'John Do' phone = '(xxx) xxx-xxxx'
# Alexa is given n piles of equal or unequal heights. # In one step, Alexa can remove any number of boxes from # the pile which has the maximum height and try to make # it equal to the one which is just lower than the maximum # height of the stack. # Determine the minimum number of steps required to make all of # the p...
""" Explanation: Step 1: reducing 5 -> 2 [2, 2, 1] Step 2: reducing 2 -> 1 [2, 1, 1] Step 3: reducing 2 -> 1 [1, 1, 1] So final number of steps required is 3. """ def min_steps_equal_piles(piles): steps = 0 length = len(piles) if piles == []: return 0 else: sorted_piles = ...
''' Created on 1.12.2016 @author: Darren '''''' Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; } Populate each next pointer to point to its next right node. If there is no next right node, the next pointer...
""" Created on 1.12.2016 @author: Darren Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; } Populate each next pointer to point to its next right node. If there is no next right node, the next pointer should be set to NULL...
class Solution: def solve(self, board: List[List[str]]) -> None: """ Do not return anything, modify board in-place instead. """ def valid(i, j, m, n): return i >= 0 and i < m and j >= 0 and j < n def dfs(board, i, j, m, n): di = [-1, ...
class Solution: def solve(self, board: List[List[str]]) -> None: """ Do not return anything, modify board in-place instead. """ def valid(i, j, m, n): return i >= 0 and i < m and (j >= 0) and (j < n) def dfs(board, i, j, m, n): di = [-1, 0, 1, 0] ...
class Vector2(object): def __init__( self, args ): x, y = args self.x, self.y = float( x ), float( y ) def __str__( self ): s = "(" s += ", ".join( [ str( i ) for i in [ self.x, self.y ] ] ) s += ")" return s class Vector3(object): def __init__( self, args ): x, y, z = args self.x...
class Vector2(object): def __init__(self, args): (x, y) = args (self.x, self.y) = (float(x), float(y)) def __str__(self): s = '(' s += ', '.join([str(i) for i in [self.x, self.y]]) s += ')' return s class Vector3(object): def __init__(self, args): ...
class Solution(object): def combine(self, N, K): def helper(first, combination): if len(combination)==K: answer.append(combination) else: for num in xrange(first, N+1): helper(num+1, combination+[num]) answer = [] he...
class Solution(object): def combine(self, N, K): def helper(first, combination): if len(combination) == K: answer.append(combination) else: for num in xrange(first, N + 1): helper(num + 1, combination + [num]) answer = [] ...
class Solution: def minimumSum(self, num: int) -> int: arr = [] while num: arr.append(num%10) num = num // 10 arr.sort() return (arr[0]*10 + arr[3]) + (arr[1]*10 + arr[2])
class Solution: def minimum_sum(self, num: int) -> int: arr = [] while num: arr.append(num % 10) num = num // 10 arr.sort() return arr[0] * 10 + arr[3] + (arr[1] * 10 + arr[2])
def _impl(ctx): ctx.actions.write( output = ctx.outputs.executable, content = ctx.file._shellcheck.short_path, ) return [ DefaultInfo( executable = ctx.outputs.executable, runfiles = ctx.runfiles(files = [ctx.file._shellcheck]), ), ] def _impl_tes...
def _impl(ctx): ctx.actions.write(output=ctx.outputs.executable, content=ctx.file._shellcheck.short_path) return [default_info(executable=ctx.outputs.executable, runfiles=ctx.runfiles(files=[ctx.file._shellcheck]))] def _impl_test(ctx): files = [ctx.file._shellcheck] + ctx.files.data script = 'exec ' +...
initial_hash_values = [ '6a09e667', 'bb67ae85', '3c6ef372', 'a54ff53a', '510e527f', '9b05688c', '1f83d9ab', '5be0cd19' ] sha_256_constants = [ '428a2f98', '71374491', 'b5c0fbcf', 'e9b5dba5', '3956c25b', '59...
initial_hash_values = ['6a09e667', 'bb67ae85', '3c6ef372', 'a54ff53a', '510e527f', '9b05688c', '1f83d9ab', '5be0cd19'] sha_256_constants = ['428a2f98', '71374491', 'b5c0fbcf', 'e9b5dba5', '3956c25b', '59f111f1', '923f82a4', 'ab1c5ed5', 'd807aa98', '12835b01', '243185be', '550c7dc3', '72be5d74', '80deb1fe', '9bdc06a7', ...
# Author: Ashish Jangra from Teenage Coder num = 5 for i in range(5): print(num * "* ")
num = 5 for i in range(5): print(num * '* ')
# Question # 37. Write a program to perform sorting on the given list of strings, on the basis of length of strings # Code a = input("List of strings, sep with commas:\n") strings = [i.strip() for i in a.split(",")] strings.sort(key=lambda x: len(x)) print("Sorted strings") print(strings) # Input # List of string...
a = input('List of strings, sep with commas:\n') strings = [i.strip() for i in a.split(',')] strings.sort(key=lambda x: len(x)) print('Sorted strings') print(strings)
# Medium # https://leetcode.com/problems/unique-paths-ii/ # TC: O(M * N) # SC: O(N) class Solution: def uniquePathsWithObstacles(self, obstacleGrid: List[List[int]]) -> int: n, m = len(obstacleGrid[0]), len(obstacleGrid) prev_row = [0 for _ in range(n)] for i in range(m): for j...
class Solution: def unique_paths_with_obstacles(self, obstacleGrid: List[List[int]]) -> int: (n, m) = (len(obstacleGrid[0]), len(obstacleGrid)) prev_row = [0 for _ in range(n)] for i in range(m): for j in range(n): if obstacleGrid[i][j] == 0: ...
#!/usr/bin/python3 class QuickSearch: offset = 0 steps = 0 jumptable = dict() pattern = "" input = "" def __init__(self, input: str, pattern: str): self.input = input self.pattern = pattern self._getLanguage() self._calculateJumps() self._search() ...
class Quicksearch: offset = 0 steps = 0 jumptable = dict() pattern = '' input = '' def __init__(self, input: str, pattern: str): self.input = input self.pattern = pattern self._getLanguage() self._calculateJumps() self._search() def _get_language(sel...
class SetterBaseCollection(Collection[SetterBase],IList[SetterBase],ICollection[SetterBase],IEnumerable[SetterBase],IEnumerable,IList,ICollection,IReadOnlyList[SetterBase],IReadOnlyCollection[SetterBase]): """ Represents a collection of System.Windows.SetterBase objects. SetterBaseCollection() """ def Cl...
class Setterbasecollection(Collection[SetterBase], IList[SetterBase], ICollection[SetterBase], IEnumerable[SetterBase], IEnumerable, IList, ICollection, IReadOnlyList[SetterBase], IReadOnlyCollection[SetterBase]): """ Represents a collection of System.Windows.SetterBase objects. SetterBaseCollection() """ ...
# https://py.checkio.org/en/mission/morse-decoder/ ''' Your task is to decrypt the secret message using the Morse code. The message will consist of words with 3 spaces between them and 1 space between each letter of each word. If the decrypted text starts with a letter then you'll have to print this letter in upp...
""" Your task is to decrypt the secret message using the Morse code. The message will consist of words with 3 spaces between them and 1 space between each letter of each word. If the decrypted text starts with a letter then you'll have to print this letter in uppercase. """ morse = {'.-': 'a', '-...': 'b', '-.-.': 'c',...
# Copyright 2019 Jeremy Schulman, nwkautomaniac@gmail.com # # 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 applicabl...
""" This file contains the Slack components for using Dialogs Notes ----- API: https://api.slack.com/dialogs For reference, the dialog fields are copy/paste from the API here: title : str User-facing title of this entire dialog. 24 characters to work with and it's required. callback_id : str...
def food(f,num): """jfehfiehfioe i fihiohghi""" tip=0.1*f f=f+tip return f/num def movie(m,num): """iiehgf o h ghighighi""" return m/num
def food(f, num): """jfehfiehfioe i fihiohghi""" tip = 0.1 * f f = f + tip return f / num def movie(m, num): """iiehgf o h ghighighi""" return m / num
# by Kami Bigdely WELL_DONE = 900000 MEDIUM = 600000 COOKED_CONSTANT = 0.05 def is_cookeding_criteria_satisfied(time, temperature, pressure, desired_state): cooked_level = time * temperature * pressure * COOKED_CONSTANT if desired_state == 'well-done' and cooked_level >= WELL_DONE: return True if...
well_done = 900000 medium = 600000 cooked_constant = 0.05 def is_cookeding_criteria_satisfied(time, temperature, pressure, desired_state): cooked_level = time * temperature * pressure * COOKED_CONSTANT if desired_state == 'well-done' and cooked_level >= WELL_DONE: return True if desired_state == 'm...
class MediaTag(object): # ndb keys are based on these! Don't change! CHAIRMANS_VIDEO = 0 CHAIRMANS_PRESENTATION = 1 CHAIRMANS_ESSAY = 2 tag_names = { CHAIRMANS_VIDEO: 'Chairman\'s Video', CHAIRMANS_PRESENTATION: 'Chairman\'s Presentation', CHAIRMANS_ESSAY: 'Chairman\'s Essay...
class Mediatag(object): chairmans_video = 0 chairmans_presentation = 1 chairmans_essay = 2 tag_names = {CHAIRMANS_VIDEO: "Chairman's Video", CHAIRMANS_PRESENTATION: "Chairman's Presentation", CHAIRMANS_ESSAY: "Chairman's Essay"} tag_url_names = {CHAIRMANS_VIDEO: 'chairmans_video', CHAIRMANS_PRESENTA...
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( A , arr_size , sum ) : for i in range ( 0 , arr_size - 2 ) : for j in range ( i + 1 , arr_size - 1 ) : ...
def f_gold(A, arr_size, sum): for i in range(0, arr_size - 2): for j in range(i + 1, arr_size - 1): for k in range(j + 1, arr_size): if A[i] + A[j] + A[k] == sum: print('Triplet is', A[i], ', ', A[j], ', ', A[k]) return True return Fals...
#!/usr/bin/env python # -*- coding: utf-8 -*- # This file is part of civicjson. # https://github.com/DCgov/civic.json-cli # Licensed under the CC0-1.0 license: # https://creativecommons.org/publicdomain/zero/1.0/ # Copyright (c) 2016, Emanuel Feld <elefbet@gmail.com> __version__ = '0.1.1' # NOQA
__version__ = '0.1.1'
"""Constants.""" CACHE_NAME = 'web_mirror' CACHE_TIMEOUT = 3600
"""Constants.""" cache_name = 'web_mirror' cache_timeout = 3600
try: i=0/0 f=open("abc.txt") for line in f: print(line) # except: # print("why with me") except Exception as e: print(e) # except FileNotFoundError: # print("file not found") # except ZeroDivisionError: # print("divided by 0 bro") # except (FileNotFoundError,ZeroDivisionError): # ...
try: i = 0 / 0 f = open('abc.txt') for line in f: print(line) except Exception as e: print(e)
""" Given a collection of distinct numbers, return all possible permutations. For example, [1,2,3] have the following permutations: [ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1] ] """ def permute(elements): """ returns a list with the permuations. """ if len(elements) <= 1: ...
""" Given a collection of distinct numbers, return all possible permutations. For example, [1,2,3] have the following permutations: [ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1] ] """ def permute(elements): """ returns a list with the permuations. """ if len(elements) <= 1: ...
# V0 # https://github.com/yennanliu/CS_basics/blob/master/leetcode_python/Linked_list/reverse-linked-list.py # TO VALIDATE class Solution(object): def sortList(self, head): head_list = [] while head: head_list.append(head.value) head = head.next head_list = sorted(...
class Solution(object): def sort_list(self, head): head_list = [] while head: head_list.append(head.value) head = head.next head_list = sorted(head_list) p = head for i in head_list: p.value = i p = p.next return head ...
def is_prime(num): prime_counter = 1 for x in range(1, num): if num % x == 0: prime_counter += 1 if prime_counter > 2: return False return True primes = [] i = 1 p = 0 n = 10001 while p != n+1: if is_prime(i): primes.append(i) p += 1 i += 1 ...
def is_prime(num): prime_counter = 1 for x in range(1, num): if num % x == 0: prime_counter += 1 if prime_counter > 2: return False return True primes = [] i = 1 p = 0 n = 10001 while p != n + 1: if is_prime(i): primes.append(i) p += 1 i += 1 p...
# -*- coding: utf-8 -*- """ idfy_rest_client.models.eiendeler_foretak This file was automatically generated for Idfy by APIMATIC v2.0 ( https://apimatic.io ) """ class EiendelerForetak(object): """Implementation of the 'EiendelerForetak' model. TODO: type model description here. ...
""" idfy_rest_client.models.eiendeler_foretak This file was automatically generated for Idfy by APIMATIC v2.0 ( https://apimatic.io ) """ class Eiendelerforetak(object): """Implementation of the 'EiendelerForetak' model. TODO: type model description here. Attributes: regnskaps_av_ar_fiel...
def read_csv(logfile): result = {} lines = [] with open(logfile) as f: for line in f.readlines(): l_clean = [float(x) for x in line.strip().split()] lines.append(l_clean) column_data = zip(*lines) labels = [ "index", "defocus1", "defocus2", ...
def read_csv(logfile): result = {} lines = [] with open(logfile) as f: for line in f.readlines(): l_clean = [float(x) for x in line.strip().split()] lines.append(l_clean) column_data = zip(*lines) labels = ['index', 'defocus1', 'defocus2', 'astig', 'azimuth_astig', 'p...
def multiply(*args): ret = 1 for a in args: ret *= a return ret def return_if_jake(**kwargs): if not 'jake' in kwargs.keys(): return False return kwargs['jake'] def call_with_42(func): return func(42) def call_with_42_and_more(func, *args): return func(42, *args) def get_water_function(): def...
def multiply(*args): ret = 1 for a in args: ret *= a return ret def return_if_jake(**kwargs): if not 'jake' in kwargs.keys(): return False return kwargs['jake'] def call_with_42(func): return func(42) def call_with_42_and_more(func, *args): return func(42, *args) def get_...
#!/usr/bin/python3 f = open("day1-input.txt", "r") finput = f.read().split("\n") found = False for i in finput: for x in finput: if x == '': break for y in finput: if y == '': break product = int(i) + int(x) + int(y) if product == 202...
f = open('day1-input.txt', 'r') finput = f.read().split('\n') found = False for i in finput: for x in finput: if x == '': break for y in finput: if y == '': break product = int(i) + int(x) + int(y) if product == 2020: re...
# # This file contains the Python code from Program 16.13 of # "Data Structures and Algorithms # with Object-Oriented Design Patterns in Python" # by Bruno R. Preiss. # # Copyright (c) 2003 by Bruno R. Preiss, P.Eng. All rights reserved. # # http://www.brpreiss.com/books/opus7/programs/pgm16_13.txt # class Digraph(Gra...
class Digraph(Graph): def get_is_strongly_connected(self): for v in xrange(self.numberOfVertices): visitor = self.CountingVisitor() self.depthFirstTraversal(pre_order(visitor), v) if visitor.count != self.numberOfVertices: return False return True
pattern_zero=[0.0, 0.0135109777, 0.0266466504, 0.0273972603, 0.0394070182, 0.0409082379, 0.0517920811, 0.0540439107, 0.0547945205, 0.063801839, 0.0668042785, 0.0683054982, 0.075436292, 0.0791893413, 0.081441171, 0.0821917808, 0.08669544, 0.0911990993, 0.0942015388, 0.0957027585, 0.0975792832, 0.1028335523, 0.1065866016...
pattern_zero = [0.0, 0.0135109777, 0.0266466504, 0.0273972603, 0.0394070182, 0.0409082379, 0.0517920811, 0.0540439107, 0.0547945205, 0.063801839, 0.0668042785, 0.0683054982, 0.075436292, 0.0791893413, 0.081441171, 0.0821917808, 0.08669544, 0.0911990993, 0.0942015388, 0.0957027585, 0.0975792832, 0.1028335523, 0.10658660...
def is_valid(input_line: str) -> bool: min_max, pass_char, password = input_line.split(' ') min_count, max_count = [int(i) for i in min_max.split('-')] pass_char = pass_char.rstrip(':') char_count = 0 for char in password: if char == pass_char: char_count += 1 if char_count >= min...
def is_valid(input_line: str) -> bool: (min_max, pass_char, password) = input_line.split(' ') (min_count, max_count) = [int(i) for i in min_max.split('-')] pass_char = pass_char.rstrip(':') char_count = 0 for char in password: if char == pass_char: char_count += 1 if char_cou...
# Copyright 2020 The Bazel Authors. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable la...
"""Macros for defining external repositories for Debian system installed libraries.""" load('//tools/distributions:system_repo.bzl', 'system_repo') def debian_deps(): debian_java_deps() debian_cc_deps() debian_proto_deps() debian_bin_deps() def debian_java_deps(): system_repo(name='debian_java_dep...
EDINGCNC_VERSION = "CNC V4.03.52" EDINGCNC_MAJOR_VERSION = 4 CNC_EPSILON = (0.00001) CNC_EPSILON_EPSILON = (1e-33) CNC_MAGIC_NOTUSED_DOUBLE = -1.0e10 CNC_MAGIC_ZERO = 1.0e-33 CNC_DOUBLE_FUZZ = 2.2204460492503131e-16 CNC_FULL_CIRCLE_FUZZ_STANDARD = (0.000001) CNC_PI = 3.1415926535897932384626433832795029 CNC_PI2 = (CNC...
edingcnc_version = 'CNC V4.03.52' edingcnc_major_version = 4 cnc_epsilon = 1e-05 cnc_epsilon_epsilon = 1e-33 cnc_magic_notused_double = -10000000000.0 cnc_magic_zero = 1e-33 cnc_double_fuzz = 2.220446049250313e-16 cnc_full_circle_fuzz_standard = 1e-06 cnc_pi = 3.141592653589793 cnc_pi2 = CNC_PI / 2.0 cnc_two_pi = CNC_P...