content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
# Question 9: Write a program that asks the user for an integer and creates a list that consists of the factors # (divisors) of that integer. num = int(input("enter a number")) L = [] for i in range(num): if i %num ==0: L.append(i) print(L)
num = int(input('enter a number')) l = [] for i in range(num): if i % num == 0: L.append(i) print(L)
class ConstLanguage(): """class for storing all const Language""" MENU_RIG = 10 MENU_RIG_NEW = 11 MENU_RIG_REFRESH = 12 MENU_RIG_RENAME = 13 MENU_RIG_DELETE_CURRENT = 14 MENU_RIG_DELETE_ALL = 15 MENU_RIG_CHANGE_FOLDER = 16 MENU_RIG_OPTIONS = 20 MENU_RIG_OPTIONS_IMPORT = 21 ...
class Constlanguage: """class for storing all const Language""" menu_rig = 10 menu_rig_new = 11 menu_rig_refresh = 12 menu_rig_rename = 13 menu_rig_delete_current = 14 menu_rig_delete_all = 15 menu_rig_change_folder = 16 menu_rig_options = 20 menu_rig_options_import = 21 menu...
def test(): # Here we can either check objects created in the solution code, or the # string value of the solution, available as __solution__. A helper for # printing formatted messages is available as __msg__. See the testTemplate # in the meta.json for details. # If an assertion fails, the messag...
def test(): assert 'random_state=33', 'Make sure you are settting the random state to 33 when splittting the data.' assert 'test_size=0.2' in __solution__, 'Make sure you are doing a 20-80 split.' assert 'DecisionTreeClassifier' in __solution__, "Make sure you are specifying a 'DecisionTreeClassifier'." ...
def quicksort(l): if l: left = [x for x in l if x < l[0]] right = [x for x in l if x > l[0]] if len(left) > 1: left = quicksort(left) if len(right) > 1: right = quicksort(right) return left + [l[0]] * l.count(l[0]) + right return [] def q...
def quicksort(l): if l: left = [x for x in l if x < l[0]] right = [x for x in l if x > l[0]] if len(left) > 1: left = quicksort(left) if len(right) > 1: right = quicksort(right) return left + [l[0]] * l.count(l[0]) + right return [] def quicksort2...
#this file should contain all the sample date, location, concentration, species information for samples wanting to #be included in the HYCOM model runs #common locations: #IFCB in Port Aransas, TX: -97.0318, 27.8304 #South Padre Island, TX: -97.05, 26.078 #Galveston, TX: -94.66, 29.28 #I'm having to add a fifth eleme...
species_list = {'Kbrevis': 0, 'Dinophysis': 1, 'Ptexanum': 2, 'Pminimum': 3, 'Asterionellopsis': 4, 'Thalassionema': 5} extra_bloom_dates = {(2009, 183, 3): [[-97.0318, 27.8304, 3, 3, 4], [-97.0318, 27.8304, 3, 5, 5]], (2010, 1, 3): [[-97.0318, 27.8304, 3, 5, 0], [-97.0318, 27.8304, 3, 7, 3], [-97.0318, 27.8304, 3, 3, ...
#!/usr/bin/env python # Beginning of Chinese Range: 11904 (traditional), 19968 (simplified?) for i in range(1, 100000): s = '\\u%04x'%(i,) print(' ', chr(i), ' ', i, s)
for i in range(1, 100000): s = '\\u%04x' % (i,) print(' ', chr(i), ' ', i, s)
''' https://leetcode.com/contest/weekly-contest-175/problems/maximum-students-taking-exam/ ''' class Solution: def maxStudents(self, seats: List[List[str]]) -> int: n, m = len(seats), len(seats[0]) rows = [] for r in seats: br = 0 for s in r: ...
""" https://leetcode.com/contest/weekly-contest-175/problems/maximum-students-taking-exam/ """ class Solution: def max_students(self, seats: List[List[str]]) -> int: (n, m) = (len(seats), len(seats[0])) rows = [] for r in seats: br = 0 for s in r: br...
# Animal class class Animal(object): """ preceding variable with __ makes them private that means if we want to use them we first need to create a function in this class """ __name = "" __height = 0 __weight = 0 __sound = 0 # constructor def __init__(self, name, height, weight,...
class Animal(object): """ preceding variable with __ makes them private that means if we want to use them we first need to create a function in this class """ __name = '' __height = 0 __weight = 0 __sound = 0 def __init__(self, name, height, weight, sound): self.__name = nam...
set_name(0x80137B7C, "EA_cd_seek", SN_NOWARN) set_name(0x80137BA4, "MY_CdGetSector", SN_NOWARN) set_name(0x80137BD8, "init_cdstream", SN_NOWARN) set_name(0x80137BE8, "flush_cdstream", SN_NOWARN) set_name(0x80137C0C, "check_complete_frame", SN_NOWARN) set_name(0x80137C8C, "reset_cdstream", SN_NOWARN) set_name(0x80137CB4...
set_name(2148760444, 'EA_cd_seek', SN_NOWARN) set_name(2148760484, 'MY_CdGetSector', SN_NOWARN) set_name(2148760536, 'init_cdstream', SN_NOWARN) set_name(2148760552, 'flush_cdstream', SN_NOWARN) set_name(2148760588, 'check_complete_frame', SN_NOWARN) set_name(2148760716, 'reset_cdstream', SN_NOWARN) set_name(2148760756...
# Copyright 2021 Cory Paik. 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 law or ag...
""" PyType Integration Macros""" load('@rules_python//python:defs.bzl', _py_binary='py_binary', _py_library='py_library', _py_test='py_test') def py_binary(name, python_version='PY3', srcs_version='PY3', **kwargs): _py_binary(name=name, srcs_version=srcs_version, python_version=python_version, **kwargs) def py_li...
coins = [1, 2, 5, 10, 20, 50, 100, 200] amount = 200 ways = [0] * (amount + 1) ways[0] = 1 for coin in coins: for n in range(coin, amount + 1): ways[n] += ways[n - coin] print(ways[amount])
coins = [1, 2, 5, 10, 20, 50, 100, 200] amount = 200 ways = [0] * (amount + 1) ways[0] = 1 for coin in coins: for n in range(coin, amount + 1): ways[n] += ways[n - coin] print(ways[amount])
# Simple read() method around a bytearray class BytesBuffer(): def __init__(self, b): self.buf = b self.readCount = 0 def count(self): return self.readCount def reset_count(self): self.readCount = 0 def size(self): return len(self.buf) def peek(self): ...
class Bytesbuffer: def __init__(self, b): self.buf = b self.readCount = 0 def count(self): return self.readCount def reset_count(self): self.readCount = 0 def size(self): return len(self.buf) def peek(self): return self.buf[0] def write(self,...
# Schemas corresponding to Myrial examples { 'public:adhoc:sp2bench' : [('subject', 'STRING_TYPE'), ('predicate','STRING_TYPE'), ('object','STRING_TYPE')], }
{'public:adhoc:sp2bench': [('subject', 'STRING_TYPE'), ('predicate', 'STRING_TYPE'), ('object', 'STRING_TYPE')]}
# Python function to find a range of primes def findprimes(min, max): for Number in range(min, max + 1): count = 0 for i in range(2, (Number // 2 + 1)): if (Number % i == 0): count = count + 1 break if (count == 0 and Number != 1): prin...
def findprimes(min, max): for number in range(min, max + 1): count = 0 for i in range(2, Number // 2 + 1): if Number % i == 0: count = count + 1 break if count == 0 and Number != 1: print(' %d' % Number, end=' ') print() def primes():...
{ "targets": [ { "target_name": "mozporter", "type": "shared_library", "sources": [ "vendor/Normalize.c", "vendor/fts3_porter.c", "vendor/rank.m" ], 'dependencies': ["./node_modules/better-sqlite3/deps/sqlite3.gyp:sqlite3"], 'cflags': [ '-std=c99...
{'targets': [{'target_name': 'mozporter', 'type': 'shared_library', 'sources': ['vendor/Normalize.c', 'vendor/fts3_porter.c', 'vendor/rank.m'], 'dependencies': ['./node_modules/better-sqlite3/deps/sqlite3.gyp:sqlite3'], 'cflags': ['-std=c99', '-Wno-unused-function', '-Wno-sign-compare'], 'xcode_settings': {'OTHER_CFLAG...
b=int(input())#bot's answer a=int(input())#student's answer if (b == 1 and b!=a) or (a==1 and a!=b): print("NO") if (a != 1 and b != 1) or (b==1 and a==1): print("YES")
b = int(input()) a = int(input()) if b == 1 and b != a or (a == 1 and a != b): print('NO') if a != 1 and b != 1 or (b == 1 and a == 1): print('YES')
""" Marker class to allow registrations, DI, and type hinting for subclasses. """ class Adapter: """ Marker adapter all adapters are expected to subclass from """ pass
""" Marker class to allow registrations, DI, and type hinting for subclasses. """ class Adapter: """ Marker adapter all adapters are expected to subclass from """ pass
def pluralize(num,word): if num == 1: print("1 {}".format(word)) else: plural = "" if word[-2:] == "fe": plural = word[:-2] + "ves" elif word[-2:] == "ey" or word[-2:] == "ay" or word[-2:] == "uy" or word[-2:] == "oy": plural = word + "s" elif word...
def pluralize(num, word): if num == 1: print('1 {}'.format(word)) else: plural = '' if word[-2:] == 'fe': plural = word[:-2] + 'ves' elif word[-2:] == 'ey' or word[-2:] == 'ay' or word[-2:] == 'uy' or (word[-2:] == 'oy'): plural = word + 's' elif w...
""" File: exercise_4.5.py Author: William Gatharia This code demonstrates reading text from a text file. """ file_name = input("Enter file to read:") file = open(file_name, 'r') while True: line = file.readline() if line == "": break print(line.strip())
""" File: exercise_4.5.py Author: William Gatharia This code demonstrates reading text from a text file. """ file_name = input('Enter file to read:') file = open(file_name, 'r') while True: line = file.readline() if line == '': break print(line.strip())
""" ..module: Generator - help to guess the riddled number - the basis to play "Bools&Cows" with computer ..author: Sergey Sumburov <sumburovsn@gmail.com> """ # trialLog dictionary keeps all the responses of the current session of the game # in form "attempt: response" game_log = { '81...
""" ..module: Generator - help to guess the riddled number - the basis to play "Bools&Cows" with computer ..author: Sergey Sumburov <sumburovsn@gmail.com> """ game_log = {'8134': 'B0 C1'} class Attempt: """ class Attempt for easy sorting the optimal request based on the amount of possible...
__author__ = "Robert Kist" # QLineEdit lineedit_style = ''' QLineEdit { background: palette(dark); border-radius: 5px; height: 22px; min-height: 22px; max-height: 22px; margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; border: 2px solid transparent; } Q...
__author__ = 'Robert Kist' lineedit_style = '\nQLineEdit {\n background: palette(dark);\n border-radius: 5px;\n height: 22px;\n min-height: 22px;\n max-height: 22px;\n margin-top: 0px;\n margin-bottom: 0px;\n margin-left: 0px;\n margin-right: 0px;\n border: 2px solid transparent;\n}\n\nQLi...
"""Setup script for CWLite/1200 with XMEGA (CW303/CW308-XMEGA/CWLite target) Configures scope settings to prepare for capturing SimpleSerial power traces """ # GUI compatibility try: scope = self.scope except NameError: pass scope.gain.gain = 45 scope.adc.samples = 25000 scope.adc.offset = 0 scope.adc.ba...
"""Setup script for CWLite/1200 with XMEGA (CW303/CW308-XMEGA/CWLite target) Configures scope settings to prepare for capturing SimpleSerial power traces """ try: scope = self.scope except NameError: pass scope.gain.gain = 45 scope.adc.samples = 25000 scope.adc.offset = 0 scope.adc.basic_mode = 'rising_edge' s...
# -------------- class_1 = ['Geoffrey Hinton','Andrew Ng','Sebastian Raschka','Yoshua Bengio'] class_2 = ['Hilary Mason','Carla Gentry','Corinna Cortes'] new_class = class_1 + class_2 print(new_class) new_class.append('Peter Warden') print(new_class) new_class.remove('Carla Gentry') print(new_class) courses = {...
class_1 = ['Geoffrey Hinton', 'Andrew Ng', 'Sebastian Raschka', 'Yoshua Bengio'] class_2 = ['Hilary Mason', 'Carla Gentry', 'Corinna Cortes'] new_class = class_1 + class_2 print(new_class) new_class.append('Peter Warden') print(new_class) new_class.remove('Carla Gentry') print(new_class) courses = {'Math': 65, 'English...
def assert_browsing_context(info, children, context, url, parent=None): assert "children" in info if children is not None: assert isinstance(info["children"], list) assert info["children"] == children assert "context" in info assert isinstance(info["context"], str) # TODO: Always check ...
def assert_browsing_context(info, children, context, url, parent=None): assert 'children' in info if children is not None: assert isinstance(info['children'], list) assert info['children'] == children assert 'context' in info assert isinstance(info['context'], str) if context is not None...
# -*- coding: utf-8 -*- def pi(N=2**7): pi = 0 for n in range(0, N + 1): pi += 1 / (16**n) * (4 / (8 * n + 1) - 2 / (8 * n + 4) - 1 / (8 * n + 5) - 1 / (8 * n + 6)) return pi
def pi(N=2 ** 7): pi = 0 for n in range(0, N + 1): pi += 1 / 16 ** n * (4 / (8 * n + 1) - 2 / (8 * n + 4) - 1 / (8 * n + 5) - 1 / (8 * n + 6)) return pi
# You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed. All houses at this place are arranged in a circle. That means the first house is the neighbor of the last one. Meanwhile, adjacent houses have security system connected and it will automatically cont...
class Solution(object): def rob(self, nums): """ :type nums: List[int] :rtype: int """ if len(nums) == 0: return 0 if len(nums) <= 2: return max(nums) rob1 = self.helper(nums, 0) rob2 = self.helper(nums, 1) return max(r...
#Config MYSQL_HOST = 'dockerMysql' MYSQL_PORT = 3306 MYSQL_USER = 'ssuser' MYSQL_PASS = 'sspasswd' MYSQL_DB = 'sspanel' MANAGE_PASS = 'ss233333333' #if you want manage in other server you should set this value to global ip MANAGE_BIND_IP = '127.0.0.1' #make sure this port is idle MANAGE_PORT = 23333
mysql_host = 'dockerMysql' mysql_port = 3306 mysql_user = 'ssuser' mysql_pass = 'sspasswd' mysql_db = 'sspanel' manage_pass = 'ss233333333' manage_bind_ip = '127.0.0.1' manage_port = 23333
''' Sum of number from 1 to n return 1 + 2 + 3 + 4 + .... + (n-1) + n ''' # # TRUST the function # def sum_n(n): # if(n == 1): # Or base case could be 0 --> return 0 # return 1 # left_part = sum_n(n-1) # print(f"Left Part is {left_part}") # return left_part + n ''' Sum of Digit of th...
""" Sum of number from 1 to n return 1 + 2 + 3 + 4 + .... + (n-1) + n """ '\nSum of Digit of the number \n\nINPUT : 12344\nOUTPUT : 1 + 2 + 3 + 4 + 5 = 15\n\n1234 + 5\n\n' def digit_sum(n): if n == 0: return 0 last_digit = n % 10 remaining_part = n // 10 return digit_sum(remaining_p...
""" cloudscheduler is a module that contains various cloud connection classes for starting virtual machines in the cloud in conjuction with HTCondor to assemble a distributed computing resource for batch jobs. """
""" cloudscheduler is a module that contains various cloud connection classes for starting virtual machines in the cloud in conjuction with HTCondor to assemble a distributed computing resource for batch jobs. """
# program globals # initLoadDir = "" # should be something like initLoadDir = <get dir from program state save file> initSaveDir = "" # should be something like initSaveDir = <get dir from program state save file> initVidFmt = "" initAudFmt = "" def updateUserData(loadDir="./", saveDir="./", vidFmt=None, audFmt=Non...
init_load_dir = '' init_save_dir = '' init_vid_fmt = '' init_aud_fmt = '' def update_user_data(loadDir='./', saveDir='./', vidFmt=None, audFmt=None): global initLoadDir, initSaveDir, initVidFmt, initAudFmt with open('data.txt', 'r+') as f: current_save_data = f.read().split('\n') init_save_dir ...
# O(n^2) time | O(1) space def selectionSort(array): currentIdx = 0 while currentIdx < len(array) -1: smallestIdx = currentIdx for i in range(currentIdx + 1, len(array)): if array[smallestIdx] > array[i]: smallestIdx = i array[smallestIdx], array[currentIdx] =...
def selection_sort(array): current_idx = 0 while currentIdx < len(array) - 1: smallest_idx = currentIdx for i in range(currentIdx + 1, len(array)): if array[smallestIdx] > array[i]: smallest_idx = i (array[smallestIdx], array[currentIdx]) = (array[currentIdx],...
class Node: def __init__(self,data): self.data = data self.left = self.right = None def utility(root,ans): if root is None: return 0 ## get the sum of tree using function currsum = (root.data + utility(root.left,ans) + utility(root.right,ans)) ans[0] = max(ans...
class Node: def __init__(self, data): self.data = data self.left = self.right = None def utility(root, ans): if root is None: return 0 currsum = root.data + utility(root.left, ans) + utility(root.right, ans) ans[0] = max(ans[0], currsum) return currsum def find_largest(roo...
class Solution: def spiralOrder(self, matrix: List[List[int]]) -> List[int]: ans = [] while matrix: ans += matrix.pop(0) # Rotate matrix = list(zip(*matrix))[::-1] return ans
class Solution: def spiral_order(self, matrix: List[List[int]]) -> List[int]: ans = [] while matrix: ans += matrix.pop(0) matrix = list(zip(*matrix))[::-1] return ans
# AUTHOR: Sanket Khadse # Python3 Concept: Find first and last positions of an element in a sorted array # GITHUB: https://github.com/edusanketdk def sol_1(ar: list, x: int) -> tuple: """using index function""" return (ar.index(x), len(ar)-ar[::-1].index(x)-1) if x in ar else (-1, -1) def sol_2(ar: list, x:...
def sol_1(ar: list, x: int) -> tuple: """using index function""" return (ar.index(x), len(ar) - ar[::-1].index(x) - 1) if x in ar else (-1, -1) def sol_2(ar: list, x: int) -> tuple: """using single traversal""" (f, l) = (-1, -1) for i in range(len(ar)): if ar[i] == x: if f == -1...
# brute force, dynamic programing O(n^2) def max_area(height): max_area = 0 for j in range(1, len(height)): for i in range(j-1, -1, -1): area = min(height[i], height[j]) * (j - i) max_area = max(max_area, area) return max_area ''' If we try to move the pointer at t...
def max_area(height): max_area = 0 for j in range(1, len(height)): for i in range(j - 1, -1, -1): area = min(height[i], height[j]) * (j - i) max_area = max(max_area, area) return max_area "\nIf we try to move the pointer at the longer line inwards, we won't gain any increase ...
class Namespace: """A shortcut for defining a namespace with a prefix. Attributes: uri: The full uri of the namespace. prefix: Name of the prefix that will be used. """ uri = None prefix = None def __str__(self): return self.prefix class Uri: """A shortcut for co...
class Namespace: """A shortcut for defining a namespace with a prefix. Attributes: uri: The full uri of the namespace. prefix: Name of the prefix that will be used. """ uri = None prefix = None def __str__(self): return self.prefix class Uri: """A shortcut for cons...
# -*- coding: utf-8 -*- """ A base class for pipable objects """ class Pipable(object): """ A class for pipable objects """ def __init__(self, this, parent=None): super(Pipable, self).__init__() self.this = this self.call = this self.parent = parent def pipe(self, other): ...
""" A base class for pipable objects """ class Pipable(object): """ A class for pipable objects """ def __init__(self, this, parent=None): super(Pipable, self).__init__() self.this = this self.call = this self.parent = parent def pipe(self, other): """ Piping the o...
# # Metrix++, Copyright 2009-2019, Metrix++ Project # Link: https://github.com/metrixplusplus/metrixplusplus # # This file is a part of Metrix++ Tool. # # Copied from http://code.activestate.com/recipes/577268-python-data-structure-to-xml-serialization/ # - indent feature and better formatting...
indent_space_symbol = ' ' '\nPy2XML - Python to XML serialization\n\nThis code transforms a Python data structures into an XML document\n\nUsage:\n serializer = Py2XML()\n xml_string = serializer.parse( python_object )\n print python_object\n print xml_string\n' class Py2Xml: digit_count = 0 de...
def levenshtein_distance(word1: str, word2: str) -> int: small = word1 if len(word1) < len(word2) else word2 big = word1 if len(word1) >= len(word2) else word2 even_edits = [x for x in range(len(small) + 1)] odd_edits = [_ for _ in range(len(small) + 1)] for row in range(1, len(big) + 1): if...
def levenshtein_distance(word1: str, word2: str) -> int: small = word1 if len(word1) < len(word2) else word2 big = word1 if len(word1) >= len(word2) else word2 even_edits = [x for x in range(len(small) + 1)] odd_edits = [_ for _ in range(len(small) + 1)] for row in range(1, len(big) + 1): if...
n = int(input()) b = [] for i in range(30): i += 2 s = i*i while s <= 1000: b.append(s) s = s*i answer = 1 for i in range(len(b)): if b[i] <= n and answer < b[i]: answer = b[i] print(answer)
n = int(input()) b = [] for i in range(30): i += 2 s = i * i while s <= 1000: b.append(s) s = s * i answer = 1 for i in range(len(b)): if b[i] <= n and answer < b[i]: answer = b[i] print(answer)
#!/usr/bin/python # if_kwd.py age = 17 if age > 18: print ("Driving licence issued") else: print ("Driving licence not permitted")
age = 17 if age > 18: print('Driving licence issued') else: print('Driving licence not permitted')
""" @generated cargo-raze generated Bazel file. DO NOT EDIT! Replaced on runs of cargo-raze """ load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository") # buildifier: disable=load load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") # buildifier: disable=load load("@bazel_tools//too...
""" @generated cargo-raze generated Bazel file. DO NOT EDIT! Replaced on runs of cargo-raze """ load('@bazel_tools//tools/build_defs/repo:git.bzl', 'new_git_repository') load('@bazel_tools//tools/build_defs/repo:http.bzl', 'http_archive') load('@bazel_tools//tools/build_defs/repo:utils.bzl', 'maybe') def rules_rust_w...
""" Lists builtin plugins. """ plugins = [] builtins = ( ('nose.plugins.attrib', 'AttributeSelector'), ('nose.plugins.capture', 'Capture'), ('nose.plugins.logcapture', 'LogCapture'), ('nose.plugins.cover', 'Coverage'), ('nose.plugins.debug', 'Pdb'), ('nose.plugins.deprecated', 'Deprecated'), ...
""" Lists builtin plugins. """ plugins = [] builtins = (('nose.plugins.attrib', 'AttributeSelector'), ('nose.plugins.capture', 'Capture'), ('nose.plugins.logcapture', 'LogCapture'), ('nose.plugins.cover', 'Coverage'), ('nose.plugins.debug', 'Pdb'), ('nose.plugins.deprecated', 'Deprecated'), ('nose.plugins.doctests', 'D...
def fail(request, domain): # if you want to play with it, wire this to a url raise Exception("HQ Couchlog simulated failure in domain %s!" % domain)
def fail(request, domain): raise exception('HQ Couchlog simulated failure in domain %s!' % domain)
class Solution(object): def productExceptSelf(self, nums): """ :type nums: List[int] :rtype: List[int] """ res = [0] * len(nums) total = 1 zeros = 0 zpos = 0 for i in range(len(nums)): if not(nums[i]): zeros += 1 ...
class Solution(object): def product_except_self(self, nums): """ :type nums: List[int] :rtype: List[int] """ res = [0] * len(nums) total = 1 zeros = 0 zpos = 0 for i in range(len(nums)): if not nums[i]: zeros += 1 ...
TMI_TOKEN = "" CLIENT_ID = "" BOT_NICK = "pequeninancientbot" BOT_PREFIX = "!" CHANNEL = "#hector_pulido_" CLIENT_SECRET = ""
tmi_token = '' client_id = '' bot_nick = 'pequeninancientbot' bot_prefix = '!' channel = '#hector_pulido_' client_secret = ''
power = {'BUSES': {'Area': 1.33155, 'Bus/Area': 1.33155, 'Bus/Gate Leakage': 0.00662954, 'Bus/Peak Dynamic': 0.0, 'Bus/Runtime Dynamic': 0.0, 'Bus/Subthreshold Leakage': 0.0691322, 'Bus/Subthreshold Leakage with power gating': 0.0259246, 'Gate...
power = {'BUSES': {'Area': 1.33155, 'Bus/Area': 1.33155, 'Bus/Gate Leakage': 0.00662954, 'Bus/Peak Dynamic': 0.0, 'Bus/Runtime Dynamic': 0.0, 'Bus/Subthreshold Leakage': 0.0691322, 'Bus/Subthreshold Leakage with power gating': 0.0259246, 'Gate Leakage': 0.00662954, 'Peak Dynamic': 0.0, 'Runtime Dynamic': 0.0, 'Subthres...
limit = 500 fib = 0 pFib = 1 print(fib) print(pFib) while pFib < limit: temp = pFib pFib = fib + pFib print(pFib) fib = temp
limit = 500 fib = 0 p_fib = 1 print(fib) print(pFib) while pFib < limit: temp = pFib p_fib = fib + pFib print(pFib) fib = temp
class Solution(object): def maximumProduct(self, nums): """ :type nums: List[int] :rtype: int """ largest_three = [-1003,-1002,-1001] smallest_three = [1003,1002,1001] for i in nums: if i > largest_three[0]: largest_three[0...
class Solution(object): def maximum_product(self, nums): """ :type nums: List[int] :rtype: int """ largest_three = [-1003, -1002, -1001] smallest_three = [1003, 1002, 1001] for i in nums: if i > largest_three[0]: largest_three[0] =...
__all__ = [ "loghandler", "githandler" ]
__all__ = ['loghandler', 'githandler']
# The next lines will make the Pixel Turtle and its heading invisible # and will clear the screen for light show hidePixel() hideHeading() clear() # First we move to the top left corner moveTo(0, 0) right(2) forward(15) right(2) forward(7) right(2) forward(15) right(2) forward(6) right(2) forward(14) right(2) forwar...
hide_pixel() hide_heading() clear() move_to(0, 0) right(2) forward(15) right(2) forward(7) right(2) forward(15) right(2) forward(6) right(2) forward(14) right(2) forward(5) right(2) forward(13) right(2) forward(4) right(2) forward(12) right(2) forward(3) right(2) forward(11) right(2) forward(2) right(2) forward(10) rig...
wiz.response.render('/auth/login', "page.signin") wiz.response.render('/auth/join', "page.signup") if wiz.match("/auth/logout") is not None: if wiz.session.has("id"): wiz.session.clear() wiz.response.redirect("/auth/login") if wiz.session.has("id"): wiz.response.redirect("/") wiz.response.redirec...
wiz.response.render('/auth/login', 'page.signin') wiz.response.render('/auth/join', 'page.signup') if wiz.match('/auth/logout') is not None: if wiz.session.has('id'): wiz.session.clear() wiz.response.redirect('/auth/login') if wiz.session.has('id'): wiz.response.redirect('/') wiz.response.redirect('...
# Created by yingwen at 2019-03-10 def IGA(pi_alpha, pi_beta, payoff_0, payoff_1, u_alpha, u_beta, iteration=1000, lr=0.01): pi_alpha_history = [pi_alpha] pi_beta_history = [pi_beta] pi_alpha_gradient_history = [0.] pi_beta_gradient_history = [0.]...
def iga(pi_alpha, pi_beta, payoff_0, payoff_1, u_alpha, u_beta, iteration=1000, lr=0.01): pi_alpha_history = [pi_alpha] pi_beta_history = [pi_beta] pi_alpha_gradient_history = [0.0] pi_beta_gradient_history = [0.0] for i in range(iteration): pi_alpha_gradient = pi_beta * u_alpha + payoff_0[0...
def main(): a = input().strip() b = input().strip() print(number_needed(a, b)) def number_needed(a, b): sort_a = sorted(a) sort_b = sorted(b) a_len = len(sort_a) b_len = len(sort_b) if a_len < 1: return b_len elif b_len < 1: return a_len else: num_need...
def main(): a = input().strip() b = input().strip() print(number_needed(a, b)) def number_needed(a, b): sort_a = sorted(a) sort_b = sorted(b) a_len = len(sort_a) b_len = len(sort_b) if a_len < 1: return b_len elif b_len < 1: return a_len else: num_needed ...
class StreamingMetric: ''' Class for updating measurement mean and variance statistics in an online fashion using a moving (and possibly decaying) average Parameters ---------- decay: float or None Decay value between 0 and 1 for measurement updates. Higher values mean older ...
class Streamingmetric: """ Class for updating measurement mean and variance statistics in an online fashion using a moving (and possibly decaying) average Parameters ---------- decay: float or None Decay value between 0 and 1 for measurement updates. Higher values mean older ...
def owl_count(text): owl_count = 0 char_check = 0 realText = text.lower() for char in list(realText): if char == 'o' or char == 'w' or char == 'l': char_check += 1 if char_check == 3: owl_count += 1 else: char_check = 0 print(owl_co...
def owl_count(text): owl_count = 0 char_check = 0 real_text = text.lower() for char in list(realText): if char == 'o' or char == 'w' or char == 'l': char_check += 1 if char_check == 3: owl_count += 1 else: char_check = 0 print(owl_c...
with open('input') as f: lines = f.readlines() count = 0 for l in lines: if l[0] == '+': count += int(l[1:]) else: count -= int(l[1:]) print(count)
with open('input') as f: lines = f.readlines() count = 0 for l in lines: if l[0] == '+': count += int(l[1:]) else: count -= int(l[1:]) print(count)
# Copyright Google Inc. All Rights Reserved. # # Use of this source code is governed by an MIT-style license that can be # found in the LICENSE file at https://angular.io/license "Install toolchain dependencies" load("@build_bazel_rules_nodejs//:defs.bzl", "yarn_install") load("@build_bazel_rules_typescript//:defs.bz...
"""Install toolchain dependencies""" load('@build_bazel_rules_nodejs//:defs.bzl', 'yarn_install') load('@build_bazel_rules_typescript//:defs.bzl', 'check_rules_typescript_version') def ng_setup_workspace(): """This repository rule should be called from your WORKSPACE file. It creates some additional Bazel ext...
N, *a = map(int, open(0).read().split()) pos = [0] * (N + 1) for i in range(N): pos[a[i]] = i l = [-1] * N r = [-1] * N result = 0 for x in range(N, 0, -1): i = pos[x] j = i while j != 0 and a[j - 1] > x: j = l[j - 1] l[i] = j j = i while j != N - 1 and a[j + 1] > x: j = ...
(n, *a) = map(int, open(0).read().split()) pos = [0] * (N + 1) for i in range(N): pos[a[i]] = i l = [-1] * N r = [-1] * N result = 0 for x in range(N, 0, -1): i = pos[x] j = i while j != 0 and a[j - 1] > x: j = l[j - 1] l[i] = j j = i while j != N - 1 and a[j + 1] > x: j = r[...
""" Version And Diverse Info **Module CONSTANTS:** __version__ `str` - the released version (last release) RELEASE_DATE `str` - the date of the last release SHORT_VERSION `str` - the main version is the: __version__ stripped of the last part: e.g. used by sphinx conf.py TESTED_HOST_OS `st...
""" Version And Diverse Info **Module CONSTANTS:** __version__ `str` - the released version (last release) RELEASE_DATE `str` - the date of the last release SHORT_VERSION `str` - the main version is the: __version__ stripped of the last part: e.g. used by sphinx conf.py TESTED_HOST_OS `st...
"""Top-level package for msm_we.""" __author__ = """John Russo""" __email__ = 'russojd@ohsu.edu' __version__ = '0.1.0'
"""Top-level package for msm_we.""" __author__ = 'John Russo' __email__ = 'russojd@ohsu.edu' __version__ = '0.1.0'
# _ _ _ # | | | | | | # __ _____| |__ ___| | ___ _ __ ___ ___ _ __ | |_ ___ _ __ _ _ # \ \ /\ / / _ \ '_ \ / _ \ |/ _ \ '_ ` _ \ / _ \ '_ \| __/ __| '_ \| | | | # \ V V / __/ |_) | __/ | ...
__version__ = '0.0.5'
# For sample predict functions for popular libraries visit https://github.com/opendatahub-io/odh-prediction-samples # Import libraries # import tensorflow as tf # Load your model. # model_dir = 'models/myfancymodel' # saved_model = tf.saved_model.load(model_dir) # predictor = saved_model.signatures['default'] # Wri...
def predict(args_dict): return {'prediction': 'not implemented'}
Scale.default = Scale.major Root.default = 0 Clock.bpm = 120 ~n1 >> noise( P(PSine(32),PSine(24),PSine(27),PSine(18)*.7,PSine(45)), amp=P(.8,.7,.8,.7,.9)*.4, delay=P(PRange(5)/5), dur=.5, formant=(linvar([1,3],48), linvar([3,1],53)), chop=linvar([0,16],65), lpf=1200, lpr=(linvar([0,6],6...
Scale.default = Scale.major Root.default = 0 Clock.bpm = 120 ~n1 >> noise(p(p_sine(32), p_sine(24), p_sine(27), p_sine(18) * 0.7, p_sine(45)), amp=p(0.8, 0.7, 0.8, 0.7, 0.9) * 0.4, delay=p(p_range(5) / 5), dur=0.5, formant=(linvar([1, 3], 48), linvar([3, 1], 53)), chop=linvar([0, 16], 65), lpf=1200, lpr=(linvar([0, 6],...
"""About sampler""" __name__ = 'sampler' __version__ = '0.0.1' __author__ = "Tristan R. Brown", __email__ = "brown.tristan.r@gmail.com", __desc__ = "A vector space sampling package.", __license__ = "MIT",
"""About sampler""" __name__ = 'sampler' __version__ = '0.0.1' __author__ = ('Tristan R. Brown',) __email__ = ('brown.tristan.r@gmail.com',) __desc__ = ('A vector space sampling package.',) __license__ = ('MIT',)
def f(): x=2 print("x:",x) #Hauptprogramm x=1 f() print("x:",x)
def f(): x = 2 print('x:', x) x = 1 f() print('x:', x)
""" Given a collection of intervals, find the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping. Note: You may assume the interval's end point is always bigger than its start point. Intervals like [1,2] and [2,3] have borders "touching" but they don't overlap each other. ...
""" Given a collection of intervals, find the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping. Note: You may assume the interval's end point is always bigger than its start point. Intervals like [1,2] and [2,3] have borders "touching" but they don't overlap each other. ...
S = input() result = [] for s in S: if s == 'I' or s == 'l': result.append('1') elif s == 'O' or s == 'o': result.append('0') else: result.append(s) print(''.join(result))
s = input() result = [] for s in S: if s == 'I' or s == 'l': result.append('1') elif s == 'O' or s == 'o': result.append('0') else: result.append(s) print(''.join(result))
n, k = map(int, input().split()) h = [int(input()) for _ in range(n)] h = sorted(h, reverse=True) t = [] for i in range(n - k + 1): t.append(h[i] - h[i + k - 1]) print(min(t))
(n, k) = map(int, input().split()) h = [int(input()) for _ in range(n)] h = sorted(h, reverse=True) t = [] for i in range(n - k + 1): t.append(h[i] - h[i + k - 1]) print(min(t))
def paginate(objects, context): """ yields: page, page_index, total_pages """ DEFAULT_PAGINATION = getattr(context.settings, 'DEFAULT_PAGINATION') object_count = len(objects) if object_count > DEFAULT_PAGINATION: total_pages = ( (object_count - (object_count % ...
def paginate(objects, context): """ yields: page, page_index, total_pages """ default_pagination = getattr(context.settings, 'DEFAULT_PAGINATION') object_count = len(objects) if object_count > DEFAULT_PAGINATION: total_pages = (object_count - object_count % DEFAULT_PAGINATION) // DEFAUL...
# Copyright 2019 Ministry of Education and Culture, Finland # SPDX-License-Identifier: MIT ''' Custom exception classes. ''' class BaseException(Exception): status_code = 500 message = 'something went wrong' def __init__(self, message=None, status_code=None, data=None): super().__init__() ...
""" Custom exception classes. """ class Baseexception(Exception): status_code = 500 message = 'something went wrong' def __init__(self, message=None, status_code=None, data=None): super().__init__() if message is not None: self.message = message if status_code is not No...
# -*- coding: utf-8 -*- class Scope: def apply(self, builder, model): """ Apply the scope to a given query builder. :param builder: The query builder :type builder: orator.orm.Builder :param model: The model :type model: orator.orm.Model """ raise...
class Scope: def apply(self, builder, model): """ Apply the scope to a given query builder. :param builder: The query builder :type builder: orator.orm.Builder :param model: The model :type model: orator.orm.Model """ raise NotImplementedError
#!/usr/bin/env python # # Copyright (c) 2015 Pavel Lazar pavel.lazar (at) gmail.com # # The Software is provided WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED. ##################################################################### SUPPORTED_COMPLEX_MATCH = ['basic'] SUPPORTED_MATCH_FIELDS = ['ETH_SRC', 'ETH_DST', 'ETH_TYPE',...
supported_complex_match = ['basic'] supported_match_fields = ['ETH_SRC', 'ETH_DST', 'ETH_TYPE', 'VLAN_VID', 'VLAN_PCP', 'IPV4_PROTO', 'IPV4_SRC', 'IPV4_DST', 'TCP_SRC', 'TCP_DST', 'UDP_SRC', 'UDP_DST'] supported_protocols = ['ETH', 'VLAN', 'IPV4', 'TCP', 'UDP']
# -*- coding: utf-8 -*- """ @author: Dr Michael GUEDJ Algorithmique -- TP8 -- Mots """ # 2 def concatener(lst): res = lst[0] i = 1 while i < len(lst): res += " "+lst[i] i +=1 return res # 3 def est_present(m, c): for x in m: if x == c: r...
""" @author: Dr Michael GUEDJ Algorithmique -- TP8 -- Mots """ def concatener(lst): res = lst[0] i = 1 while i < len(lst): res += ' ' + lst[i] i += 1 return res def est_present(m, c): for x in m: if x == c: return True return False def est_present_bis(m, c...
def add(a): return len(a) # from tsfresh.feature_extraction.feature_calculators import cid_ce # import pandas as pd # def add(a, b): # data = pd.Series([1, 2, 3, 4, 5, 6, 7, 8]) # data = cid_ce(data, True) # return data
def add(a): return len(a)
#a1z26 cipher by kenny zhang def main(): menu = 'a1z26 cipher menu' print(menu) print('-'*len(menu)) print('[1] cipher a message\n[2] decipher a message\n[3] quit') option = input('\nenter a menu option and ENTER: ') if option == '1': cipher() elif option == '2': ...
def main(): menu = 'a1z26 cipher menu' print(menu) print('-' * len(menu)) print('[1] cipher a message\n[2] decipher a message\n[3] quit') option = input('\nenter a menu option and ENTER: ') if option == '1': cipher() elif option == '2': decipher() else: quit() de...
# # Copyright 2017 Anil Thomas # # 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 t...
""" Configuration settings """ chunk_size = 64 low_thresh = -1100 high_thresh = 500 mask_dilation = 4 resolution = 1.0 file_ext = 'blp' chunks_per_dim = 8
guestlist = ['Barack Obama', 'Stanley Kubrick', 'Thomas Pynchon'] print("This new dinner table, I have, however, now seats 120 dinner guests.") guestlist.insert(0, 'Bill Murray') guestlist.insert(2, 'Stephen King') guestlist.append('Kim Kardashian') message = (f"How does McDonalds sound, {guestlist[0]}?") print(mes...
guestlist = ['Barack Obama', 'Stanley Kubrick', 'Thomas Pynchon'] print('This new dinner table, I have, however, now seats 120 dinner guests.') guestlist.insert(0, 'Bill Murray') guestlist.insert(2, 'Stephen King') guestlist.append('Kim Kardashian') message = f'How does McDonalds sound, {guestlist[0]}?' print(message) ...
''' max Int range in python [-2**31] to [(2**31) -1] ''' class Solution: def reverse(self, x: int) -> int: isNegative = False reverseDigit = 0 if(x < 0): isNegative = True x = -1 * x while(x > 0): lastDigit = x % 10 ...
""" max Int range in python [-2**31] to [(2**31) -1] """ class Solution: def reverse(self, x: int) -> int: is_negative = False reverse_digit = 0 if x < 0: is_negative = True x = -1 * x while x > 0: last_digit = x % 10 reverse_digit...
#!/usr/bin/python # partition.py s = "1 + 2 + 3 = 6" a = s.partition("=") print (a)
s = '1 + 2 + 3 = 6' a = s.partition('=') print(a)
candy_title = input('What is the candy title? ') candy_flavor = input('What is the candy flavor? ') print('It shall be called {0} {1}!'.format(candy_title, candy_flavor))
candy_title = input('What is the candy title? ') candy_flavor = input('What is the candy flavor? ') print('It shall be called {0} {1}!'.format(candy_title, candy_flavor))
"""Class that provides function(s) related to calcuations of Fibonacci numbers. TODO: Add some additional error handling: - How do I handle desiredSequence and ensuring it is an integer. TODO: Overflow handling? TODO: Can I cleanup the calculation """ class Fibonacci: """This class provides Fibonacci...
"""Class that provides function(s) related to calcuations of Fibonacci numbers. TODO: Add some additional error handling: - How do I handle desiredSequence and ensuring it is an integer. TODO: Overflow handling? TODO: Can I cleanup the calculation """ class Fibonacci: """This class provides Fibonacci ...
class File: def directory(self) -> str: pass def name(self) -> str: pass def extension(self) -> str: pass def path(self): return self.directory() + self.name() + self.extension() class FileBase(File): directoryStr = '' nameStr = '' extensionStr = '' ...
class File: def directory(self) -> str: pass def name(self) -> str: pass def extension(self) -> str: pass def path(self): return self.directory() + self.name() + self.extension() class Filebase(File): directory_str = '' name_str = '' extension_str = '' ...
class pointsTrajectory: def __init__(self, points, factor = [1,1]): self.factor = factor self.points = [[-1, 0]] + points + [[1, 0]] def getPos(self, phase, factor = None): factorTotal = self.factor if(factor != None): for i in range(len(factor)): factorTotal *= factor[i] #Contact with the ground...
class Pointstrajectory: def __init__(self, points, factor=[1, 1]): self.factor = factor self.points = [[-1, 0]] + points + [[1, 0]] def get_pos(self, phase, factor=None): factor_total = self.factor if factor != None: for i in range(len(factor)): fact...
ABI_ENDPOINT = "https://api.etherscan.io/api?module=contract&action=getabi&address=" POLYGON_ABI_ENDPOINT = ( "https://api.polygonscan.com/api?module=contract&action=getabi&address=" ) ENDPOINT = "" POLYGON_ENDPOINT = "" ATTRIBUTES_FOLDER = "raw_attributes" IMPLEMENTATION_SLOT = ( "0x360894a13ba1a3210667c828492...
abi_endpoint = 'https://api.etherscan.io/api?module=contract&action=getabi&address=' polygon_abi_endpoint = 'https://api.polygonscan.com/api?module=contract&action=getabi&address=' endpoint = '' polygon_endpoint = '' attributes_folder = 'raw_attributes' implementation_slot = '0x360894a13ba1a3210667c828492db98dca3e2076c...
def test_is_open_property(factories): survey = factories.SurveyFactory(num_expected=5) survey.record_salary(10, key=5) survey.record_salary(10, key=3) survey.record_salary(10, key=7) survey.record_salary(10, key=13) assert survey.is_open assert not survey.is_finalized survey.finalize(1...
def test_is_open_property(factories): survey = factories.SurveyFactory(num_expected=5) survey.record_salary(10, key=5) survey.record_salary(10, key=3) survey.record_salary(10, key=7) survey.record_salary(10, key=13) assert survey.is_open assert not survey.is_finalized survey.finalize(10)...
#Given a string s, find all its potential permutations. #The output should be sorted in lexicographical order. #For s = "CBA", the output should be # stringPermutations(s) = ["ABC", "ACB", "BAC", "BCA", "CAB", "CBA"]; #For s = "ABA", the output should be # stringPermutations(s) = ["AAB", "ABA", "BAA"]. #CodeSignal p...
def string_permutations(s): if len(s) == 0: return 0 elif len(s) == 1 or (len(s) == 2 and s[0] == s[1]): return [s] elif len(s) == 2 and s[0] != s[1]: sortingo = sorted(s) sortingo = ''.join(sortingo) return [sortingo] + [sortingo[::-1]] sorted_string = sorted(s) ...
def mdc12(x): y = [] if x["_MDC12"] == 0: return y if x["707&708|ORPCS"] > 0: if x["_MCC"] + x["_CC"] > 0: y.append("707") else: y.append("708") if x["709&710|ORPCS"] > 0: if x["_MCC"] + x["_CC"] > 0: y.append("709") else: ...
def mdc12(x): y = [] if x['_MDC12'] == 0: return y if x['707&708|ORPCS'] > 0: if x['_MCC'] + x['_CC'] > 0: y.append('707') else: y.append('708') if x['709&710|ORPCS'] > 0: if x['_MCC'] + x['_CC'] > 0: y.append('709') else: ...
""" Various hooks for extending Splitgraph, including: * External object handlers (:mod:`splitgraph.hooks.external_objects`) allowing to download/upload objects to locations other than the remote Splitgraph engine. * FDW handlers (:mod:`splitgraph.hooks.mount_handlers`) that allow to use the Postgres engine's ...
""" Various hooks for extending Splitgraph, including: * External object handlers (:mod:`splitgraph.hooks.external_objects`) allowing to download/upload objects to locations other than the remote Splitgraph engine. * FDW handlers (:mod:`splitgraph.hooks.mount_handlers`) that allow to use the Postgres engine's ...
# Generated by https://github.com/chanzuckerberg/single-cell-curation/blob/main/notebooks/compute_ancestor_mapping.ipynb ontology_mapping = { "HsapDv:0000000": ["HsapDv:0000000"], "HsapDv:0000001": ["HsapDv:0000001"], "HsapDv:0000002": ["HsapDv:0000002", "HsapDv:0000045", "HsapDv:0000001"], "HsapDv:000...
ontology_mapping = {'HsapDv:0000000': ['HsapDv:0000000'], 'HsapDv:0000001': ['HsapDv:0000001'], 'HsapDv:0000002': ['HsapDv:0000002', 'HsapDv:0000045', 'HsapDv:0000001'], 'HsapDv:0000045': ['HsapDv:0000045', 'HsapDv:0000001'], 'HsapDv:0000003': ['HsapDv:0000003', 'HsapDv:0000002', 'HsapDv:0000045', 'HsapDv:0000001'], 'H...
t=int(input()) for i in range(t): n=int(input()) arr_a=[0]*n arr_b=[0]*n arr_a=[int(x) for x in input().split()] arr_b=[int(x) for x in input().split()] arr_a_min=min(arr_a) arr_b_min=min(arr_b) ans=0 for i in range(n): if arr_b[i] != arr_b_min and arr_a[i] == arr_a_min: ans += (arr_b[i] - arr_b_min) if...
t = int(input()) for i in range(t): n = int(input()) arr_a = [0] * n arr_b = [0] * n arr_a = [int(x) for x in input().split()] arr_b = [int(x) for x in input().split()] arr_a_min = min(arr_a) arr_b_min = min(arr_b) ans = 0 for i in range(n): if arr_b[i] != arr_b_min and arr_a...
class Tile: map_word = "Pine forest" def describe(self): print("There are not so many trees around but the ground is full of " "pine needles and pine cones.\n") def action(self, player, do): print("I don't understand.") def leave(self, player, direction): ...
class Tile: map_word = 'Pine forest' def describe(self): print('There are not so many trees around but the ground is full of pine needles and pine cones.\n') def action(self, player, do): print("I don't understand.") def leave(self, player, direction): if direction == 'e': ...
def find_erasures(bit_list: list, codeword_length: int, data_words: int): erasures = [] for c in range(0, codeword_length*data_words, codeword_length): all_one = (bit_list[c:c+codeword_length].count('1') == codeword_length) all_zero = (bit_list[c:c+codeword_length].count('0') == codeword_length)...
def find_erasures(bit_list: list, codeword_length: int, data_words: int): erasures = [] for c in range(0, codeword_length * data_words, codeword_length): all_one = bit_list[c:c + codeword_length].count('1') == codeword_length all_zero = bit_list[c:c + codeword_length].count('0') == codeword_leng...
def test_smoke(client): r = client.get('/', follow_redirects=True) assert r.status_code == 200 assert 'Registreerimisvorm' in r.data
def test_smoke(client): r = client.get('/', follow_redirects=True) assert r.status_code == 200 assert 'Registreerimisvorm' in r.data
#!/usr/bin/env python2 #encoding: UTF-8 def fizz_buzz(n): """ return fizz when divisible by 3 return buzz when divisible by 5 return fizzbuz when divisible by both 3 and 5 """ if n % 3 == 0 and n % 5 == 0: return 'fizzbuzz' elif n % 3 == 0: return 'fizz' elif n % 5 == 0: ...
def fizz_buzz(n): """ return fizz when divisible by 3 return buzz when divisible by 5 return fizzbuz when divisible by both 3 and 5 """ if n % 3 == 0 and n % 5 == 0: return 'fizzbuzz' elif n % 3 == 0: return 'fizz' elif n % 5 == 0: return 'buzz'
class Complex : def __init__(self, x, y) : self.rPart = x self.iPart = y def __str__(self) : return 'Complex({0} + i{1})'.format(self.rPart, self.iPart) def __eq__(self, other) : return self.rPart == other.rPart and self.iPart == other.iPart def __add__(self, oth...
class Complex: def __init__(self, x, y): self.rPart = x self.iPart = y def __str__(self): return 'Complex({0} + i{1})'.format(self.rPart, self.iPart) def __eq__(self, other): return self.rPart == other.rPart and self.iPart == other.iPart def __add__(self, other): ...
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def deleteNode(self, root, key): """ :type root: TreeNode :type key: int :rtype: TreeNode...
class Solution(object): def delete_node(self, root, key): """ :type root: TreeNode :type key: int :rtype: TreeNode """ def remove(node, parent): ret = root if node.left is None and node.right is None: if parent is None: ...
def make_string(w): if w == '': return '' u = w[0] count = 1 if u == '(' else -1 chk_perfect = (True if count > 0 else False) for ch in w[1:]: u += ch count += (1 if ch == '(' else -1) if count == 0: break if chk_perfect and count < 0: ...
def make_string(w): if w == '': return '' u = w[0] count = 1 if u == '(' else -1 chk_perfect = True if count > 0 else False for ch in w[1:]: u += ch count += 1 if ch == '(' else -1 if count == 0: break if chk_perfect and count < 0: chk_...
s = "abcsssaa" print(s.count('a')) print(s.count('s'))
s = 'abcsssaa' print(s.count('a')) print(s.count('s'))
""" # Definition for a Node. class Node: def __init__(self, val=None, children=None): self.val = val self.children = children """ class Solution: def levelOrder(self, root: 'Node'): if not root: return [] stack, results = [(root, 0)], [] while stack: ...
""" # Definition for a Node. class Node: def __init__(self, val=None, children=None): self.val = val self.children = children """ class Solution: def level_order(self, root: 'Node'): if not root: return [] (stack, results) = ([(root, 0)], []) while stack: ...