content stringlengths 7 1.05M |
|---|
# https://www.geeksforgeeks.org/partition-a-set-into-two-subsets-such-that-the-difference-of-subset-sums-is-minimum/
def helper(arr, n, path, s):
if n == 0:
return abs((s - path) - path)
return min(
helper(arr, n-1, path+arr[n], s),
helper(arr, n-1, path, s)
)
def solve(arr):
... |
## Shortest Word
## 7 kyu
## https://www.codewars.com/kata/57cebe1dc6fdc20c57000ac9
def find_short(s):
# your code here
return sorted([len(word) for word in s.split()])[0] |
nums = 34
coins= [1,2,5,10]
temp = nums
dp = [float("inf") for _ in range(nums)]
dp[0] = 0
for i in range(1,nums):
for j in range(len(coins)):
if(coins[j] <= nums):
dp[i] = min(dp[i], dp[i-coins[j]]+1)
print(dp)
print(dp[nums-1])
|
model_name_mapping = {
'baseline': 'Baseline',
# dnn
'single_regression_2': 'SingleRegression_a',
'single_regression_11': 'SingleRegression_b',
'single_classification_22': 'SingleClassification_a',
'single_classification_42': 'SingleClassification_b',
'multi_classification_15': 'MultiCl... |
class QueryContinueDragEventArgs(RoutedEventArgs):
""" Contains arguments for the System.Windows.DragDrop.QueryContinueDrag event. """
Action=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""Gets or sets the current status of the associated drag-and-drop operation.
Get: Action(self: Q... |
def isfirstwordtitle(txt):
allchars = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',' ']
for char in allchars:
if txt.startswith(char):
return True
return False
def islower(txt,checknum=0):
txt = txt.replace(' ','')
allchars = ['a', 'b', 'c', ... |
# Checks if all characters of a string are alphanumeric (a-z, A-Z and 0-9).
c = "qA2"
print(c.isalnum())
# Checks if all the characters of a string are alphabetical (a-z and A-Z).
print(c.isalpha())
# Checks if all characters in a string are digits.
print(c.isdigit())
# Checks if all characters in a string are lower... |
names = ['Christopher', 'Susan']
index = 0
while index < len(names):
print(names[index])
# 조건을 바꿈!!
index = index + 1
|
"""
438. Find All Anagrams in a String
Example 1:
Input:
s: "cbaebabacd" p: "abc"
Output:
[0, 6]
Explanation:
The substring with start index = 0 is "cba", which is an anagram of "abc".
The substring with start index = 6 is "bac", which is an anagram of "abc".
Example 2:
Input:
s: "abab" p: "ab"
... |
"""modular.py
Modular arithmetic helpers
"""
def modular_multiply(A, B, C):
"""Finds `(A * B) mod C`
This is equivalent to:
`(A mod C * B mod C) mod C`
https://www.khanacademy.org/computing/computer-science/cryptography/modarithmetic/a/modular-multiplication
https://www.khanacademy.org/computin... |
# STRING: nome
print('Camilli', type('Camilli'))
# INT: idade
print(17, type(17))
# # ALTURA: float
print(1.58, type(1.58))
# É MAIOR DE IDADE: bool
print(bool(17 > 18)) |
# -*- coding: utf-8 -*-
class ClassTest:
def __init__(self, value1, value2):
self.value1 = value1
self._value2 = value2
@property
def value2(self):
return self._value2
@value2.setter
def value2(self, value):
self._value2 = value
|
s=0
tot =0
for c in range(1, 500, 2):
if (c % 3) == 0:
s += c
tot += 1
print(s)
print(tot) |
#!/usr/bin/python3
for a in range(1, 400):
for b in range(1, 400):
c = (1000 - a) - b
if a < b < c:
if a**2 + b**2 == c**2:
print(a * b * c)
|
# 向文件添加两行字符串
f = open('hello.txt', 'a') # 打开(文本+追加模式)
f.write('Fine, thanks.\n')
f.write('And you?\n')
f.close() # 关闭 |
# Advent of Code - Day 8 - Part Two
def result(data):
digits = {
2: 1,
4: 4,
3: 7,
7: 8
}
count = 0
for line in data:
a, b = line.split(' | ')
for word in b.split(' '):
x = len(word)
if digits.get(x):
count += 1
... |
# coding: utf-8
"""
According http://www.iliassociation.org/documents/industry/POF%20specs%20V3_2%20January%202005.pdf
Газпром 2-2.3-919-2015
"""
class Error(Exception):
"""
Feature Class exception
"""
class MagnetType: # pylint: disable=too-few-public-methods,no-init
"""
Magnet system types
... |
def staircase(n):
num_dict = dict({})
return staircase_faster(n, num_dict)
def staircase_faster(n, num_dict):
if n == 1:
output = 1
elif n == 2:
output = 2
elif n == 3:
output = 4
else:
if (n - 1) in num_dict:
first_output = num_dict[n - 1]
el... |
"""
Code taken from fsl.py https://git.fmrib.ox.ac.uk/fsl/fslpy
Copyright 2016-2017 University of Oxford, Oxford, UK.
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/licen... |
def firstNonRepeatingCharacter(string):
"""
This function takes a string and find the first character in the string which is non-repeating. This implementation is of O(n) time
complexity and O(1) space complexity where n is the length of the string and all chars in the string are lowecase that is why only 26
key va... |
#三种求 5!+ 4!+ 3!+ 2!+ 1!之和的方法
def cross(n):
result = 1
while n > 1:
result *= n
n -= 1
return result
sum = 0
for i in range(1,6):
sum += cross(i)
print(sum)
sum = 0
a = 1
for i in range(1, 6):
a *= i
sum += a
print(sum)
print(cross(6))
def cross(n):
if n == 1:
re... |
if __name__ == "__main__":
primes = [2, 3, 5, 7, 11, 13, 17, 19]
s = 1
m = 1
for i in range(1, 21):
if i in primes:
s *= i
m *= i
elif m % i == 0:
pass
elif m % i != 0:
j = m
while True:
j += s
... |
# Program to push , pop and display elements of a stack
st = []
r = []
def push():
print('--STACK--')
x = int(input('Book_No: '))
y = input('Book_Name: ')
r = [x, y]
st.append(r)
def display():
if len(st) > 0:
for i in range(len(st)-1, -1, -1):
print(st[i])
else:
... |
class SiteConfig(dict):
def update(self, d, **kwargs):
filtered_d = {k: v for k, v in d.items() if v is not None}
super().update(filtered_d, **kwargs)
@staticmethod
def default():
return SiteConfig(
{
"depth": 5,
"delay": 1.5,
... |
contoh_list = [1, 'dua', 3, 4.0, 5]
print(contoh_list[0])
print(contoh_list[3])
contoh_list = [1, 'dua', 3, 4.0, 5]
contoh_list[3] = 'empat'
print(contoh_list[3])
|
# -*- coding: utf-8 -*-
# this file is released under public domain and you can use without limitations
#########################################################################
## Customize your APP title, subtitle and menus here
#########################################################################
response.logo... |
# spaceobj.py
# A space object.
# Basically, anything that exists on the starmap.
NONETYPE = 0
FLEETTYPE = 1
STARTYPE = 2
class SpaceObj:
name = ""
x = 0
y = 0
# This is often a class variable...
sprite = ()
def __init__( s ):
pass
def moveTo( s, x, y ):
s.x = x
... |
x = y = direction = 0
moves = open('input.txt', 'r').readline().strip().split(', ')
for move in moves:
if move[0] == 'L':
if direction == 0:
direction = 3
else:
direction -= 1
elif move[0] == 'R':
if direction == 3:
direction = 0
else:
... |
with open('input.txt') as f:
lines = f.readlines()
count = 0
prevSum = 0
for i in range(len(lines)):
if i + 3 > len(lines):
break
newSum = int(lines[i]) + int(lines[i + 1]) + int(lines[i + 2])
if prevSum != 0:
if newSum > prevSum:
count += ... |
TOKEN_LIST = [
#kovan
['ethereum', '42', 'eth', '0x0000000000000000000000000000000000000000', 18],
['ethereum', '42', 'usdt', '0xd85476c906b5301e8e9eb58d174a6f96b9dfc5ee', 6],
['ethereum', '42', 'usdc', '0xb7a4f3e9097c08da09517b5ab877f7a917224ede', 6],
['ethereum', '42', 'dai', '0xc4375b7de8af5a38a... |
# -*- coding: utf-8 -*-
"""
Created on Tue May 25 11:16:49 2021
@author: SST-Lab
"""
class XBank:
loggedinCounter = 0
def _init_(self, atmpin, theaccountbalance, thename):
self.atmpin = theatmpin
self.accountbalance = theaccountbalance
self.name = thename
XBank.loggedinCounter ... |
def linear_search(list, target):
"""
Returns the index position of the target if found, else returns None
"""
for i in range(0, len(list)):
if list[i] == target:
return i
return None
def verify(index):
if index is not None:
print("Target is found at index: ", index... |
# coding=utf-8
#
# @lc app=leetcode id=830 lang=python
#
# [830] Positions of Large Groups
#
# https://leetcode.com/problems/positions-of-large-groups/description/
#
# algorithms
# Easy (47.46%)
# Likes: 224
# Dislikes: 56
# Total Accepted: 29.6K
# Total Submissions: 61.5K
# Testcase Example: '"abbxxxxzzy"'
#
# ... |
DEBIAN = 'debian'
CENTOS = 'centos'
OPENSUSE = 'opensuse'
UBUNTU = 'ubuntu'
|
print('====== EX 024 ======')
cid = str(input('Em que cidade você nasceu? ')).lower().split()
print('santo' in cid)
|
# Quest 01
num = int(input("Digite um número: "))
positivo = num > 0
negativo = num < 0
neutro = num == 0
if (positivo):
print("Positivo")
elif(negativo):
print("Negativo")
else:
print("Neutro") |
#MenuTitle: Make bottom left node first
# -*- coding: utf-8 -*-
__doc__="""
Makes the bottom left node in each path the first node in all masters
"""
def left(x):
return x.position.x
def bottom(x):
return x.position.y
layers = Glyphs.font.selectedLayers
for aLayer in layers:
for idx, thisLayer in enumerate(a... |
class Solution(object):
def nextPermutation(self, nums):
"""
:type nums: List[int]
:rtype: void Do not return anything, modify nums in-place instead.
"""
# find the longest non-decreasing suffix in nums
right = len(nums) - 1
while right >= 1 and nums[right] <=... |
cand1 = 0
cand2 = 0
cand3 = 0
eleitores = int(input('Digite a quantidade de eleitores: '))
print('Para votar no Candidato 1 digite [1]\nPara votar no Candidato 2 digite [2]\nPara votar no Candidato 3 digite [3]')
for cont in range(0, eleitores):
voto = str(input('Digite seu voto: '))
if voto == '1':
can... |
qq = (input('Digite algo qualquer: '))
print('O tipo da palavra digitado é', type(qq))
print('O valor dela são digitos?', qq.isdigit())
print('O valor dela são númericos?', qq.isnumeric())
print('O valor dela são letras?', qq.isalpha())
print('O valor dela são alfanúmericos?', qq.isalnum())
print('O valor dela são apen... |
# ----------------------------------------------------------------------
# Copyright (c) Microsoft Corporation.
# All rights reserved.
# ----------------------------------------------------------------------
# TODO: Consider just inheriting from Python's set type -MPL
class SymbolSet:
def __init__(self):
... |
fix = {'5':'S', '0':'O', '1':'I'}
def correct(s):
return "".join(fix.get(c, c) for c in s)
|
def config_step_task(name, task_name, task_params=[], on_failure='TERMINATE_CLUSTER'):
"""
Returns a Python dict representing the step.
:param name: semantic name of the task
:param task_name: task name, identifies executable
:param task_params: task parameters
:param on_failure: either "CONTI... |
#!/usr/bin/python3
def test_erc165_support(nft):
erc165_interface_id = "0x01ffc9a7"
assert nft.supportsInterface(erc165_interface_id) is True
def test_erc721_support(nft):
erc721_interface_id = "0x80ac58cd"
assert nft.supportsInterface(erc721_interface_id) is True
|
def fatorial(_numero = 1, show = False):
resultado = 1
for item in range(1, _numero + 1):
resultado *= item
if show:
texto = ''
for item in reversed(range(1, _numero + 1)):
texto += '{} '.format(item)
if item == 1:
texto += '= {}'.format(resul... |
"""
Management of OpenStack Keystone Roles
======================================
.. versionadded:: 2018.3.0
:depends: shade
:configuration: see :py:mod:`salt.modules.keystoneng` for setup instructions
Example States
.. code-block:: yaml
create role:
keystone_role.present:
- name: role1
dele... |
BLACK = '\x1b[0;30m'
RED = '\x1b[0;31m'
GREEN = '\x1b[0;32m'
BROWN = '\x1b[0;33m'
BLUE = '\x1b[0;34m'
PURPLE = '\x1b[0;35m'
CYAN = '\x1b[0;36m'
LIGHT_GRAY = '\x1b[0;37m'
DARK_GRAY = '\x1b[1;30m'
LIGHT_RED = '\x1b[1;31m'
LIGHT_GREEN = '\x1b[1;32m'
YELLOW = '\x1b[1;33m'
LIGHT_BLUE = '\x1b[1;34m'
LIGHT_PURPLE = '\x1b[1;3... |
""" Assignment 8
1. Write a function that will return True if the passed-in number is even,
and False if it is odd.
2. Write a second function that will call the first with values 0-6 and print
each result on a new line.
3. Invoke the second function.
The signature of the first function should be: `is_even(num: int) ... |
authentication = {
"type": "object",
"properties": {
"access": {
"type": "object",
"properties": {
"token": {
"type": "object",
"properties": {
"id": {
"type": "string"
... |
class Node:
def __init__(self, value):
self.value = value
self.next = None
class Queue:
def __init__(self):
self.front = None
self.rear = None
def enqueue(self, data):
node = Node(data)
if self.rear:
self.rear.next = node
self.rear... |
"""
# requests : 웹 사이트에 접속, 데이터를 받아오는 역할
# * 페이지 보기를 했을때 나오는 코드로 이용
# BeautifulSoup : 데이터를 HTML로 해석하는 역할
# 선행지식 : HTML에 대한 이해, CSS Selector를 만드는 방법
# 요소검사를 통해 확인할 수 있는 소스코드 or 업데이트되는 환경일 때
1) selennium : 웹 브라우저 자체를 컨트롤해서 Crawling(실시간으로 업데이트된 것을 가져오기 위해)
* 요소를 선택해서 사용자의 동작을 흉내낸다. : 클릭, 키보드 입력
* 이때는 선택자) xpa... |
class Customer:
def __init__(self, name, age, phone_no, address):
self.name = name
self.age = age
self.phone_no = phone_no
self.address = address
def view_details(self):
print(self.name, self.age, self.phone_no)
print(self.address.get_door_no(),
sel... |
#!/usr/bin/env python3
# https://abc054.contest.atcoder.jp/tasks/abc054_a
a, b = map(int, input().split())
if a == b: print('Draw')
elif a == 1: print('Alice')
elif b == 1: print('Bob')
elif a > b: print('Alice')
else: print('Bob')
|
#获取参数异常
class ArgmentError(Exception):
def __init__(self, expression, message):
self.expression = expression
self.message = message
#读取配置文件异常
class SettingFileError(Exception):
def __init__(self, expression, message):
self.expression = expression
self.message = message
cla... |
class NoQueueError(Exception):
pass
class JobError(RuntimeError):
pass
class TimeoutError(JobError):
pass
class CrashError(JobError):
pass |
# ------------------------------
# 33. Search in Rotated Sorted Array
#
# Description:
# Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.
#
# (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).
# You are given a target value to search. If found in the array return its index... |
# Encoding and Decoding in Python 3.x
a = 'Harshit'
# initialize byte object.
c = b'Harshit'
# using encode() to encode string
d = a.encode('ASCII')
if (d == c):
print("Encoding successful.")
else:
print("Encoding unsuccessful. :( ")
# Similarly, decode() is the inverse process.
# decode() will convert byte... |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
__author__ = 'ipetrash'
# SOURCE: Design Patterns: Proxy - Заместитель
# SOURCE: https://ru.wikipedia.org/wiki/Заместитель_(шаблон_проектирования)
class IMath:
"""Интерфейс для прокси и реального субъекта"""
def add(self, x, y):
raise NotImplementedEr... |
#! /usr/bin/env python3
"""
--- besspin-ci.py is the CI entry to the BESSPIN program.
--- This file provide the combinations of CI files generated.
--- Every combination is represented as a set of tuples.
Each tuple represents one setting and its possible values.
Each "values" should be a tuple. Please note t... |
'''
Verify correct field and URL verification behavior
for not and nocase modifiers.
'''
# @file
#
# Copyright 2021, Verizon Media
# SPDX-License-Identifier: Apache-2.0
#
Test.Summary = '''
Verify correct field and URL verification behavior for
equals, absent, present, contains, prefix, and suffix
with not, nocase, a... |
#!/usr/bin/python3
""" Class Square creation module
A Blueprint for squares
"""
class Square:
"""Set the class square"""
def __init__(self, size=0):
"""Iniatiate Attributes for Square class.
Args:
size: integer with size of the square.
"""
self.__size = size
... |
# Python API for using CAPI 3 core files from VUnit
# Authors:
# Unai Martinez-Corral
#
# Copyright 2021 Unai Martinez-Corral <unai.martinezcorral@ehu.eus>
#
# 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... |
"""Welcome to FIRESONG, the FIRst Extragalactic Simulation Of Neutrinos and Gamma-rays"""
__author__ = 'C.F. Tung, T. Glauch, M. Larson, A. Pizzuto, R. Reimann, I. Taboada'
__email__ = ''
__version__ = '1.8'
__all__ = ['Firesong', 'Evolution', 'distance', 'FluxPDF',
'input_out', 'Luminosity', 'sampling', '... |
# ------------------------------
# 1027. Longest Arithmetic Sequence
#
# Description:
# Given an array A of integers, return the length of the longest arithmetic subsequence in A.
# Recall that a subsequence of A is a list A[i_1], A[i_2], ..., A[i_k] with 0 <= i_1 < i_2 <
# ... < i_k <= A.length - 1, and that a sequ... |
products = {}
command = input()
while command != "statistics":
command = input()
while command != "statistics":
tokens = command.split(": ")
product = tokens[0]
quantity = int(tokens[1])
if product not in products:
products[product] = 0
products[product] += quantity
print("Products in s... |
DEBUG = False
ALLOWED_HOSTS = ['*']
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'db1',
'USER': 'alex',
'PASSWORD': 'asdewqr1',
'HOST': 'localhost', # Set to empty string for localhost.
'PORT': '', # Set to empty string for default.
}
... |
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
# Copyright (c) 2002-2020 "Neo4j,"
# Neo4j Sweden AB [http://neo4j.com]
#
# This file is part of Neo4j.
#
# 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 L... |
"""
`segment_regexes`: make sure a string is segmented at either the start or end of the matching group(s)
"""
newline = {
'name': 'newline',
'regex': r'\n',
'at': 'end'
}
ellipsis = {
'name': 'ellipsis',
'regex': r'…(?![\!\?\..?!])',
'at': 'end'
}
after_semicolon = {
'name': 'after_semico... |
class Dummy:
def __str__(self) -> str:
return "dummy"
d1 = Dummy()
print(d1)
|
"""
Problem 1 - https://adventofcode.com/2020/day/2
Part 1 -
Given a list of password and conditions the passwords have to fulfill, return the number of passwords that fulfill the conditions
Part 2 -
Same as part 1 with different conditions
"""
# Set up the input
with open('input-02122020.txt', 'r') as file... |
"""
Last one was a bit easy. Let's ramp it up a tad :)
This challenge is close to the real deal. Some of you may get it here. Solve the equation for X.
Example
For string = "99X=1(mod 8)", the output should be
breakDown3(string) = 3.
"99X=1(mod 8)".
To solve this equation, first you must reduce the left side. Make i... |
_use_time = True
try:
_start_time = datetime.utcnow().timestamp()
except Exception:
_use_time = False |
# -*- coding: Latin-1 -*-
## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ##
## ##
# infinity.py
# --------------------------------
# Copyright (c) 2005
# Jean-Sébastien BOLDUC
# Hans Vangheluwe... |
# -*- coding: utf-8 -*-
"""
sphinxcontrib.websupport.version
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:copyright: Copyright 2007-2018 by the Sphinx team, see README.
:license: BSD, see LICENSE for details.
"""
__version__ = '1.1.0'
__version_info__ = tuple(map(int, __version__.split('.')))
|
class ErrorCode(object):
ERROR_001_REQUIRED_FIELD_NOT_NULL = '001'
ERROR_002_PAGE_SIZE_LARGE_THAN_0 = '002'
ERROR_003_PAGE_LARGE_THAN_0 = '003'
ERROR_004_FIELD_VALUE_INVALID = '004'
ERROR_005_ORDER_VALUE_INVALID = '005'
ERROR_006_SEARCH_PARAMS_INVALID = '006'
ERROR_040_UNAUTHORIZED = '040'
... |
"""
Painonhallintasovelluksen pääohjelma
Huolehtii syötteen lukemisesta ja tulosten näyttämisestä
"""
# Kirjastojen ja modulien lataukset
# Pääohjelman omat luokat, funktiot ja kirjastokomponenttien alustukset
# Pääohjelman ikuinen silmukka
jatketaan = 'K'
while True:
while virhekoodi != 0:
paino_str =... |
# -*- coding: utf-8 -*-
extensions = ['sphinx.ext.viewcode']
master_doc = 'index'
exclude_patterns = ['_build']
viewcode_follow_imported_members = False
|
#!/usr/bin/env python
# encoding: utf-8
__all__ = ['gcd']
def gcd(a, b):
"""Compute gcd(a,b)
:param a: first number
:param b: second number
:returns: the gcd
"""
pos_a, _a = (a >= 0), abs(a)
pos_b, _b = (b >= 0), abs(b)
gcd_sgn = (-1 + 2*(pos_a or po... |
'''
Anti-palindrome strings
You are given a string containing only lowercase alphabets. You can swap two adjacent characters any number of times (including 0).
A string is called anti-palindrome if it is not a palindrome. If it is possible to make a string anti-palindrome, then find the lexicographically smallest an... |
"""
all opcodes Python3.6.0
"""
# general
NOP = 9
POP_TOP = 1
ROT_TWO = 2
ROT_THREE = 3
DUP_TOP = 4
DUP_TOP_TWO = 5
# one operand
UNARY_POSITIVE = 10
UNARY_NEGATIVE = 11
UNARY_NOT = 12
UNARY_INVERT = 15
GET_ITER = 68
GET_YIELD_FROM_ITER = 69
# two operand
BINARY_POWER = 19
BINARY_MULTIPLY = 20
BINARY_MATRIX_MULTIPLY... |
## 020 Valid Parentheses
## Given a string containing just the characters '(', ')', '{', '}', '[' and ']',
## determine if the input</br> string is valid.
## The brackets must close in the correct order, "()" and "()[]{}" are all valid
## but "(]" and "([)]" are not.
class Solution:
def isValid(self, s):
... |
def bom_populate(bom):
bom.components.new(
name="s1",
description="HPE ML30 INTEL, 4U Tower, 8 HD's fit inside, 1 gbit dual",
cost=378,
rackspace_u=0,
cru=0,
sru=0,
hru=0,
mru=0,
su_perc=50,
cu_perc=50,
power=150,
)
... |
class Model:
def to_dict(self):
return NotImplementedError
class User(Model):
def to_dict(self):
return {}
class UserID(Model):
def to_dict(self):
return {}
class UserAuth(Model):
def to_dict(self):
return {}
|
# @file dsc_processor_plugin
# Plugin for for parsing DSCs
##
# Copyright (c) Microsoft Corporation
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
##
class IDscProcessorPlugin(object):
##
# does the transform on the DSC
#
# @param dsc - the in-memory model of the DSC
# @param thebuilder - UefiB... |
def q2(stop_value):
first, second = 0, 1
i = 0
while first < stop_value:
print(f"{i}th term is: {first}")
first, second = first + second, first
i += 1
if __name__ == "__main__":
n = 20
q2(n)
|
def titulo():
print('~' * 80)
print('{:^80}'.format('Sistema Interativo PyHelp'))
print('~' * 80)
def leia_comando():
comando = str(input(
'> Insira o comando que deseja obter ajuda: ("fim" para encerrar) ')).lower().strip()
return comando
def imprimir_manual(_comando):
try:
... |
class Status:
""" If you create a custom Status symbol, please keep in mind that
all statuses are registered globally and that can cause name collisions.
However, it's an intended use case for your checks to be able to yield
custom statuses. Interpreters of the check protocol will have to skip
stat... |
"""Detects and configures the local Python.
Add the following to your WORKSPACE FILE:
```python
python_configure(name = "cpython37", interpreter = "python3.7")
```
Args:
name: A unique name for this workspace rule.
interpreter: interpreter used to config this workspace
"""
def _tpl(repository_ctx, tpl, substitu... |
# Mu Lung Dojo Bulletin Board (2091006) | Mu Lung Temple (250000100)
dojo = 925020000
response = sm.sendAskYesNo("Would you like to go to Mu Lung Dojo?")
if response:
sm.setReturnField()
sm.setReturnPortal(0)
sm.warp(dojo) |
# --------------
# Code starts here
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... |
"""
Spark mllib
Algorithms ->
Classification
regression
clustering
topic modelling.
etc.
workflows ->
feature transformations
pipelines
evaluations
hyperparameter
tuning
utilities ->
Distributed math libraries
statistics
functions
"""
# Normalize -> maps data from original range to range of 0 to 1
# Advantage of ... |
badge_icon = 'app.icns'
icon_locations = {
'LBRY.app': (115, 164),
'Applications': (387, 164)
}
background='dmg_background.png'
default_view='icon-view'
symlinks = { 'Applications': '/Applications' }
window_rect=((200, 200), (500, 320))
files = [ 'LBRY.app' ]
icon_size=128
|
# -*- coding: utf-8 -*-
"""
Created on Mon Jun 11 01:37:09 2018
@author: sushy
"""
secretWord = 'apple'
lettersGuessed = ['e', 'i', 'k', 'p', 'r', 's']
def getGuessedWord(sW, lG):
'''
sW: string, the word the user is guessing
lG: list, what letters have been guessed so far
returns: string, comprised ... |
#
# PySNMP MIB module TPT-TPA-HARDWARE-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/TPT-TPA-HARDWARE-MIB
# Produced by pysmi-0.3.4 at Wed May 1 15:26:46 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (defau... |
class Solution:
def criticalConnections(self, n: int, connections: List[List[int]]) -> List[List[int]]:
INF = 1000000
lows = [INF] * n
ranks = [INF] * n
graph = collections.defaultdict(list)
for u, v in connections:
graph[u].append(v)
graph[v].append(u... |
# mode: run
# ticket: 593
# tag: property, decorator
my_property = property
class Prop(object):
"""
>>> p = Prop()
>>> p.prop
GETTING 'None'
>>> p.prop = 1
SETTING '1' (previously: 'None')
>>> p.prop
GETTING '1'
1
>>> p.prop = 2
SETTING '2' (previously: '1')
>>> p.prop
... |
l = [83, 85, 78, 123, 77, 52, 57, 53, 45, 102, 52, 110, 33, 125]
flag = ""
for c in l:
flag += chr(c)
print(flag)
|
class ServerObj:
"""Server class"""
def __init__(self):
self._name = ''
self._totalPhysicalMemory = 0
self._freePhysicalMemory = 0
self._disks = []
@property
def name(self):
return self._name
@name.setter
def name(self... |
l,S1,final=[],[],[]
S=input('Enter the numbers: ')
S1=S.split()
for i in S1:
l.append(int(i))
final=str("['"+str(l)+"']")
print(final)
|
# Permutation
def permutation_rec(a):
if len(a) == 0:
return []
if len(a) == 1:
return [a]
l = []
for i in range(len(a)):
x = a[:i] + a[i+1:]
for j in permutation_rec(x):
str2 = a[i] + j
l.append(str2)
return l
count = 0
for r in permutati... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.