content stringlengths 7 1.05M |
|---|
#
# Copyright (C) [2020] Futurewei Technologies, Inc.
#
# FORCE-RISCV is 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
#
# THIS SOFTWARE IS PRO... |
'''
There is a horizontal row of cubes. The length of each cube is given. You need to create a new vertical pile of cubes.
The new pile should follow these directions: if cube_i is on top of cube_j then cube_j >= cube_i.
When stacking the cubes, you can only pick up either the
leftmost or the rightmost cube each ti... |
# coding: utf-8
# Copyright (c) Scanlon Materials Theory Group
# Distributed under the terms of the MIT License.
"""
Package containing functions for loading and manipulating phonon data.
"""
|
count = 0
soma = 0
num = 0
maior = 0
menor = 999999999999999999999999
resp = ''
while resp in 'Ss':
num = int(input('Digite um número: '))
resp = str(input('Deseja continuar [S/N]: '))
soma += num
if num > maior:
maior = num
if num < menor:
menor = num
count += 1
print('O MAIOR n... |
class Player:
def __init__(self, char='X'):
self.kind = 'human'
self.char = char
def move(self, board):
while True: #valid move
move = int(input('Your move? '))
if board[move] != "X" and board[move] != "O" and move >= 0 and move <= 9:
ret... |
#
# Nomalize Data
# (c) iomonad <iomonad@riseup.net>
#
FALLBACK_NAME = "Trappe d'accès"
layer = iface.activeLayer()
layer.startEditing()
for feature in layer.getFeatures():
if not feature['name']:
layer.changeAttributeValue(feature.id(), 0, FALLBACK_NAME)
continue
layer.changeAttributeValue... |
#: Common folder in which the data file are related.
DATA_ROOT_FOLDER = '/Users/mdartiailh/Labber/Data/2019/'
#: Dictionary of parallel field, file path.
DATA_PATHS = {400: '03/Data_0316/JS124S_BM002_390.hdf5',
# 350: '03/Data_0317/JS124S_BM002_392.hdf5',
# 300: '03/Data_0318/JS124S_BM002_3... |
def poly_conversion_array(eq, var):
poly = eq.split()
coeffPower = []
i = 1
while i < len(poly):
poly.insert(i, poly[i] + poly[i + 1])
poly.pop(i + 1)
poly.pop(i + 1)
i += 1
for j in poly:
cp = j.split(var)
if len(cp) == 1:
cp.append(0)
... |
a = 50
print('\033[32m_\033[m' * a)
print(f'\033[1;32m{"SISTEMA DE CALCULO DE AREA":=^{a}}\033[m')
print('\033[32m-\033[m' * a)
def area(a, b):
tot = a * b
print(f'\033[1;34mA area de um terreno de {a:.2f} x {b:.2f} é de {tot:.2f}m².\033[m')
larg = float(input('\033[35mLargura do terreno (m): '))
comp = flo... |
def selection(arr):
for i in range(0, len(arr)):
# Min idx starts always at the ith element
min_idx = i
# Look for any local minima going forward
for j in range(i+1, len(arr)):
# If we find one, set the min_idx to what we find
if arr[j] < arr[mi... |
# This file will store strings for the entire app
# Error Strings
space_in_first_name_error = 'First name may not contain spaces'
space_in_last_name_error = 'Last name may not contain spaces'
# Dashboard Strings
my_projects = "My Projects"
no_projects = "Looks like you don't have any projects yet. Select Add project,... |
# Copyright 2020 The XLS 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 agreed to in writ... |
show_in_list = True
title = 'Detector Configuration'
motor_names = ['collect.detector_configuration', 'xray_scope.setup', 'laser_scope.setup']
names = ['detectors', 'xray_scope_setup', 'laser_scope_setup', 'motor2']
motor_labels = ['Detectors', 'X-ray Scope Setup', 'Laser Scope Setup']
widths = [280, 170, 170]
line0.xr... |
# MIT License
# (C) Copyright 2021 Hewlett Packard Enterprise Development LP.
#
# linkIntegrity : Link integrity and bandwidth test
def get_link_integrity_test_result(
self,
ne_id: str,
) -> dict:
"""Retrieve current link integrity test status/results from
appliance
.. list-table::
:heade... |
# Setters for the results dictionary
def set_error(name, message):
global _error
_error = {}
_error = {"Hostname": name, "Message": message}
return _error
def new():
return {
'Hostname': None,
'IP': None,
'MD5': None,
'View':... |
class FloorType(HostObjAttributes, IDisposable):
""" An object that specifies the type of a floor in Autodesk Revit. """
def Dispose(self):
""" Dispose(self: Element,A_0: bool) """
pass
def getBoundingBox(self, *args):
""" getBoundingBox(self: Element,view: View) -> Boundin... |
def GWO(lb, ub, dim, searchAgents_no, maxIters):
# Grey wolves 초기화
alpha_pos = np.zeros(dim) # The best search agent
alpha_score = float("inf")
beta_pos = np.zeros(dim) # The second best search agent
beta_score = float("inf")
delta_pos = np.zeros(dim) # The third best search agent
delta_sc... |
"""
description: delete-node-in-a-linked-list(删除链表中的节点)
author: jiangyx3915
date: 2018/10/13
请编写一个函数,使其可以删除某个链表中给定的(非末尾)节点,你将只被给定要求被删除的节点。
现有一个链表 -- head = [4,5,1,9],它可以表示为:
4 -> 5 -> 1 -> 9
说明:
链表至少包含两个节点。
链表中所有节点的值都是唯一的。
给定的节点为非末尾节点并且一定是链表中的一个有效节点。
不要从你的函数中返回任何结果。
结题思路
由于没有办法得到node的前节点,我们只... |
def get_input():
with open("input.txt", "r") as file:
return file.read()
def quiz1(data):
print(data.count("(") - data.count(")"))
def quiz2(data):
count = 0
for i, p in enumerate(data):
if p == ("("):
count += 1
if p == (")"):
count -= 1
if c... |
user = "DB_USER"
password = "DB_PASS"
token = "API_TOKEN"
valid_chats = []
|
# Copyright 2018 Google LLC
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, s... |
MASK = 0xffffffffffffffff
BLOCK_LEN_INT64 = 8
BLOCK_LEN_BYTES = 8 * BLOCK_LEN_INT64
blake2b_IV = [
0x6a09e667f3bcc908, 0xbb67ae8584caa73b,
0x3c6ef372fe94f82b, 0xa54ff53a5f1d36f1,
0x510e527fade682d1, 0x9b05688c2b3e6c1f,
0x1f83d9abfb41bd6b, 0x5be0cd19137e2179
]
def rotr(w, c):
return (w >> c) | (w ... |
class Solution:
def rotate(self, matrix: List[List[int]]) -> None:
"""
Do not return anything, modify matrix in-place instead.
"""
q = 0
m = len(matrix) - 1
while q < len(matrix) // 2:
c = 0
while c < len(matrix) - 1 - q * 2:
n... |
"""
"""
lengths = []
for len_file in snakemake.input:
with open(len_file, 'r') as lf:
lengths.append(int(lf.readline().strip()))
with open(snakemake.output[0], "w") as out_file:
print(min(lengths), file=out_file)
|
#!/usr/bin/env python3
# https://codeforces.com/problemset/problem/1208/A
# xor性质~~
def f(l):
a,b,n = l
l[2] = a^b
return l[n%3]
t = int(input())
for _ in range(t):
l = list(map(int,input().split()))
print(f(l))
|
#Author:Li Shen
#定义form公共类
class FormMixin(object):
#提取表单验证失败的错误信息
def get_errors(self):
#判断object对象中是否存在'errors'属性
if hasattr(self,'errors'):
errors = self.errors.get_json_data()
#新建一个字典用来装载提取出来的错误信息
new_errors={}
#遍历每个错误信息,因为errors是字典形式
... |
# https://leetcode.com/problems/valid-parentheses/
class Solution:
def isValid(self, s: str) -> bool:
stack = []
for c in s:
if c == ')':
if len(stack) > 0 and stack[-1] == '(':
stack.pop()
else:
return Fal... |
def create_lkas(packer, enabled, frame, lat_active, apply_steer):
values = {
"LKA_MODE": 2,
"LKA_ICON": 2 if enabled else 1,
"TORQUE_REQUEST": apply_steer,
"LKA_ASSIST": 1 if lat_active else 0,
"STEER_REQ": 1 if lat_active else 0,
"STEER_MODE": 0,
"SET_ME_1": 0,
"NEW_SIGNAL_1": 0,
... |
"""
7581. Cuboids
작성자: xCrypt0r
언어: Python 3
사용 메모리: 29,380 KB
소요 시간: 92 ms
해결 날짜: 2020년 9월 14일
"""
def main():
while True:
l, w, h, v = map(int, input().split())
if all(x == 0 for x in [l, w, h, v]): break
elif l == 0: l = v // w // h
elif w == 0: w = v // l // h
elif h =... |
# https://leetcode-cn.com/problems/binary-search/
def binary_search(nums, target):
if not nums:
return -1
if nums[0] > target or nums[-1] < target:
return -1
l, r = 0, len(nums) - 1
while l <= r:
m = l + (r - l) // 2
if nums[m] == target:
return m
e... |
def human_readable_size(size, decimal_places=2):
for unit in ['B','KB','MB','GB','TB']:
if size < 1024.0:
break
size /= 1024.0
return f"{size:.{decimal_places}f} {unit}"
|
def RemoveA(file1='Weird.txt',file2='WeirdButA.txt'):
f=open(file2,'a')
lst=open(file1,'r').readlines()
f1=open(file1,'w')
for x in lst:
if 'a' in x or 'A' in x:
f.write(x)
else:
f1.write(x)
f.close()
f1.close()
print(open(file1,'r').read(),open(file2,... |
pn = int(input('Digite o primeiro número: '))
sn = int(input('Digite o segundo número: '))
tn = int(input('Digite o terceiro número: '))
if pn > sn and pn > tn:
print('O primeiro número é o maior.'.format(pn))
if pn < sn and pn < tn:
print('O primeiro número é o menor'.format(pn))
if sn > pn and sn > tn:
pr... |
wt0_16_4 = {'192.168.122.111': [8.3103, 8.0392, 7.6612, 7.6962, 7.5176, 7.5481, 7.5683, 7.5518, 7.8167, 7.7147, 7.6347, 7.5667, 7.5034, 7.9934, 7.9606, 7.9429, 7.9216, 7.8997, 7.8826, 8.0898, 8.037, 8.36, 8.3285, 8.4888, 8.4126, 8.3655, 8.2986, 8.258, 8.2224, 8.1874, 8.1354, 8.1046, 8.2392, 8.2046, 8.1844, 8.1706, 8.1... |
couponTypeId = None
def getImportCouponTypeId(database):
if couponTypeId is not None:
return couponTypeId
with database.cursor as cursor:
query = "SELECT id FROM coupon_type WHERE type_name = 'IMPORTED'"
for row in cursor.execute(query):
return row.id
query = """IN... |
a=[]
for x in range(1,101):
if x%3==0:
a.append('Fizz')
elif x%5==0:
a.append('Buzz')
elif x%3==0 and x%5==0:
a.append("FizzBuzz")
else:
a.append(x)
print(*a)
|
def menu_tree_to_vue(menus):
res = []
for menu in menus:
tmp = {
'id': menu.id,
'name': menu.name,
'path': menu.path,
'component': menu.component,
'hidden': menu.is_show is False,
'meta': {
'title': menu.title,
... |
cube = lambda x: x ** 3 # complete the lambda function
def fibonacci(n):
# return a list of fibonacci numbers
a = 0
b = 1
for i in range(n):
yield a
a, b = b, a + b
def main():
n = int(input())
print(list(map(cube, fibonacci(n))))
if __name__ == '__main__':
main()
|
r1 = float(input('1° segmento: '))
r2 = float(input('2° segmento: '))
r3 = float(input('3° segmento: '))
print('==' * 20)
if r1 < r2 + r3 and r2 < r1 + r3 and r3 < r2 + r1:
print('Os segmentos acima FORMAM um triângulo!')
else:
print('Os segmentos NÃO FORMAM um triângulo!') |
'''
面试题57 - II. 和为s的连续正数序列
输入一个正整数 target ,输出所有和为 target 的连续正整数序列(至少含有两个数)。
序列内的数字由小到大排列,不同序列按照首个数字从小到大排列。
示例 1:
输入:target = 9
输出:[[2,3,4],[4,5]]
示例 2:
输入:target = 15
输出:[[1,2,3,4,5],[4,5,6],[7,8]]
限制:
1 <= target <= 10^5
'''
# test cases:
# 1. target<3: return []
# 2. no qualified result: input 4, 8...
# 3. normal t... |
#!/usr/bin/env python3
"""
Exception used in the AutoTag project
"""
class BaseAutoTagException(Exception):
"""Base exception for the AutoTag project."""
class DetectorValidationException(BaseAutoTagException):
"""Validation failed on a detector"""
class DetectorNotFound(BaseAutoTagException):
"""Vali... |
def get_x_request_id(metadata):
"""
Returning x-request-id from response metadata
:param metadata: response metadata from one of VoiceKit methods
return: None if x-request-id don't contain in metadata
"""
x_request_id = tuple(filter(lambda x: x[0] == 'x-request-id', metadata))
if x_requ... |
class Node:
def __init__(self, key="", val=-1, prev=None, next=None):
self.key = key
self.val = val
self.prev = prev
self.next = next
class LRUCache:
"""
@param: capacity: An integer
"""
def __init__(self, capacity):
self.capacity = capacity
self.map... |
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = ['*'] # TODO: to env
TIME_ZONE = 'Europe/Helsinki' # TODO: to env
FIRST_DAY_OF_WEEK = 1
MONTH_DAY_FORMAT = 'j F '
|
# Random Comment
x = 3
y = x + 2
y = y * 2
print(y)
|
a = ('zero', 'um', 'dois', 'três', 'quatro', 'cinco', 'seis', 'sete', 'oito', 'nove', 'dez', 'onze', 'doze', 'treze', 'cartoze', 'quinze')
n = int(input('DIGITE UM NÚMERO DE 0 A 15: '))
if n > 15 or n < 0:
while True:
n = int(input('DIGITE UM NÚMERO DE 0 A 15: '))
if 0 <= n <= 15:
break
... |
# Anti Diagonals
# https://www.interviewbit.com/problems/anti-diagonals/
#
# Give a N*N square matrix, return an array of its anti-diagonals. Look at the example for more details.
#
# Example:
#
# Input:
#
# 1 2 3
# 4 5 6
# 7 8 9
#
# Return the following :
#
# [
# [1],
# [2, 4],
# [3, 5, 7],
# [6, 8],
# [9]
#... |
def extractPenguTaichou(item):
"""
Pengu Taichou
"""
vol, chp, frag, postfix = extractVolChapterFragmentPostfix(item['title'])
if not (chp or vol or frag) or 'preview' in item['title'].lower():
return None
if item['title'].lower().startswith('sword shisho chapter'):
return buildReleaseMessageWithType(item, 'I... |
orders = ["daisy", "buttercup", "snapdragon", "gardenia", "lily"]
# Create new orders here:
new_orders = ["lilac", "iris"]
orders_combined = orders + new_orders
broken_prices = [5, 3, 4, 5, 4] + [4] |
# -*- coding: utf-8 -*-
"""
Tencent is pleased to support the open source community by making 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community
Edition) available.
Copyright (C) 2017-2021 THL A29 Limited, a Tencent company. All rights reserved.
Licensed under the MIT License (the "License"); you may not use this file except in co... |
# За студио, при повече от 7 нощувки през май и октомври : 5% намаление.
# За студио, при повече от 14 нощувки през май и октомври : 30% намаление.
# За студио, при повече от 14 нощувки през юни и септември: 20% намаление.
# За апартамент, при повече от 14 нощувки, без значение от месеца : 10% намаление.
month = input... |
nomes = [0,0,0,0,0,0,0,0,0,0]
telefone = [0,0,0,0,0,0,0,0,0,0]
i = 0
while(i < 2):
nomes[i]=input("Digite um nome... ")
telefone[i]=input("Digite o telefone respectivo ")
i+=1
i=nomes.index(input("Qual nome referente ao número desejado? "))
print(f"O número de {nomes[i]} é {telefone[i]}") |
# List Comprehension
# adalah metode untuk menambahkan anggota dari suatu list melalui for loop
# Syntax dari List Comprehension adalah
# [expression for item in iterable]
# Original List
original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
print(f"Original : {original}")
# Output = Original : [1, 2, 3, 4, 5, 6, 7... |
class Solution:
def sumBase(self, n: int, k: int) -> int:
r = 0
while n>0:
r += n%k
n = n//k
return r
|
##
#给定两个单词 word1 和 word2,计算出将 word1 转换成 word2 所使用的最少操作数 。
#
# 你可以对一个单词进行如下三种操作:
#
# 插入一个字符
# 删除一个字符
# 替换一个字符
# 示例 1:
#
# 输入: word1 = "horse", word2 = "ros"
# 输出: 3
# 解释:
# horse -> rorse (将 'h' 替换为 'r')
# rorse -> rose (删除 'r')
# rose -> ros (删除 'e')
# 示例 2:
#
# 输入: word1 = "intention", word2 = "execu... |
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "workspace_and_buildfile")
def _http_archive_impl(ctx):
"""Buildozer implementation of the http_archive rule."""
if not ctx.attr.url and not ctx.attr.urls:
fail("At least one of url and urls must be provided")
if ctx.attr.build_file and ctx.att... |
# Copyright 2021 Adobe. All rights reserved.
# This file is licensed to you under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. You may obtain a copy
# of the License at http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable la... |
# -*- coding: utf-8 -*-
"""
Created on Thu Jun 15 13:58:31 2017
MIT 6.00.1x course on edX.org: PSet3 P2
Next, implement the function getGuessedWord that takes in two parameters
- a string, secretWord, and a list of letters, lettersGuessed. This function
returns a string that is comprised of letters and underscores,... |
"""
anviz_sync
~~~~~~~~~~
Sync Anviz Time & Attendance data with specified database.
:copyright: (c) 2014 by Augusto Roccasalva
:license: BSD, see LICENSE for more details.
"""
__version__ = '0.1.0'
|
# This file is used by build_autocachebreakers.py
# Note: both outputs and breakers[n][1] are relative to this file's directory.
targets = [
{"output": "js_minerva/cw/net/autocachebreakers.js",
"breakers": [
("cw.net.breaker_FlashConnector_swf", "minerva/compiled_client/FlashConnector.swf"),
]},
]
|
class Solution(object):
# Runtime: 23 ms, faster than 68.57% of Python online submissions for String to Integer (atoi).00
# Memory Usage: 13.5 MB, less than 79.83% of Python online submissions for String to Integer (atoi).
def myAtoi(self, s):
"""
:type s: str
:rtype: int
... |
# Python program to print connected
# components in an undirected graph
# https://www.geeksforgeeks.org/connected-components-in-an-undirected-graph/
class Graph:
# init function to declare class variables
def __init__(self, V):
self.V = V
self.adj = [[] for i in range(V)]
def DFSUtil(self... |
"""
Question Source:Leetcode
Level: Medium
Topic: String
Solver: Tayyrov
Date: 25.02.2022
"""
def compareVersion(version1: str, version2: str) -> int:
v1 = list(map(int, version1.split(".")))
v2 = list(map(int, version2.split(".")))
dif = abs(len(v1) - len(v2))
extra = [0] * dif
if... |
#
# PySNMP MIB module NBS-NTP-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/NBS-NTP-MIB
# Produced by pysmi-0.3.4 at Wed May 1 14:17:23 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 0... |
# -*- coding: utf-8 -*-
"""
Created on Mon Jan 27 22:16:29 2020
@author: ghanta
"""
my_dict={}
filepath = 'output.txt'
with open(filepath) as fp:
line = fp.readline()
cnt = 1
while line:
# print("Line {}: {}".format(cnt, line.strip()))
my_dict[str(line.strip())] = cnt
line = fp.read... |
## Some utils for plots
clean_variable_names = {
"age": "Age",
"anosmia": "Anosmia",
"cough": "Cough",
"diarrhea": "Diarrhea",
"fever": "Fever",
"minor_severity_factor": "Number of minor severity factors",
"risk_factor": "Number of risk factors",
"sore_throat_aches": "Sore throat/aches"... |
"""LSD (least significant digit) string sort algorithm.
This algorithm is based on the Key-indexed counting sorting algorithm. The
main difference is that LSD run the same operation for W characters instead
of just 1 integer. It is assumed that strings are fixed length and that W
is the length of them.
Characteristics... |
#
# PySNMP MIB module JUNIPER-WX-STATUS-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/JUNIPER-WX-GLOBAL-MIB
# Produced by pysmi-0.3.4 at Wed May 1 14:01:32 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (def... |
def ordinal(number):
if number <= 0:
return 'none'
tmp = number % 100
if tmp >= 20:
tmp = tmp % 10
if tmp == 1:
return str(number) + 'st'
elif tmp == 2:
return str(number) + 'nd'
elif tmp == 3:
return str(number) + 'rd'
else:
return str(number)... |
def load_parse_data(path: str) -> list:
with open(path, mode='r', encoding="utf-8") as f:
return list(map(int, f.read().split(',')))
def school_by_age(data: list) -> list:
school_by_age = [0] * 9
for age in data:
school_by_age[age] += 1
return school_by_age
def model_school_growth(sc... |
scores = []
for i in range(5):
scores.append(sum([int(x) for x in input().split(" ")]))
topscore = 0
for score in scores:
if score > topscore:
topscore = score
index = scores.index(topscore) + 1
print(str(index) + " " + str(topscore))
|
"""
Dictionary Comprehension em Python - (Compreensão de
dicionários)
"""
lista = [
('chave', 'valor'),
('chave2', 'valor2'),
]
# d1 = {x: y*2 for x, y in lista}
d2 = {f'chave_{x}': x**2 for x in range(5)}
print(d2)
|
# Maior e menor peso
menor = maior = 0
for i in range(1, 6):
peso = float(input('Digite o seu peso em kg: '))
if i == 1:
menor = peso
maior = peso
else:
if peso < menor:
menor = peso
if peso > maior:
maior = peso
print()
print('O menor pes... |
lines = [line.strip() for line in open("input.txt", 'r') if line.strip() != ""]
tiles = []
# e - 0; se - 1; sw - 2; w - 3; nw - 4; ne - 5
directions = ((1, -1, 0), (0, -1, 1), (-1, 0, 1),
(-1, 1, 0), (0, 1, -1), (1, 0, -1))
for line in lines:
tile = []
while len(line) > 0:
if line[0] =... |
# 二叉搜索树,实现映射抽象数据类型。(之前用散列实现过)
# Map() / put(key,value) /del amap[key] / get(key) /len() /in
# 二叉搜索树:对任意一个节点,比节点值小的值放在左子值,大的放在右子树,也叫做二叉搜索性
# 必须处理并创建一颗空的二叉树,因此在实现的过程中必须使用两个类,涉及两个类的耦合问题
# put函数,新来的一定被放在最后,无论大小
class TreeNode(object):
def __init__(self, key, val, lc=None, rc=None, par=None):
self.ke... |
class Solution(object):
def intersection(self, nums1, nums2):
"""
:type nums1: List[int]
:type nums2: List[int]
:rtype: List[int]
"""
max_nums = nums1 if len(nums1) > len(nums2) else nums2
min_nums = nums1 if len(nums1) < len(nums2) else nums2
r_nums =... |
# insert CR, insert line above
keys(':setf vim\<CR>jw')
keys('4\<C-Down>')
keys('Ea')
keys('\<CR>')
keys('CARRYING OVER ')
keys('\<Esc>A')
keys('\<CR>')
keys('CR at EOL')
keys('\<Esc>k')
keys('O')
keys('above CR')
keys('\<Esc>\<Esc>')
|
# from AI_module import AI_module
def receive_basic_iuput_data(Singal_Loss, Shock_Alert, Oxygen_Supply, Fever, Hypotension, Hypertension):
# Recevie data from input module, then analyze it using some judge functions to generate boolean result
# Boolean Parameters
# If paramter returns True, means it shoul... |
# -*- coding: utf-8 -*-
"""Top-level package for dbix."""
__author__ = """Alex Bodnaru"""
__email__ = 'alexbodn@gmail.com'
__version__ = '0.3.0'
|
#
# PySNMP MIB module CISCO-RADIUS-EXT-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-RADIUS-EXT-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 17:53:51 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 isValidSudoku(self, board: List[List[str]]) -> bool:
for i in range(9):
check_r = dict()
check_c = dict()
check_b = dict()
print("_____")
for j in range(9):
print(check_r.keys(),check_c.keys(),check_b.keys())
... |
### Model data
class catboost_model(object):
float_features_index = [
0, 1, 2, 3, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 26, 28, 31, 32, 33, 35, 37, 38, 39, 46, 47, 48, 49,
]
float_feature_count = 50
cat_feature_count = 0
binary_feature_count = 36
tree_co... |
# http://codingbat.com/prob/p118366
def string_splosion(str):
result = ""
for i in range( len(str) ):
result += str[:i+1]
return result
|
# Python3
m, n = [int(i) for i in input().split()]
if n <= 1:
print(n)
quit()
lesser_n = (n+2) % 60
lesser_m = (m+1) % 60
def fibo(n):
a, b = 0, 1
for i in range(2, n+1):
c = a+b
c = c % 10
b, a = c, b
return (c-1)
if lesser_n <= 1:
a = lesser... |
links_file = open("link_queue.txt", "r")
link_queue = links_file.readlines()
go = []
count = 0
index = 0
while index < len(link_queue):
if link_queue[index].find("interforo") == -1:
go.append(link_queue[index])
del link_queue[index]
else:
index = index + 1
count = count + 1
... |
'''
有序链表转换二叉搜索树
给定一个单链表,其中的元素按升序排序,将其转换为高度平衡的二叉搜索树。
本题中,一个高度平衡二叉树是指一个二叉树每个节点 的左右两个子树的高度差的绝对值不超过 1。
'''
# Definition for singly-linked list.
class ListNode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
# Definition for a binary tree node.
class TreeNode:
def __init_... |
class DockablePanes(object):
""" Provides a container of all Revit built-in DockablePaneId instances. """
BuiltInDockablePanes = None
__all__ = [
"BuiltInDockablePanes",
]
|
# Escreva um programa que leia a velocidade de um carro. Se ele ultrapassar 80Km/h, mostre uma mensagem dizendo que ele foi multado. A multa vai custar R$7,00 por cada Km acima do limite.
v = float(input('Qual é a velocidade atual do carro? '))
if v > 80:
print('Multado!')
m = (v - 80) * 7
print(f'Você dev... |
class Run(dict):
attributes = ('nx', 'ny', 'nz', 'time', 'NbrOfCores', 'platform', 'configuration', 'repetitions', 'mpiargs', 'tag')
def __init__(self, serie, data, **kwargs):
super(Run, self).__init__(**kwargs)
self.data = data
self.parent = serie
for x in Run.attributes:
... |
AVAILABLE_THEMES = [
('suse', 'SUSE', 'themes/suse'),
('default', 'Default', 'themes/default'),
]
|
# Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution(object):
def deleteDuplicates(self, head):
"""
:type head: ListNode
:rtype: ListNode
"""
res=ListNode(0)
res.n... |
callback_classes = [
['ns3::ObjectBase *', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty'],
['void', 'ns3::Ptr<const ns3::MobilityModel>', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty... |
"""
Initial extension configuration implementations.
"""
|
# Copyright 2020 https://www.globaletraining.com/
# Generator send method
def simple_gen(start_number=10):
i = start_number
while True:
x = (yield i * 2)
if x: # check if used send()
i += x
else:
i += 1
gen1 = simple_gen()
print(gen1.__next__())
print... |
# g code generator for clay extrusions
def gCodeLine(generation):
def __init__(self, coordinates, z_val = True, extrusion_value = None, feed_value = None, absolute_relative = None):
self.X = coordinates.X
self.Y = coordinates.Y
if z_val:
self.Z = coordinates.Z
class... |
# Non-unicode strings are assumed to be CP437. We have an indexed table to
# convert CP437 to unicode (index range 0-255 => unicode char) and a dict to
# convert Unicode to CP437 (unicode char => CP437 char). These are used by the
# fsuCP437_to_Unicode and fsUnicode_to_CP437 functions respectively.
asUnicodeCharMapCP43... |
# Insertion sort
def insertion_sort(A: list):
for i in range(1, len(A)):
j = i
while j > 0 and A[j - 1] > A[j]:
A[j], A[j - 1] = A[j - 1], A[j]
j -= 1
# Complexity:
# worst-case: Θ(n^2)
# best-case: Θ(n)
# average-case: Θ(n^2)
# in-place: yes
|
monthConversions = {
"Jan": "January",
"Feb": "Februry",
"Mar": "March",
"Apr": "April",
"May": "May",
"Jun": "June",
"Jul": "July",
"Aug": "August",
"Sep": "September",
"Oct": "October",
"Nov": "November",
"Dec": "December",
}
print(monthConversions["Oct"])
print(monthC... |
a=[2,6,7,5,11,15]
n=len(a)
print("old array=",a)
for i in range(n-1):
if a[i]<=a[i+1]:
continue
t=a[i+1]
j=i+1
while j>=1 and a[j-1]>t:
a[j]=a[j-1]
j=j-1
a[j]=t
print("Sorted Array=",a) |
# -*- coding: utf-8 -*-
#
# This file is part of Invenio.
# Copyright (C) 2015-2018 CERN.
#
# Invenio is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.
"""Default configuration values for Celery integration.
For further Celery configura... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.