content stringlengths 7 1.05M |
|---|
"""
TRACK 3
Ask a user to write a short bio about themselves.
Sanitize the input making sure that there are no extra spaces at the beginning and at the end of the string.
Sanitize further the string, making sure that all the words are single spaced from one another using `.split()` and `.join()`.
Use `.count()` to det... |
# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program 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 2
# of the License, or (at your option) any later version.
#
# This program is distrib... |
def convert_to_numeric(score):
"""
Convert the score to a numerical type.
"""
converted_score = float(score)
return converted_score
def sum_of_middle_three(score1, score2, score3, score4, score5):
"""
Return sum of 3 middle scores
"""
min_score = min(score1, score2, score3, score4, ... |
example = """
start-A
start-b
A-c
A-b
b-d
A-end
b-end
""".strip()
f = open("input/12.input")
text = f.read().strip()
def parse(t):
graph = {}
for line in t.split("\n"):
left, right = line.split('-')
if left not in graph:
graph[left] = set()
if right not in graph:
... |
def verif(s):
stringPair = ""
stringImpair = ""
# création des deux trucs
for i in range(len(s)):
if i % 2 == 0: # pair
stringPair += s[i]
else: # impair
stringImpair += s[i]
# check de la taille du truc
if len(s) % 2 != 0:
return False
ex... |
print ('=====Crie um programa que pergunte seu nome, e imprima, É um prazer te conhecer====')
nome=input('Qual seu nome?')
#print ('É um prazer te conhecer', nome,'!')
#Metodo do professor,{} - esse bloco sera substituido pelo format
print ('É um prazer te conhecer, {}!'.format(nome))
|
# -*- coding: utf-8 -*-
def get_config():
"""Get default configuration credentials."""
return {
"firewall": {
"interface": "",
"inbound_IPRule": {
"action": "0",
"ip_inbound": ""
},
"outbound_IPRule": {
"action": "0",
"ip_outbound": ""
},
"p... |
#
# @lc app=leetcode.cn id=1283 lang=python3
#
# [1283] reformat-date
#
None
# @lc code=end |
# Copyright (c) 2019-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
def f_gold ( n ) :
count = 0 ;
curr = 19 ;
while ( True ) :
sum = 0 ;
x = curr ;
while ( x >... |
types = {
"_car_way": "motorway|motorway_link|primary|primary_link|secondary|secondary_link|tertiary|tertiary_link|residential|living_street|service_road|unclassified",
"_pedestrian_way": "footway|steps|path|track|pedestrian_street",
"address_housenumber": '["addr:housenumber"]',
"address_street": '["ad... |
# coding=utf8
# Copyright 2018 JDCLOUD.COM
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed ... |
class Solution:
def maxPerformance(self, n: int, speed: List[int], efficiency: List[int], k: int) -> int:
modulo = 10 ** 9 + 7
# (efficiency, speed)
metrics = zip(efficiency, speed)
metrics = sorted(metrics, key=lambda t:t[0], reverse=True)
speed_heap = []
speed_sum... |
point_dict = {}
class face_c:
def __init__(self, data_string) -> None:
# data string is in format "p1,p2,p3"
data = data_string.split(",")
self.points = [point_dict[p] for p in data]
def __repr__(self) -> str:
result = "\nfacet normal 0 0 0\n\touter loop"
for point in ... |
#
# PySNMP MIB module VMWARE-CIMOM-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/VMWARE-CIMOM-MIB
# Produced by pysmi-0.3.4 at Wed May 1 15:34:48 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar ... |
class Solution:
def smallestRangeI(self, nums: List[int], k: int) -> int:
a = min(nums)
b = max(nums)
return max(b - a - 2 * k, 0)
|
# Number Spiral diagonals
def indexed_odd_number(num):
counter = 0
while num != 1:
num -= 2
counter += 1
return counter
spiral_dimension = 1001
sum_diagonals = 1
temp_num = 1
for i in range(indexed_odd_number(spiral_dimension)):
for j in range(4):
temp_num += ... |
'''
Created on Jun 6, 2019
@author: Winterberger
'''
class Menu:
def __init__(self, name, items, start_time, end_time):
'''
print(name + " is served from %d to %d." % (start_time, end_time))
'''
self.name = name
self.items = items
self.start_time = start_... |
#!/usr/bin/env python
# coding: utf-8
# In[ ]:
#冒泡排序的思想:
#比较相邻的元素,如果是逆序,则交换
# bubble
def bubble(a):
ret = False
while(not ret):
for i in range(0,len(a)-1):
if a[i] >a[i+1]:
ret = True
else:
temp = a[i]
a[i] = a[i... |
"""
0059. Spiral Matrix II
Medium
Given a positive integer n, generate an n x n matrix filled with elements from 1 to n2 in spiral order.
Example 1:
Input: n = 3
Output: [[1,2,3],[8,9,4],[7,6,5]]
Example 2:
Input: n = 1
Output: [[1]]
Constraints:
1 <= n <= 20
"""
class Solution:
def generateMatrix(self, n:... |
#
# PySNMP MIB module HUAWEI-MC-TRUNK-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HUAWEI-MC-TRUNK-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 19:34:48 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default... |
class MyHashSet:
def __init__(self):
"""
Initialize your data structure here.
"""
self.set = [0] * 1000001
def add(self, key: int) -> None:
"""Running time: O(1)
"""
self.set[key] = 1
def remove(self, key: int) -> None:
"""... |
_base_ = [
'../_base_/datasets/kitti.py',
'../_base_/default_runtime.py', '../_base_/schedules/schedule_cos20x.py'
]
model = dict(
type = 'Adabins',
# model training and testing settings
max_val=80,
train_cfg=dict(),
test_cfg=dict(mode='whole'))
find_unused_parameters=True |
#Inicio
print("Buenos dias")
#ingreso de datos
años=int(input("Ingrese sus años labor:"))
sueldo=float(input("Ingrese su sueldo laboral:"))
#Proceso
sueldototal=0.0
sueldototal1=0.0
sueldototal2=0.0
if años>2 and años<5:
sueldototal1=(sueldo*0.2)
else:
sueldototal1=(sueldo*0.3)
if sueldo<1000:
sueldototal2=(sue... |
class Communicator:
def __init__(self, nid, n_delay, in_lim, out_lim, out_conns):
self.ins =set()
# self.ordered_outs = out_conns
self.outs = set(out_conns)
self.id = nid
self.node_delay = n_delay
self.in_lim = in_lim
self.out_lim = out_lim
... |
class User:
user_list =[]
'''
class that defines user blueprint
'''
def __init__(self,username,password,email):
self.username = username
self.password = password
self.email = email
def save_user(self):
'''
function that saves new user objects
'''
User.user_list.append(self)
... |
#!/usr/bin/env python
head_joints = [
'head_sidetilt_joint',
'head_pan_joint',
'head_tilt_joint',
]
right_arm_joints = [
'right_arm_shoulder_rotate_joint',
'right_arm_shoulder_lift_joint',
'right_arm_elbow_rotate_joint',
'right_arm_elbow_bend_joint',
'right_arm_wrist_bend_joint',
... |
class ConfigException(Exception):
"""Handles the Exceptions concerning the Configuration file such as :
- absence of the file
- absence of one of the necessary fields
"""
def __init__(self, error_message=None):
if not error_message:
error_message = 'The config file is mi... |
#lamex1------Lambda Function
big=lambda a,b: a if a>b else b
#Main Program
num1 = int(input("Enter First number:"))
num2 = int(input("Enter Second number:"))
print("{0} is bigger".format(big(num1,num2))) |
load("@bazel_skylib//rules:write_file.bzl", "write_file")
def update_doc(doc_provs, doc_path = "doc"):
"""Defines an executable target that copies the documentation from the output directory to the workspace directory.
Args:
doc_provs: A `list` of document provider `struct` values as returned
... |
stmttype='''
typedef enum EStmtType {
sstunknown,sstinvalid,sstselect,sstdelete,sstupdate,
sstinsert,sstcreatetable,sstcreateview,sstsqlpluscmd, sstcreatesequence,
sstdropsequencestmt,sstdroptypestmt,sstplsql_packages,sstplsql_objecttype,sstcreate_plsql_procedure,
sstcreate_plsql_funct... |
__author__ = 'Tony Beltramelli - www.tonybeltramelli.com'
__modified = 'Kevin Kössl'
CONTEXT_LENGTH = 48
IMAGE_SIZE = 160
BATCH_SIZE = 64
EPOCHS = 10
STEPS_PER_EPOCH = 72000
|
def bool_or_str(value: str):
if value == 'True':
return True
if value == 'False':
return False
return value
def clean_line(line: str) -> str:
"""Split/tokenize a line with keywords and parameters.
TODO: rewrite using grammar or lexer?
"""
pieces = ['']
quote = ''
p... |
linha1 = input().split(" ")
linha2 = input().split(" ")
c1, n1, v1 = linha1
c2, n2, v2 = linha2
valor_pago = (int(n1) * float(v1)) + (int(n2) * float(v2))
print("VALOR A PAGAR: R$ {:.2f}".format(valor_pago)) |
CryptoCurrencyCodes = [
'ADA',
'BCH',
'BTC',
'DASH',
'EOS',
'ETC',
'ETH',
'LTC',
'NEO',
'XLM',
'XMR',
'XRP',
'ZEC',
]
def is_CryptoCurrencyCode(text):
return text.upper() in CryptoCurrencyCodes |
class ExceptionHandler:
def __init__(self, application, driver_config=None):
self.application = application
self.drivers = {}
self.driver_config = driver_config or {}
self.options = {}
def set_options(self, options):
self.options = options
return self
def ad... |
def perform_tsne(X, y, perplexity=100, learning_rate=200, n_components=2):
tsne = TSNE(n_components=n_components, init='random',
random_state=None, perplexity=perplexity, verbose=1)
result = tsne.fit_transform(X)
result = pd.DataFrame(result)
result = result.join(y)
result.c... |
# Definition for singly-linked list.
class ListNode(object):
def __init__(self, x):
self.val = x
self.next = None
# solution 1
# class Solution(object):
# def swapPairs(self, head):
# """
# :type head: ListNode
# :rtype: ListNode
# """
# if head == None:... |
lista_pessoas = list()
dados_pessoas = dict()
while True:
dados_pessoas['nome'] = str(input('Nome: ')).title()
dados_pessoas['sexo'] = str(input('Sexo[M/F]: ')).upper()
dados_pessoas['idade'] = int(input('Idade: '))
lista_pessoas.append(dados_pessoas.copy())
opcao = str(input('Quer continuar ? [S/N... |
top_twenty = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine",
"ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"]
tens = ["", "", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"]
def num_digi... |
"""
Example: Design an algorithm to print all permutations of a string.
For simplicity, assume all characters are unique.
abcd
abdc
acbd
acdb
adbc
adcb
"""
def fac(iteration):
if iteration <= 1:
return 1
else:
return iteration * fac(iteration-1)
def perm(remainder, parsed):
if not remai... |
get_market_book_success = {
'data': {
'getMarketBook': {
'dynamicPriceExpiry': 1612756694,
'orders': {
'edges': [
{
'cursor': 'MQ',
'node': {
'coinAmount': '0.00963874',
... |
def Draw(w, h, gridscale, ox, oy):
stroke(0)
strokeWeight(1)
line(ox, 0, ox, h)
line(0, oy, w, oy)
stroke(175, 175, 175)
strokeWeight(1)
for x in range(w / gridscale / 2):
gx = (x + 1) * gridscale
line(ox + gx, 0, ox + gx, h)
line(ox - gx, 0, ox - gx, h)
for y... |
'''
Crie um programa que leia dois números e mostre a soma entre eles.
'''
print('===== Exercício 03 =====')
n1 = int(input('Digite um número: '))
n2 = int(input('Digite outro número: '))
print('A soma entre', n1, 'e', n2, 'é', n1+n2)
print('A soma entre {} e {} vale {}'.format(n1, n2, n1+n2))
print(f'A soma entre {n1... |
n, m = map(int, input().split())
matrix = []
for row in range(n):
for col in range(m):
first_and_last = chr(ord("a") + row)
middle = chr(ord("a") + row + col)
print(f"{first_and_last}{middle}{first_and_last}", end=" ")
print()
|
class Solution:
def sortedSquares(self, nums: List[int]) -> List[int]:
token = 0
for i in nums:
temp = i**2
nums[token] = temp
token += 1
nums = sorted(nums, reverse=False)
return nums
# return sorted(x*x for x in nums)
|
def verify_browser_exists(browser):
raise RuntimeError('Browser detection and automatic selenium updates are not yet available for Linux distributions!\nPlease update your selenium driver manually.')
def get_browser_version(browser):
raise RuntimeError('Browser version detection and automatic selenium updates are not... |
n = int(input('Enter A Number:'))
i = 1
a = 2
while i <= n:
j = 1
while j <= i:
print(j*2, end=' ')
j += 1
i += 1
print()
|
#ANÁLISE DE DADOS
#Ler 4 valores e salvar numa tupla
#
# Este código também testa se os valores estão dentro do range
# Também gera mensagem de ausência de número par, se houver
#
while True:
n1 = int(input('Valor1?[0-9] '))
if 0 <= n1 <= 9:
n2 = int(input('Valor2? [0-9]: '))
if 0 <= n2 <= 9:
... |
# String matching algorithms
word = "axascass"
pattern = "ssaafasdasdcasaxqwdwdascassaxascassawdqwxascassaxascassaxascassaxascass"
def find_match(word, pattern):
j = 0;
if(len(word) > len(pattern)):
return -1
for i in range(0, len(pattern)):
if(word[j] == pattern[i]):
j+=1
else:
j = 0
if(j == len(wor... |
# Copyright 2020 Board of Trustees of the University of Illinois.
#
# 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 ... |
# coding=utf8
class Phase(object):
'''
Classe Phase définissant une période d'une semaine pour un chantier
Attributs publics:
- num : identifiant unique d'une phase (int)
- numSite : identifiant du chantier associé a la phase (int)
- numWeek : le numéro de la semaine de la phase (int)
... |
emqx_bills_hour_aggr_sql = """
INSERT INTO emqx_bills_hour("countTime",
"msgType", "msgCount", "msgSize", "tenantID")
SELECT date_trunc('hour', current_timestamp - INTERVAL '1 hour') AS "countTime",
emqx_bills."msgType" AS "msgType",
COUNT(*... |
num_l = num_o = num_v = num_e = 0
for i in input()[::-1]:
if i == "e":
num_e += 1
elif i == "v":
num_v += num_e
elif i == "o":
num_o += num_v
elif i == "l":
num_l += num_o
print(num_l)
|
# redis 的配置
rd_window = ['192.168.50.163', 6379, 0]
rd_one = ['192.168.50.163', 6379, 1]
rd_two = ['192.168.50.163', 6379, 2]
rd_three = ['192.168.50.163', 6379, 3] |
pkgname = "libxpm"
pkgver = "3.5.13"
pkgrel = 0
build_style = "gnu_configure"
hostmakedepends = ["pkgconf", "gettext-tiny"]
makedepends = ["xorgproto", "libsm-devel", "libxext-devel", "libxt-devel"]
pkgdesc = "X PixMap library"
maintainer = "q66 <q66@chimera-linux.org>"
license = "MIT"
url = "https://xorg.freedesktop.o... |
# We can check the divisibility by 3 by taking the sum of digits.
# If remainder is 0, we consider it as it is. If remainder is 1 or 2 we can combine them greedily.
# We can then combine 3 numbers each with remainder 1 or 2.
def sum_of(n):
s = 0
num = n
while(num>0):
s+=num%10
num = num//10
return s
for i in r... |
class Solution:
def subsets(self, nums):
"""O(n^2) | not sure"""
self.result = [[]]
def helper(start, nums, prev_set):
for i in range(start, len(nums)):
if nums[i] not in prev_set:
new_set = set(prev_set)
new_set.add(nums[i]... |
"""
The new "Avengers" movie has just been released! There are a lot of people at the cinema box office standing in a huge line. Each of them has a single 100, 50 or 25 dollar bill. An "Avengers" ticket costs 25 dollars.
Vasya is currently working as a clerk. He wants to sell a ticket to every single person in this li... |
# -*- coding: utf-8 -*-
""" gcrlm/core/exceptions/crlm """
class NoRoiClusters(RuntimeError):
"""
Exception to be raised by
Data/Prepare_patches/CRLM.CRLM.extract_annotations_and_masks setting
inside_roi to True but not providing roi_clusters
"""
def __init__(self, message=''):
""" In... |
#deleting duplicate elements from lists
def delete(a):
temp=[]
for i in range(0,len(a)):
if a[i] not in temp:
temp.append(a[i])
print(temp)
a=[]
ac=input("enter count of array")
for i in range(0,ac):
a.append(input())
delete(a)
|
class NDBC:
"""NDBC class provides convenient access to NDBC's API.
Instances of this class are the gateway to interacting with National
Data Buoy Center (NDBC) through `buoy-py`. The canonical way to obtain
an instance of this class is via:
.. code-block:: python
import buoypy as bp
... |
"""
input your key and secret for neurio here
"""
key = None
secret = None
|
list =[1,2,3,4,5,6,]
def change_list(mode,number):
if mode =='add':
list.append(number)
elif mode == 'remove' and number in list:
list.remove(number)
elif mode =='pop':
if number >= len(list):
print('вы вели слишком большое число')
else:
list.pop(number... |
""" Intersection and Union of Two Arrays: Another approach would be to create one set and check from other array """
def intersection(arr, arr2) -> int:
set1 = set(arr)
set2 = set(arr2)
print(set1.intersection(set2))
return len(set1.intersection(set2))
def union(arr, arr2) -> int:
set1 = set(ar... |
_base_ = [
'../../_base_/models/swav/r18.py',
'../../_base_/datasets/imagenet/swav_mcrop-2-6_sz224_96_bs32.py',
'../../_base_/default_runtime.py',
]
# interval for accumulate gradient
update_interval = 8 # total: 8 x bs64 x 8 accumulates = bs4096
# additional hooks
custom_hooks = [
dict(type='SwAVHoo... |
def verify(isbn):
characters = list(isbn.replace("-", ""))
if characters and characters[-1] == "X":
characters[-1] = "10"
if not len(characters) == 10 or not all(char.isdigit() for char in characters):
return False
indices = range(10, 0, -1)
return sum(int(char) * index for char, ... |
#!/usr/local/bin/python3
"""Task
The AdvancedArithmetic interface and the method declaration for the abstract divisorSum(n) method are provided for you in the editor below.
Complete the implementation of Calculator class, which implements the AdvancedArithmetic interface.
The implementation for the divisorSum(n) me... |
number = int(input("Podaj liczbę: "))
divisor = int(input("Przez jaką liczbę chcesz dzielić: "))
def check_zero(number):
check_number = str(number)
if check_number.count("0") != 0 or len(set(check_number)) != len(check_number):
return False
return True
if check_zero(number) == True:
divisors ... |
# Write a Python program to find the type of the progression (arithmetic progression/geometric progression) and the next successive member of a given three successive members of a sequence.
# According to Wikipedia, an arithmetic progression (AP) is a sequence of numbers such that the difference of any two successive m... |
X, Y = map(int, input().split())
if abs(X-Y) <= 2:
print('Yes')
else:
print('No')
|
class TimeInForceEnum:
TIF_UNSET = 0
TIF_DAY = 1
TIF_GOOD_TILL_CANCELED = 2
TIF_GOOD_TILL_DATE_TIME = 3
TIF_IMMEDIATE_OR_CANCEL = 4
TIF_ALL_OR_NONE = 5
TIF_FILL_OR_KILL = 6
|
OVER5_HEALTH_INDICATORS = dict(
app="mvp_over5",
indicators=dict(
over5_health=dict(
over5_positive_rdt=dict(
description="No. Over5 who received positive RDT Result",
title="# Over5 who received positive RDT Result",
indicator_key="over5_posit... |
'''
Created on Nov 11, 2018
@author: nilson.nieto
'''
lst = [1,4,431,24,1,4,234,2,1,128]
print(list(filter(lambda a : a%2==0,lst))) |
n = float(input('qual o preço do produto R$:'))
x = n*5
d = x / 100 # d = desconto
print('O produto que custava R${}, na promoção de 5% vai custar R${:.2f}'.format(n, n - d))
|
#!/usr/bin/env python
# coding: utf-8
# In[3]:
n = int(input())
hobbits = 0
humanos = 0
elfos = 0
anoes = 0
magos = 0
for _ in range(0, n):
raca = input().split()[1]
if raca == 'X':
hobbits += 1
elif raca == 'H':
humanos += 1
elif raca == 'E':
elfos += 1
elif raca == 'A'... |
#
# PySNMP MIB module FRDTE-OPT-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/FRDTE-OPT-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 19:02:28 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 201... |
"""
[07/01/13] Challenge #131 [Easy] Who tests the tests?
https://www.reddit.com/r/dailyprogrammer/comments/1heozl/070113_challenge_131_easy_who_tests_the_tests/
# [](#EasyIcon) *(Easy)*: Who tests the tests?
[Unit Testing](http://en.wikipedia.org/wiki/Unit_testing) is one of the more basic, but effective, tools for ... |
with open("input2.txt", "r") as f:
tx = f.read()
base_program = list(map(int, tx.split(",")))
# only solution 2 is here but solution 1 can be found by setting noun and verb
def run_to_halt(program, noun, verb):
program[1] = noun
program[2] = verb
for index, opcode in list(enumerate(program))[::4]:
if opco... |
nombres=["Juan", "murcielago", "Alejandro"]
vocales=["a","e","i","o","u"]
conteo_vocales =[]
for nombre in nombres:
for letra in nombre:
if letra not in vocales:
continue
else:
print(letra)
conteo_vocales.append(letra)
print(conteo_voca... |
# This is here to allow a sub-object that contains all of our crud information within the
# peewee model and avoid messing with model object data as much as possible
class ResponseMessages:
# Errors
ErrorDoesNotExist = 'Resource with id \'{0}\' does not exist'
ErrorTypeInteger = 'Value \'{0}\' must be an ... |
#
# PySNMP MIB module BAY-STACK-RADIUS-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/BAY-STACK-RADIUS-MIB
# Produced by pysmi-0.3.4 at Wed May 1 11:36:14 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (defau... |
d = int(input())
if d == 25:
ans = 'Christmas'
elif d == 24:
ans = 'Christmas Eve'
elif d == 23:
ans = 'Christmas Eve Eve'
elif d == 22:
ans = 'Christmas Eve Eve Eve'
print(ans)
|
pkgname = "gperf"
pkgver = "3.1"
pkgrel = 0
build_style = "gnu_configure"
make_cmd = "gmake"
hostmakedepends = ["gmake"]
pkgdesc = "Perfect hash function generator"
maintainer = "q66 <q66@chimera-linux.org>"
license = "GPL-3.0-or-later"
url = "https://www.gnu.org/software/gperf"
source = f"$(GNU_SITE)/{pkgname}/{pkgnam... |
'''
Author: Jon Ormond
Created: October 10th, 2021
Description: Simplified dragon text game, example of room movement.
Created for week 6 of the IT-140 class at SNHU.
Version: 1.0
'''
# A dictionary for the simplified dragon text game
# The dictionary links a room to other rooms.
rooms = {
'Great ... |
def merge2(lista1, lista2):
i1 = i2 = 0
lista3 = []
while i1 < len(lista1) and i2 < len(lista2):
if lista1[i1] < lista2[i2]:
if len(lista3) == 0 or lista3[-1] != lista1[i1]:
lista3.append(lista1[i1])
i1 += 1
else:
if len(lista3) == 0 or l... |
# 先定义这个类中的方法
def func(self, name='NJ'):
print('Student, %s.' % name)
# 用 type() 创建类,三个参数:类名、父类、类的方法
Student = type('Student', (object, ), dict(name = func))
h = Student()
h.name('Moxy')
h.name() |
"""
A traits-aware documentation tool.
Part of the ETSDevTools project of the Enthought Tool Suite.
:Author: David Baer
:Contact: dbaer@14853.net
:Organization: `Enthought, Inc.`_
:Copyright: Copyright (C) 2005 by `Enthought, Inc.`_
:Date: 2005-08-17
.. _`Enthought, Inc.` : http://www.enthought.com/
"""
|
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
# https://skyyen999.gitbooks.io/-leetcode-with-javascript/content/questions/24md.html
class Solution:
def swapPairs(self, head: ListNode) -> ListNode:
prev_p... |
'''
Given a list of numbers and a number k, return whether any two numbers from the list add up to k.
For example, given [10, 15, 3, 7] and k of 17, return true since 10 + 7 is 17.
Bonus: Can you do this in one pass?
'''
def check_2_numbers(anum, alist):
for x in alist:
#print(f'Start {x}')
for y ... |
#! /usr/bin/python
HOME_PATH = './'
CACHE_PATH = '/var/cache/obmc/'
FLASH_DOWNLOAD_PATH = "/tmp"
GPIO_BASE = 320
SYSTEM_NAME = "Palmetto"
## System states
## state can change to next state in 2 ways:
## - a process emits a GotoSystemState signal with state name to goto
## - objects specified in EXIT_STATE_DEPE... |
public_key = b"\x30\x82\x01\x22\x30\x0d\x06\x09\x2a\x86\x48\x86\xf7\x0d\x01\x01\x01\x05\x00\x03\x82\x01\x0f\x00\x30\x82\x01\x0a\x02\x82\x01\x01" + \
b"\x00\xc0\x86\x99\x9a\x76\x74\x9a\xf5\x04\xb8\x48\xf0\x7e\x67\xc3\x90\x51\x17\xe6\xcd\xb3\x97\x6b\x41\xbc\x4e\x4e\x0c\x30\xff\x57" + \
b"\xf1\x4... |
"""
pertinent_user.py
--------------
This class represents a pertinent user.
"""
__author__ = "Steven M. Satterfield"
class PertinentUser:
def __init__(self):
self._id = ""
self._participantid = ""
self._group = ""
self._userid = ""
def getId(self):
... |
class Solution(object):
def intersect(self, nums1, nums2):
"""
:type nums1: List[int]
:type nums2: List[int]
:rtype: List[int]
"""
dict = {}
for n in nums2:
if n not in dict:
dict[n] = 1
else:
dict[n] +=... |
class Solution:
def canVisitAllRooms(self, rooms: List[List[int]]) -> bool:
# we use this below list for checking whether all list have been visited or not
visited=[False]*len(rooms)
# per condition room 0 is always unlocked
visited[0]=True
#we use stack for acquiring key to ... |
def findDecision(obj): #obj[0]: Coupon, obj[1]: Education, obj[2]: Occupation, obj[3]: Restaurant20to50, obj[4]: Distance
# {"feature": "Coupon", "instances": 85, "metric_value": 0.9637, "depth": 1}
if obj[0]>1:
# {"feature": "Occupation", "instances": 56, "metric_value": 0.8384, "depth": 2}
if obj[2]<=7:
# {"... |
arr1= [50,60]
array = [1,2,3,4,5,6,7,8]
arr = []
arr.append(arr1[1])
print(arr) |
print(15 != 15)
print(10 > 11)
print(10 > 9) |
pares = []
impares = []
numeros = [pares , impares]
for i in range(1, 8):
numero = int(input('Digite o {}o. valor: '.format(i)))
if numero % 2 == 0:
pares.append(numero)
else:
impares.append(numero)
pares.sort()
impares.sort()
print('-='*20)
print('Os valores pares digitados foram: {}.'.fo... |
def sortedSquaredArray(array):
# Write your code here.
negatives = [] # This simulates a stack
squares = []
i = 0
while i < len(array):
if array[i] < 0: # If negative
negatives.append(abs(array[i]))
else:
if len(negatives) > 0: # If negatives stack has elements and current element is positive
top... |
class Car:
models = []
count = 0
def __init__(self, make, model):
self.make = make
self.model = model
Car.count += 1
@classmethod
def add_models(cls, make):
cls.models.append(make)
@staticmethod
def convert_km_to_mile(value):
return value / 1.609344... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.