content stringlengths 7 1.05M |
|---|
'''Take the following Python code that stores a string:
str = 'X-DSPAM-Confidence: 0.8475 '
Use "find" and string slicing to extract the portion of the string after the colon character and then use the "float" function to convert the extracted string into a floating point number. '''
str = 'X-DSPAM-Confidence: 0.84... |
def main():
ran = range(3)
for i in ran:
path = 'class'+str(i)+'/'
f = open(path+'word.db','w')
f.close()
f = open('dictionary','w')
f.close()
f = open('dictionary2','w')
f.close()
if __name__=='__main__':
main()
|
# Copyright (c) 2011 Google Inc. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
{
'targets': [
{
'target_name': 'test_app',
'product_name': 'Test App',
'type': 'executable',
'mac_bundle': 1,
'sources': [
... |
# This file is part of Project Deity.
# Copyright 2020-2021, Frostflake (L.A.)
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights... |
#
# PySNMP MIB module FOUNDRY-MAC-VLAN-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/FOUNDRY-MAC-VLAN-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 19:01:17 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (defau... |
def gridSearch(G, P):
p_h, p_w = len(P), len(P[0])
search_h, search_w = len(G) - p_h + 1, len(G[0]) - p_w + 1
nrow_match = 0
for i in range(search_h):
for j in range(search_w):
if G[i][j:j+p_w] == P[0]:
nrow_match += 1
# dfs
for m in r... |
# Query to join weather to call records by date columns
query = """
SELECT *
FROM hpd311calls
JOIN weather
ON hpd311calls.created_date = weather.date;
"""
# Create data frame of joined tables
calls_with_weather = pd.read_sql(query, engine)
# View the data frame to make sure all columns were joined
print(calls... |
frase = str(input('Digite uma frase: ')).strip().upper()
palavras = frase.split()
juntar = ''.join(palavras)
inverso = ''
for letra in range (len(juntar)-1, -1, -1):
inverso += juntar[letra]
if inverso == juntar:
print('É PALINDROMO')
else:
print('NÃO É PALINDROMO') |
def create_matrix(size):
return [input().split() for line in range(size)]
def find_miner_start_position(matrix, size):
for r in range(size):
for c in range(size):
if matrix[r][c] == "s":
return r, c
def find_total_coal(matrix):
result = 0
for r in range(size):
... |
## Function 3 - multiplying two numbers
## 8 kyu
## https://www.codewars.com/kata/523b66342d0c301ae400003b
def multiply(x,y):
return x * y |
# определить знак введенного числа [06:03]
x = int(input())
if x < 0:
print("x - отрицательное число")
# if x >= 0:
# else:
# print("х - неотрицательное число")
elif x > 0:
print("x - положительное число")
else:
print("х - равно нулю")
|
# special websocket message types used for managing the connection
# corresponds to constants at the top of websockets.js
HELLO_TYPE = 'HELLO'
GOT_HELLO_TYPE = 'GOT_HELLO'
PING_TYPE = 'PING'
PING_RESPONSE_TYPE = 'PING'
RECONNECT_TYPE = 'RECONNECT'
# use the value in this json field in the message to pick an
# on_VALU... |
#----------* CHALLENGE 40 *----------
#Ask for a number below 50 and then count down from 50 to that number, making sure you show the number they entered in the output
num = int(input("Enter a number below 50: "))
for i in range(50,num-1,-1):
print(i) |
#Functions
'''
#Using Functions
#------------------------#
print("----------------------")
def print_hello_world() :
print("Hello World")
print_hello_world()
print("----------------------")
#------------------------#
'''
'''
#Using paramaters
#------------------------#
print("----------------------")
def print_m... |
class Solution(object):
def wiggleSort(self, nums):
"""
:type nums: List[int]
:rtype: void Do not return anything, modify nums in-place instead.
"""
nums.sort()
tmp, length = nums[:], len(nums)
cursor = length / 2 + length % 2
i, k = cursor - 1, 0
... |
'''
Escreva um programa que converta uma temperatura digitada em ºC e converta para ºF
'''
temperatura_em_C = float(input("Digite a temperatura em Cº: "))
temperatura_em_F = (temperatura_em_C * 1.8)+32
print('A temperatura de {:2.0f} ºC convertido para Fahrenheit é {:2.0f} ºF.'.format(temperatura_em_C,temperatura_em... |
# Copyright 2017 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.
DEPS = [
'chromium',
'chromium_tests',
'depot_tools/tryserver',
'recipe_engine/platform',
'recipe_engine/properties',
'test_results',... |
dp = [[0 for _ in range(101)] for _ in range(101)]
def solve(n, m):
if dp[n][m]: return dp[n][m]
if m==0 or n==m: return 1
dp[n][m]=solve(n-1, m-1)+solve(n-1, m)
return dp[n][m]
n, m=map(int, input().split())
print(solve(n, m)) |
def test_captcha(app, start):
app.account.captcha_off()
def test_new_account(app):
link = app.account.find_link_for_create_account()
app.account.go_to_create_account_page(link)
user = app.account.create_account()
app.account.account_has_been_created()
app.account.logout()
app.account.login... |
def IDtoTime(string):
start_time = ""
result = []
#mon1
#mon1,2
#mon10,2,3
#mon10:30
#tue(11:30
if string[1].isdecimal() == True:
start_time = string[1]
if len(string) >=3 :
if string[2].isdecimal() == True:
start_time = string[1:3]
if len(str... |
# SiteTool
# 2019
APP_VERSION = '0.1.0'
|
num1 = int(input('Digite um número: '))
num2 = int(input('Digite outro número: '))
soma = num1 + num2
print('A soma vale {}'.format(soma))
|
"""
Find the sum of all left leaves in a given binary tree.
Example:
3
/ \
9 20
/ \
15 7
There are two left leaves in the binary tree, with values 9 and 15 respectively. Return 24.
"""
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# ... |
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
def buildifier_deps_deps():
go_rules_dependencies()
go_register_toolchains()
gazelle_depend... |
"""
Implementation of BOWSR paper
Zuo, Yunxing, et al.
"Accelerating Materials Discovery with Bayesian Optimization and Graph Deep Learning."
arXiv preprint arXiv:2104.10242 (2021).
"""
|
#Device Source for vector division
kernel_code_div = """
__global__ void kernel(float *d, float *a, float *b)
{
int tid = blockIdx.x * blockDim.x + threadIdx.x;
d[tid] = a[tid] / b[tid];
}
""" |
year = int(input())
is_hapyy_year = False
while not is_hapyy_year:
year += 1
str_year = str(year)
set_year = set(str_year)
if len(str_year) == len(set_year):
is_hapyy_year = True
print(year)
|
class SDL_SubSystem:
SDL_INIT_TIMER = 1
SDL_INIT_AUDIO = 16
SDL_INIT_VIDEO = 32
SDL_INIT_JOYSTICK = 512
SDL_INIT_HAPTIC = 4096
SDL_INIT_GAMECONTROLLER = 8192
SDL_INIT_EVENTS = 16384
SDL_INIT_EVERYTHING = 6201
class SDL_EventType:
"""SDL EventType.
See: https://wiki.libsdl.org/... |
user_files = './normalized_profiles/users/'
object_files = './normalized_profiles/objects/'
num_users = 1012
num_objects = 656
users = open(user_files + 'all.txt').read().split('\n')
objects = open(object_files + 'all.txt').read().split('\n')
err = open('database_errors.log', 'w')
for i in range(num_users):
f =... |
class Solution:
def lengthOfLongestSubstring(self, s: str) -> int:
len_ = 0
temp_list = []
for ch in s:
if ch in temp_list:
print(ch)
len_ = max(len_, len(temp_list))
temp_list = temp_list[temp_list.index(ch)+1:]
pri... |
geral = list()
nomepeso = list()
maiorpeso = list()
while True:
nomepeso.append(str(input('Nome: ')))
nomepeso.append(int(input('Peso: ')))
geral.append(nomepeso[:])
nomepeso.clear()
sn = str(input('Deseja continuar? [S/N] '))
if sn in 'Nn':
break
for c in geral:
maiorpeso.append(c[1... |
#!/usr/bin/env python
# coding: utf-8
# In[1]:
test=float('inf')
print('test>1',test>1)
print('test>10',test>10)
print('test>10',test>100)
# In[7]:
#To represent positive and negative infinity:
# positive infinity
p_inf = float("inf")
# negative infinity
n_inf = float("-inf")
print("n_inf",n_inf <-10)
# In[ ]:... |
"""
Lab 6 for Loop and Range
"""
#3.1
for i in range(6):
if i !=3:
print(i)
#3.2
#result = 1
#for i in range(1,6):
# result = result * i
#print(result)
# #3.3
# result = 0
# for i in range(1,6):
# result = result + i
# print(result)
# #3.4
# result = 1
# for i in range(3,9):
# result =... |
n = 1
c = 1
f = "-"
print(f"{f*10}INICIO | DIGITE UM NUMERO NEGATIVO PARA SAIR{f*10}")
while True:
n = int(input("Informe um valor para ver sua tabuada: "))
c = 1
if n > 0:
while n*11 != n*c:
print(f"{n}x{c}={n*c}")
c += 1
else:
break
print("FIM")
|
def minimum2(L):
min_1 = L[0]
min_2 = L[1]
if min_1 < min_2:
min_1, min_2 = min_2, min_1
i = 0
while i < len(L):
if L[i] < min_1:
min_2, min_1 = min_1, L[i]
elif L[i] < min_2 and L[i] > min_1:
min_2 = L[i]
i += 1
return min_2
print(minimum2([3,2,5,7,2]))
|
'''
Desenvolva uma lógica que leia o peso e a altura de uma pessoa, calcule seu IMC e mostre seu status,
de acordo com a tabela abaixo:
- Abaixo de 18.5: Abaixo do peso
- Entre 18.5 e 25: Peso ideal
- 25 até 30: Sobrepeso
- 30 Até 40: Obesidade
- Acima de 40: Obesidade mórbida
'''
# peso = int(input('Digite o seu peso... |
TEST_NAME = "030-trackingreview"
BRANCH_NAME = [TEST_NAME + "-1",
TEST_NAME + "-2"]
UPSTREAM_NAME = [name + "-upstream"
for name in BRANCH_NAME]
SUMMARY = TEST_NAME
ORIGINAL_SHA1 = "37bfd1ee7d301b364d0a8c716e9bca36efd5d139"
REVIEWED_SHA1 = []
UPSTREAM_SHA1 = ["22afd9377add956e1e8d8dd6ef... |
def check_goldbach_for_num(n,primes_set) :
'''gets an even integer- n, and a set of primes- primes_set. Returns whether there're two primes which their sum is n'''
for prime in primes_set :
if ((p < n) and ((n - prime) in primes_set)):
return True
return False
|
#!/usr/bin/env python
#********************
# retroSpeak vocabulary
# retroSpeak is a Raspberry Pi controlled speech synthesizer using the vintage
# SP0256-AL2 chip, and MCP23S17 SPI controlled port expander.
#
# Vocabulary based on example wordlists in the Archer/Radioshack SP0256 datasheet
# with typos corrected and... |
def create_tables(cursor,fileName):
file = open(fileName)
sql = file.readline()
while sql:
cursor.execute(sql)
sql = file.readline()
file.close()
|
# Date: 2020/11/05
# Author: Luis Marquez
# Description:
# ##
#
#
def square():
#DEFINING EPSILON (MARGIN OF ERROR)
epsilon = 0.01
#DEFINING STEP (HOW MUCH I CAN APPROXIMATE IN EACH STEP)
step = epsilon**2
#DEFINFING ANSWER
answer = 0.0
#DEFINING OBJECTIVE (TO CALCULATE... |
"""
The idea here is to build a segment tree. Each node stores the left and right
endpoint of an interval and the sum of that interval. All of the leaves will store
elements of the array and each internal node will store sum of leaves under it.
Creating the tree takes O(n) time. Query and updates are bo... |
#!/usr/bin/python3
with open('data') as f:
lines = f.readlines()
n = 0
for i in range(len(lines)-1):
if int(lines[i]) < int(lines[i+1]):
n += 1
print('python3, day 1, part 1 :', n)
|
height= float(input("Please Enter your height : "))
weight= int(input("Please Enter your weight : "))
BMI=weight/height ** 2
print("your BMI is : " + str(BMI)) |
# rin, kn_x, kn_y = input().split(), input().split(), input().split()
# def s(kn_t, axis):
# b_s = list(())
# for e_i, e_v in enumerate([int(a) for a in kn_t]):
# if e_i==0: b_s.append(e_v)
# elif e_i==len(kn_t)-1: b_s.append(int(rin[axis])-e_v)
# else: b_s.append(e_v-int(kn_t[e_i-... |
# -*- coding: utf-8 -*-
"""Top-level package for phenotrex."""
__author__ = """Lukas Lüftinger"""
__email__ = 'lukas.lueftinger@outlook.com'
__version__ = '0.6.0'
__all__ = ['io', 'ml', 'util', 'transforms']
|
#
# PySNMP MIB module HPN-ICF-MAC-INFORMATION-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HPN-ICF-MAC-INFORMATION-MIB
# Produced by pysmi-0.3.4 at Wed May 1 13:40:07 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python versio... |
# Time: O(n)
# Space: O(h)
# Given a binary tree, find the leftmost value in the last row of the tree.
#
# Example 1:
# Input:
#
# 2
# / \
# 1 3
#
# Output:
# 1
# Example 2:
# Input:
#
# 1
# / \
# 2 3
# / / \
# 4 5 6
# /
# 7
#
# Output:
# 7
# Note: You may a... |
# Copyright © 2021 BaraniARR
# Encoding = 'utf-8'
# Licensed under MIT License
# Special Thanks for gogoanime
"""ANIME DL TELEGRAM BOT CREDENTIALS"""
api_id = "2943069"
api_hash = "7ba2c6c7a6013f79ef95baab7dba92e3"
bot_token = "1846560617:AAE0-3pF14D_kM3ek-e18HSGzXQDKupCrbE"
|
# -*- coding:utf-8 -*-
# --------------------------------------------------------
# Copyright (C), 2016-2021, lizhe, All rights reserved
# --------------------------------------------------------
# @Name: constant.py
# @Author: lizhe
# @Created: 2021/11/18 - 22:08
# ------------------------------... |
# Fibonacci numbers
# 1, 1, 2, 3, 5, 8, 13, 21, ...
def fibonacci(limit):
nums = []
currnum = 0
nextnum = 1
while currnum < limit:
currnum, nextnum = nextnum, nextnum + currnum
nums.append(currnum)
return nums
print('via lists')
for n in fibonacci(100):
print(n, end=', ')
p... |
'''
Any e All
all() - Retorna True se todos os elementos do iterável são verdadeiros ou ainda se o iterável está vazio.
# Exemplo all()
print(all([0, 1, 2, 3, 4])) # Todos os números são verdadeiros ? False
print(all([1, 2, 3, 4, 5])) # Todos os números são verdadeiros ? True
print(all([])) # True iteravel vazio
p... |
text = "X-DSPAM-Confidence: 0.8475"
fiveposition = text.find("5")
# print(fiveposition)
zeroposition = text.find("0")
# print(zeroposition)
number = text[zeroposition:]
print(float(number))
|
MORSE_ALPHABET = {
"A": ".-",
"B": "-...",
"C": "-.-.",
"D": "-..",
"E": ".",
"F": "..-.",
"G": "--.",
"H": "....",
"I": "..",
"J": ".---",
"K": "-.-",
"L": ".-..",
"M": "--",
"N": "-.",
"O": "---",
"P": ".--.",
"Q": "--.-",
"R": ".-.",
"S": ".... |
class Solution:
def evalRPN(self, tokens: List[str]) -> int:
"""
:type tokens: List[str]
:rtype: int
"""
stack = list()
operations = {'+', '-', '*', '/'}
for token in tokens:
if token in operations:
right = stack.pop()
... |
cookies = input("hoeveel koekjes wil je maken")
sugar = (1.5 / 48) * int(cookies)
butter = (1 / 48) * int(cookies)
flour = (2.75 / 48) * int(cookies)
print ("suiker: ", sugar, "\n", "boter: ", butter, "\n", "bloem: ", flour)
|
class CaseData:
"""
A test case.
Attributes
----------
bond_factory : :class:`.BondFactory`
The bond factory to test.
atoms : :class:`tuple` of :class:`.Atom`
The atom to pass to :meth:`.BondFactory.get_bonds`.
bonds : :class:`tuple` of :class:`.Bond`
The bonds whi... |
"""
Python条件语句是通过一条或多条语句的执行结果(True或者False)来决定执行的代码块。
"""
"""
if 语句,一般语法格式:
if c_1:
b_1
elif c_2:
b_2
else:
b_3
关于语法分析:
如果 "c_1" 为 True 将执行 "b_1" 块语句
如果 "c_1" 为False,将判断 "c_2"是True还是False
如果"c_2" 为 True 将执行 "b_2" 块语句
如果 "c_2" 为False,将执行"b_3"块语句
一般语言中看到的是else if,Python中用 elif 代替了 else if,所以if语句的关键字为:if –... |
__author__ = "Sunrit Jana"
__email__ = "warriordefenderz@gmail.com"
__version__ = "0.1.0"
__license__ = "MIT License"
__copyright__ = "Copyright 2021 Sunrit Jana"
|
def swap(array, i, j):
temp = array[i]
array[i] = array[j]
array[j] = temp
def bubble_sort(array):
for i in range(len(array)):
for j in range(len(array)-1, i, -1):
if array[j-1] > array[j]:
swap(array, j-1, j)
return array
if __name__ == "__main__":
print(bubble_sort([5,4,8,10,6,3,2,1])) |
"""
Sample Python File with No PEP8 Errors.
Used for testing the pep8.Tool
"""
def does_something(thing):
"""Do a thing and then return."""
return thing.buzz()
|
__packagename__ = "sira"
__description__ = "Systemic Infrastructure Resilience Analysis"
__url__ = "https://github.com/GeoscienceAustralia/sira"
__version__ = "0.1.0"
__author__ = "Geoscience Australia"
__email__ = "maruf.rahman@ga.gov.au"
__license__ = "Apache License, Version 2.0"
__copyright__ = "2020 %s" % __aut... |
def singleton(clazz):
assert clazz
assert type(clazz) == type
clazz.instance = clazz()
clazz.INSTANCE = clazz.instance
return clazz
#
|
class StartupPlugin:
pass
class EventHandlerPlugin:
pass
class TemplatePlugin:
pass
class SettingsPlugin:
pass
class SimpleApiPlugin:
pass
class AssetPlugin:
pass
|
"""
# Example:
not:10 # Table definition, arity 1.
1=not 0 # Assertion (as documentation/check)
0=not 1
and:0001 # Table definition, arity 2.
0=and 0 0
0=and 0 1
0=and 1 0
1=and 1 1
or:0111
0=or 0 0
1=or 0 1
1=or 1 0
1=or 1 1
mux:00110101 # Table definition, arity 3.
t<and 0 0 # Assignm... |
#!/usr/bin/env python3 -tt
print(2+3)
print("hello")
print("after commit")
|
#start reading file with datarefs
file = open("datarefex.txt")
line = file.read().replace("\n", "\n")
print(len(line))
#end reading file with datarefs
#convert into proper amount of parts
separated_string = line.splitlines()
print(len(separated_string))
#end
string2 = '"'
string ='": { "prefix": "'
strin... |
#!/usr/bin/python
class ListNode(object):
def __init__(self, x):
self.val = x
self.next = None
class Solution(object):
def addTwoNumbers(self, l1, l2):
carry = 0
ret = ListNode(0)
curr = ret
while l1 != None or l2 != None or carry != 0:
if l1 == None... |
#Desenvolva um programa que leia o primeiro termo e a razão de uma PA. E no final, mostre a soma dos 10 primeiros termos da progressão.
print('\033[33m-=10-TERMOS-DE-UMA-PA=-\033[m') #titulo
primeiro = int(input('Primeiro termo: ')) #input do primeiro termo da PA
razão = int(input('Razão: ')) #input da razao da PA
deci... |
"""
47 / 47 test cases passed.
Runtime: 36 ms
Memory Usage: 15 MB
"""
class Solution:
def deleteAndEarn(self, nums: List[int]) -> int:
freq = [0] * (max(nums) + 1)
for num in nums:
freq[num] += num
last, curr = 0, 0
for cnt in freq:
last, curr = curr, max(curr... |
#program to convert a byte string to a list of integers.
word = b'Darlington'
print()
print(list(word))
print()
# the reverse operation
n = [68,97,114]
print(bytes(n)) |
class Solution:
def addBinary(self, a: str, b: str) -> str:
a = int(a, 2)
b = int(b, 2)
result = a + b
result = bin(result)
return (result[2:]) |
print("\nHeyy there! Welcome to Marvel quotes machine.\n")
print("What is your name human ?\n")
user_name = input()
print(f"\nHeyy {user_name}, select corresponding numbers in front of your favorite superhero/villain to get one or two quotes related to them ;) ")
print("\n 1. Captain America\n 2. Iron Man\n 3. Spid... |
cont = maior = menor = 0
valores = list()
for i in range(0, 5):
valores.append(int(input(f'Digite um valor para a posoção {i}: ')))
'''if i == 0:
maior = menor = valores[i]
else:
if valores[i] > maior:
maior = valores[i]
if valores[i] < menor:
menor = valores[... |
# ------------------------------------------------------------------------------------
# Tutorial on f-strings
# Using f-strings is a simple and fast method for String formatting
# ------------------------------------------------------------------------------------
# # Syntax of f-strings:
# We start the string with ... |
a=[1,4,5, 67,6]
print(a)
print(a[3])
print("The index 0 element before changing ", a[0])
a[0]= 7
print("The index 0 element after changing ", a[0])
print(a)
# we can create a list with diff data types
b=[4,"dishant" , False, 8.7]
print(b)
# LIST SLICING
names=["harry", "dishant", "kanta", 45]
print(names[0:2])
... |
programs = {}
test_amount = 2000
def create_entry(string):
number, connections = string.split(" <-> ")
number = int(number)
connections = list(map(int, connections.split(", ")))
programs[number] = [None, connections]
def get_group_mem(group):
programs[group][0] = group
for x in range(0, test_a... |
"""
=========
cysofa
=========
Utilities and Python wrappers for sofa module
"""
__version__ = '0.1' |
#Dado un string, escribir una funcion que cambie todos los espacios por guiones.
string='Hola Mundo hola mundo HOLA MUNDO Hola Mundo hola mundo HOLA MUNDO Hola Mundo hola mundo HOLA MUNDO Hola Mundo hola mundo HOLA MUNDO Hola Mundo hola mundo HOLA MUNDO Hola Mundo hola mundo HOLA MUNDO Hola Mundo hola mundo HOLA MUNDO... |
class Int64Converter(BaseNumberConverter):
"""
Provides a type converter to convert 64-bit signed integer objects to and from various other representations.
Int64Converter()
"""
|
n=int(input("Enter a Number: "))
p=0
temp=n
while(temp > 0):
p = p+1
temp = temp // 10
sum=0
temp=n
while(temp > 0):
rem = temp % 10
sum = sum + (rem**p)
temp = temp // 10
if(n==sum):
print("Armstrong")
else:
print("Not Armstrong") |
#!/usr/bin/env python
"""
@package nilib
@file file_store.py
@brief Dummy module that indicates that the cache should use all filesystem
@brief for both content and metadata.
@version $Revision: 1.00 $ $Author: elwynd $
@version Copyright (C) 2012 Trinity College Dublin and Folly Consulting Ltd
This is an adjunct... |
#
# Copyright 2020 File Based Test DriverL Authors
#
# 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 ... |
# Generated by rpcgen.py at Mon Mar 8 11:09:57 2004
__all__ = ['MNTPATHLEN', 'MNTNAMLEN', 'FHSIZE2', 'FHSIZE3', 'MNT3_OK', 'MNT3ERR_PERM', 'MNT3ERR_NOENT', 'MNT3ERR_IO', 'MNT3ERR_ACCES', 'MNT3ERR_NOTDIR', 'MNT3ERR_INVAL', 'MNT3ERR_NAMETOOLONG', 'MNT3ERR_NOTSUPP', 'MNT3ERR_SERVERFAULT', 'mountstat3_id', 'MOUNTPROC_NUL... |
for _ in range(int(input())):
n = int(input())
s = input()
if '.' not in s:
print("0")
continue
if '*' not in s:
print("0")
continue
if s.count('*')==1:
print("0")
continue
count = s.count('*')
if count%2==0:
mid = count//2
else:
... |
"""
Copyright (C) 2020 Argonne, Hariharan Devarajan <hdevarajan@anl.gov>
This file is part of DLProfile
DLIO is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the published by the Free Softw... |
# AUTOGENERATED BY NBDEV! DO NOT EDIT!
__all__ = ["index", "modules", "custom_doc_links", "git_url"]
index = {"StopExecution": "00_core.ipynb",
"skip": "00_core.ipynb",
"run_all": "00_core.ipynb",
"set_google_application_credentials": "00_core.ipynb",
"PROJECT_ID": "01_constants.ip... |
if __name__ == '__main__':
n = int(input())
result = []
for _ in range(n):
operator, *operands = input().split()
operands = [int(x) for x in operands]
if (operator == 'insert'):
result.insert(operands[0], operands[1])
elif (operator == 'remove'):
resul... |
"""A dummy test."""
def test_remove() -> None:
"""A dummy test."""
assert True
|
class NumberPowerTwo:
"""Class to implement an iterator of powers of two
"""
def __init__(self, max=0):
self.max = max
def __iter__(self):
self.n = 0
return self
def __next__(self):
if self.n <= self.max:
result = 2 ** self.n
self.n += 1
... |
class PointCloudObject(RhinoObject):
# no doc
def DuplicatePointCloudGeometry(self):
""" DuplicatePointCloudGeometry(self: PointCloudObject) -> PointCloud """
pass
PointCloudGeometry = property(
lambda self: object(), lambda self, v: None, lambda self: None
)
"""Get... |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
cornerBuffer = []
cornerSequence = []
class Corner:
cornerCount = 0
cornerIndex = []
cornerColor = []
def solveCorner(self,sides,cornerPriority):
cornerGoal = (sides['U'][0]=='U' and sides['U'][2]=='U' and sides['U'][6... |
num1 = int(input("Escreva o primeiro número: "))
num2 = int(input("Escreva o segundo número: "))
soma = 0
for i in range(num1, num2 + 1):
print(i)
soma += i
print(soma)
|
# ========================
# Information
# ========================
# Direct Link: https://www.hackerrank.com/challenges/30-scope/problem
# Difficulty: Easy
# Max Score: 30
# Language: Python
# ========================
# Solution
# ========================
class Difference:
def __init__(self, a):
... |
class Solution:
def numsSameConsecDiff(self, N: int, K: int) -> List[int]:
ans = [i for i in range(1, 10)]
if N == 1:
return [0] + ans
digits = 10 ** (N-1)
while ans[0] / digits < 1:
cur = ans.pop(0)
last_digit = cur % 10
if K == 0:
... |
class Body:
supported_characteristics = ['m', 'mass',
'J', 'inertia']
def __init__(self, options):
for key in options.keys():
if key in Body.supported_characteristics:
val = options[key]
if key in ['m', 'mass']:
... |
# coding=utf-8
"""
最大间距
给定一个未经排序的数组, 请找出这个数组排序之后的两个相邻元素之间最大的间距.
如果数组中少于 2 个元素, 返回 0.
思路: 这个和最小差思路一模一样
"""
class Solution:
"""
@param nums: an array of integers
@return: the maximun difference
"""
def maximumGap(self, nums):
# write your code here
if len(nums) < 2:
re... |
#!/usr/bin/env python3
#
## @file
# cache_args.py
#
# Copyright (c) 2020, Intel Corporation. All rights reserved.<BR>
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
''' Contains the help and description strings for arguments in the
cache command meta data.
'''
COMMAND_DESCRIPTION = ('Manages local cachin... |
# Binary Tree:
# 1. Every node has at most two children.
# 2. Each child node is labeled as being either a left child or a right child.
# 3. A left child precedes a right child in the order of children of a node.
# proper binary tree: each node has two or zero child.
class Tree:
""" Abstract base class representin... |
x=float(input('Qual a velocidade atual do carro?'))
v= x-60
v2= v*7
if x >= 61:
print(f'MULTADO! Você excedeu o limite permitido que é de 60km/h\nVocê deve pagar uma multa de R${v2}!')
print('Tenha um bom dia! Dirija com segurança! ') |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.