content stringlengths 7 1.05M |
|---|
print(round(1.23,1))
print(round(1.2345, 3))
# Negative numbers round the ones, tens, hundreds and so on..
print(round(123124123, -1))
print(round(54213, -2))
# Round is not neccessary for display reasons. use format instead
x = 1.8913479812313
print("value is {:0.3f}".format(x)) |
def get_emails():
while True:
email_info = input().split(' ')
if email_info[0] == 'Stop':
break
sender, receiver, content = email_info
email = Email(sender, receiver, content)
emails.append(email)
class Email:
def __init__(self, sender, receiver, content):... |
pattern_zero=[0.0, 0.017538265306, 0.03443877551, 0.035714285714, 0.050701530612, 0.05325255102, 0.066326530612, 0.070153061224, 0.071428571429, 0.08131377551, 0.086415816327, 0.088966836735, 0.095663265306, 0.102040816327, 0.105867346939, 0.107142857143, 0.109375, 0.117028061224, 0.122130102041, 0.122448979592, 0.1246... |
def main() -> None:
x0, y0, x1, y1 = map(int, input().split())
for dx in range(-2, 3):
for dy in range(-2, 3):
if abs(dx) + abs(dy) != 3:
continue
if abs(dx) == 0 or abs(dy) == 0:
continue
x = x0 + dx
y = y0 + dy
... |
# Copyright (c) 2010 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.
# This file was split off from ppapi.gyp to prevent PPAPI users from
# needing to DEPS in ~10K files due to mesa.
{
'includes': [
'../../../third... |
# 5658. Maximum Absolute Sum of Any Subarray
# Biweekly contest 45
class Solution:
def maxAbsoluteSum(self, nums: List[int]) -> int:
currentmax = globalmax = currentmin = nums[0]
for i in range(1, len(nums)):
x, y = nums[i] + currentmax, nums[i] + currentmin
currentmax = max... |
# Copyright 2021 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... |
# -*- coding: utf8 -*-
def get_zero_matrix(size):
# '''
# Input:
# - size : 정수형 값
# Output:
# - size * size 크기의 two dimensional list를 반환함
# - list내 모든 값은 다 0으로 입력되어 있음
# Examples:
# >>> import magic_square as ms
# >>> ms.get_zero_matrix(3)
# [[0, 0, 0], [0, 0, 0], [0, 0, 0... |
TEST_OCF_ACCOUNTS = (
'sanjay', # an old, sorried account with kerberos princ
'alec', # an old, sorried account with no kerberos princ
'guser', # an account specifically made for testing
'nonexist', # this account does not exist
)
TESTER_CALNET_UIDS = (
872544, # daradib
1034192, # ckueh... |
# -*- coding: utf-8 -*-
"""
awsecommerceservice
This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
"""
class Item13(object):
"""Implementation of the 'Item13' model.
TODO: type model description here.
Attributes:
asin (string): TODO: type description here.... |
class NotFoundError(Exception):
def __init__(self, url):
super().__init__(url)
self.type = "notfound"
class NoTitleError(Exception):
def __init__(self, url):
super().__init__(url)
self.type = "notitle"
class ErrorPageError(Exception):
def __init__(self, url):
supe... |
init_info = input().split(" ")
sapce_width = int(init_info[0])
space_length = int(init_info[1])
space_gun = int(init_info[2])
gun_x = []
gun_y = []
for each_input in range(space_gun):
init_gun = input().split()
gun_x.append(int(init_gun[0]))
gun_y.append(int(init_gun[1]))
new_width = sapce_width -... |
class DigitalTv:
def __init__(self,region):
self._region = region
def display(self,channel):
if self._region == '新潟':
if channel == 8:
print('NHK総合表示中...')
elif channel == 12:
print('NHK教育表示中...')
else:
... |
"""
File: anagram.py
Name: Howard
----------------------------------
This program recursively finds all the anagram(s)
for the word input by user and terminates when the
input string matches the EXIT constant defined
at line 19
If you correctly implement this program, you should see the
number of anagrams for each wor... |
# Create a calculator function
# The function should accept three parameters:
# first_number: a numeric value for the math operation
# second_number: a numeric value for the math operation
# operation: the word 'add' or 'subtract'
# the function should return the result of the two numbers added or subtracted
# based on... |
'''
We can pass multiple arguments to the .order_by() method to order by multiple columns. In fact, we can also sort in ascending or descending order for each individual column. Each column in the .order_by() method is fully sorted from left to right. This means that the first column is completely sorted, and then with... |
#!/usr/bin/env python3
####################################################################################
# #
# Program purpose: Finds the difference between the largest and the smallest #
# integer which a... |
#############################################################################
# _____ __________ ___ __ #
# / ___// ____/ __ \/ | / / #
# \__ \/ / / /_/ / /| | / / #
# ___... |
class AuthenticationError(Exception):
pass
class MarketClosedError(Exception):
pass
class MarketEmptyError(Exception):
pass
|
# coding=utf-8
# @Time : 2021/3/26 10:34
# @Auto : zzf-jeff
class GlobalSetting():
label_path = './coco.names'
model_path = './weights/yolov5x-simpler.engine'
# model_path = './weights/yolov5s.pt'
output_path = './output'
img_path = './test_imgs'
conf_thresh = 0.3
iou... |
def test_trading_fee(position):
entry_price = 100000000000000000000 # 100
current_price = 150000000000000000000 # 150
notional = 10000000000000000000 # 10
debt = 2000000000000000000 # 2
liquidated = False
trading_fee_rate = 750000000000000
oi = int((notional / entry_price) * 10000000000... |
# @author:leacoder
# @des: 递归 二叉树的前序遍历
class Solution:
def preorderTraversal(self, root: TreeNode) -> List[int]:
result = []
self.helper(root,result)
return result
def helper(self,root,result):
if not root:
return
result.append(root.val)
self.helper... |
"""
1. Two Sum
Easy
10315
337
Favorite
Share
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
Example:
Given nums = [2, 7, 11, 15], target = 9,
Bec... |
# 9th Solutions
#--------------------------
n = int(input())
d = {}
for i in range(n):
x = input().split()
d[x[0]] = x[1]
while True:
try:
name = input()
if name in d:
print(name, '=', d[name], sep='')
else:
print('Not found')
except:
break
|
def define_targets(rules):
rules.cc_test(
name = "test",
srcs = ["impl/CUDATest.cpp"],
deps = [
"@com_google_googletest//:gtest_main",
"//c10/cuda",
],
target_compatible_with = rules.requires_cuda_enabled(),
)
|
def vogal(c):
if c == 'a' or c == 'e' or c == 'i' or c == 'o' or c == 'u' or c == 'A' or c == 'E' or c == 'I' or c == 'O' or c == 'U':
return True
else:
return False |
# Copyright 2020 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, soft... |
# Copyright 2021 Variscite LTD
# SPDX-License-Identifier: BSD-3-Clause
__version__ = "1.0.0"
|
#!/usr/bin/env python
# Copyright (c) 2020 Intel Corporation
#
# This work is licensed under the terms of the MIT license.
# For a copy, see <https://opensource.org/licenses/MIT>.
"""
This module provides the base class for user-defined actor
controllers. All user-defined controls must be derived from
this class.
A ... |
# dfs
def walk_parents(vertex):
return sum(
(walk_parents(parent) for parent in vertex.parents),
[]
) + [vertex]
def walk_children(vertex):
return sum(
(walk_children(child) for child in vertex.children),
[]
) + [vertex]
|
"""
https://leetcode.com/problems/power-of-four/
Given an integer (signed 32 bits), write a function to check whether it is a power of 4.
Example 1:
Input: 16
Output: true
Example 2:
Input: 5
Output: false
Follow up: Could you solve it without loops/recursion?
"""
# Inspired by @h285zhao in the discussion panel. If... |
# list1 = [i for i in range(5, 16)]
# print(list1)
# list1 = [i for i in range(0, 11)]
# for i in range(11):
# if i > 0:
# print(list1[i-1] * list1[i])
# list1 = [i * j for i in range(1, 10) for j in range(1, 10)]
# print(list1)
str1 = str(input())
strArray = list(str1)
newList = []
for i in strArray:
... |
# Flask settings
DEBUG = False
# Flask-restplus settings
RESTPLUS_MASK_SWAGGER = False
SWAGGER_UI_DOC_EXPANSION = 'none'
# Application settings
# API metadata
API_TITLE = 'MAX Image Colorizer'
API_DESC = 'Adds color to black and white images.'
API_VERSION = '1.1.0'
ERR_MSG = 'Invalid file type/extension. Please pro... |
minx = 20
maxx = 30
miny = -10
maxy = -5
minx = 25
maxx = 67
miny = -260
maxy = -200
def simulate(vx, vy):
x = 0
y = 0
highest = 0
while y > miny:
x += vx
y += vy
if vx > 0:
vx -= 1
elif vx < 0:
vx += 1
vy -= 1
if vy == 0:
... |
def file_to_list(filename):
lines = []
fin = open(filename, "rt", encoding="utf-8")
lines = fin.readlines()
fin.close()
return lines
def print_table(lines):
template = {
"1": "+" + "-" * 11 + "+" + "-" * 11 + "+" + "-" * 8 + "+",
"2": "| {:<10.9}| {:<10.9}| {:<7.6}|",
}
... |
# -*- coding: utf-8 -*-
# Copyright 2021 Cohesity Inc.
class SiteIdentity(object):
"""Implementation of the 'SiteIdentity' model.
O365 Sharepoint online Site Identity. These may be obtained by Graph/REST
or PnP cmdlets. All fields are case insensitive.
Attributes:
id (string): Unique guid fo... |
a = int(input())
b = int(input())
c = int(input())
a_odd = a % 2
b_odd = b % 2
c_odd = c % 2
a_even = not (a % 2)
b_even = not (b % 2)
c_even = not (c % 2)
if (a_odd or b_odd or c_odd) and (a_even or b_even or c_even):
print("YES")
else:
print("NO")
|
# -*- coding: utf-8 -*-
"""
@file
@brief quelques fonctions à propos de la première séance
"""
def commentaire_accentues():
"""
L'aide de cette fonction contient assuréments des accents.
@FAQ(Python n'accepte pas les accents)
Le langage Python a été conçu en langage anglais. Dès qu'on on ajoute un ... |
# Copyright 2016 Google Inc.
#
# 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 writing,... |
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def closestValue(self, root: TreeNode, target: float) -> int:
if root == None:
return float('inf')
diff = target - root.val
if diff > 0:
... |
command = '/opt/django/smegurus-django/env/bin/gunicorn'
pythonpath = '/opt/django/smegurus-django/smegurus'
bind = '127.0.0.1:8001'
workers = 3
|
# -*- coding: utf-8 -*-
#
# Copyright (c) 2017 - 2019, doudoudzj
# All rights reserved.
#
# InPanel is distributed under the terms of the New BSD License.
# The full license can be found in 'LICENSE'.
"""Module for Lighttpd configuration management."""
def web_response(self):
action = self.get_argument('action',... |
language_compiler_param = \
{
"java": "-encoding UTF-8 -d -cp ."
}
|
aTuple = ("Orange", [10, 20, 30], (5, 15, 25))
print(aTuple[1][1])
|
__all__ = [
"sorter",
"ioputter",
"handler",
"timer",
"simple",
"process",
"HarnessChartProcessing",
"KomaxTaskProcessing",
"KomaxCore",
"HarnessProcessing"
] |
_base_ = "base.py"
fold = 1
percent = 1
data = dict(
samples_per_gpu=1,
workers_per_gpu=1,
train=dict(
ann_file="data/coco/annotations/semi_supervised/instances_train2017.${fold}@${percent}.json",
img_prefix="data/coco/train2017/",
),
)
work_dir = "work_dirs/${cfg_name}/${percent}/${fold... |
class GumballMonitor:
def __init__(self, machine):
self.machine = machine
def report(self):
try:
print(f'Gumball Machine: {self.machine.get_location()}')
print(f'Current inventory: {self.machine.get_count()} gumballs')
except Exception as e:
print(e)
|
class Opt():
def __init__(self):
# mode options
self.isDebug = False
self.decoder_mode = 0 # {0:'pointer-generator', 1:'only-generator', 2:'only-copy'}
# GPU
self.usegpu = True
self.gpuid = 1
# preprocess.py
self.seed = 3435
self.totalVocabS... |
# -*- coding:utf-8 -*-
# ---------------------------------------------
# @file DoubleLinkedList.py.py
# @description Double Linked List
# @author WcJun
# @date 2020/06/21
# ---------------------------------------------
# 节点
class Node(object):
def __init__(self, element):
self.element = element
s... |
################### Error URLs #####################
# For imageGen.py
not_enough_info = 'http://i.imgur.com/2BZk32a.jpg'
improperly_formatted_tag = 'http://i.imgur.com/HvFX82m.jpg'
# For memeAPI.py
meme_not_supported = 'http://i.imgur.com/6VoMZqm.jpg'
couldnt_create_meme = 'http://i.imgur.com/bkW1HEV.jpg'
too_many_li... |
#
# PySNMP MIB module CENTILLION-FILTERS-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CENTILLION-FILTERS-MIB
# Produced by pysmi-0.3.4 at Wed May 1 11:47:45 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (d... |
"""
Author:
Haris Hasic, PhD Student
Institution:
Ishida Laboratory, Department of Computer Science, School of Computing, Tokyo Institute of Technology
Updated on:
April, 2021
Description:
Currently, this folder does not contain any libraries which are taken from an outside source.
Disclaimer:
The... |
def ask_user_for_weeknum():
weeknum = 0
while weeknum not in range(1,23):
try:
weeknum = int(input('Please enter the number of the week that we\'re in:'))
if weeknum in range(1,23):
break
else:
print('You did not enter a valid week number')
#weeknum = int(input('... |
message = input()
new_message = ''
index = 0
current_text = ''
multiplier = ''
while index < len(message):
if message[index].isdigit():
multiplier += message[index]
if index+1 < len(message):
if message[index+1].isdigit():
multiplier += message[index+1]
... |
load("//:import_external.bzl", import_external = "safe_wix_scala_maven_import_external")
def dependencies():
import_external(
name = "org_mongodb_mongodb_driver_reactivestreams",
artifact = "org.mongodb:mongodb-driver-reactivestreams:1.11.0",
jar_sha256 = "ae3d5eb3c51a0c286f43fe7ab0c52e3e0b385766f... |
space_agencies = {
"Australia": ['🇦🇺', 'ASA' , 'Australian Space Agency', 'https://en.wikipedia.org/wiki/Australian_Space_Agency', 2018, 'https://www.industry.gov.au/strategies-for-the-future/australian-space-agency'],
"Belarus": ['🇧🇾', 'BSA', 'Belarus Space Agency', 'https://en.wikipedia.org/wiki/Belarus_Space_Age... |
#Cengiz Ermis - 170401019
with open("veriler.txt", "r", encoding='utf-8') as file:
array = []
for i in file.read().split():
array.append(int(i))
uz = len(array)
yToplam = sum(array)
def xitoplam(uz):
xKareToplam = []
xKareToplam.append(uz)
for i in range(1,13):
va... |
#-*-coding:utf8;-*-
#qpy:console
print('\n')
print('-' * 5, 'AUMENTO NO SALÁRIO', '-' * 5)
print('\n')
s = float(input('Digite o seu salário: '))
if s > 1250:
sr = (s * 0.10) + s
print('\n')
print(' SALÁRIO: {:.2f} \n AUMENTO: {:.2f} \n SALÁRIO REAJUSTADO: {:.2f}'.format(s, (s * 0.10), sr))
elif s <= 1250:... |
"""
[2017-11-10] Challenge #339 [Hard] Severing the Power Grid
https://www.reddit.com/r/dailyprogrammer/comments/7c4bju/20171110_challenge_339_hard_severing_the_power/
# Description
In energy production, the power grid is a a large directed graph of energy consumers and producers. At times you need
to cut at certain ... |
def delete_date_symbols(date,dateFormat):
if(dateFormat == 'YYYY-MM-DD HH:MM:SS'):
year = date[0:4]
month = date[5:7]
day = date[8:10]
hours = date[11:13]
minutes = date[14:16]
seconds = date[17:19]
formattedDate=year+month+day+hours+minutes+seconds
re... |
#!/usr/bin/env python
"""
Copyright 2012 Wordnik, Inc.
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 applica... |
class SendCharacters:
"""
ユーザーがボタンを押下したときにイベントハンドラに引数として送信される文字列
"""
AC = "$"
DIVI = "/"
MULTI = "*"
PLUS = "+"
MINUS = "-"
ONE = "1"
TWO = "2"
THREE = "3"
FOUR = "4"
FIVE = "5"
SIX = "6"
SEVEN = "7"
EIGHT = "8"
NINE = "9"
ZERO = "0"
DECIMAL = ... |
class Solution:
def countAndSay(self, n: int) -> str:
if n == 1:
return "1"
prev = "1"
for i in range(1, n):
res = ""
val = prev[0]
count = 1
for i in range(1, len(prev)):
if prev[i] == val:
count... |
begin_unit
comment|'# Copyright 2014 OpenStack Foundation'
nl|'\n'
comment|'# All Rights Reserved.'
nl|'\n'
comment|'#'
nl|'\n'
comment|'# Licensed under the Apache License, Version 2.0 (the "License"); you may'
nl|'\n'
comment|'# not use this file except in compliance with the License. You may obtain'
nl|'\n'
co... |
#
# @lc app=leetcode id=771 lang=python3
#
# [771] Jewels and Stones
#
# @lc code=start
class Solution:
def numJewelsInStones(self, J: str, S: str) -> int:
jewels = set(J)
number_jewels = 0
for char in S:
if char in jewels:
number_jewels += 1
return num... |
#Odd numbers
for number in range(1,21,2):
print(number)
|
imie = str(input('podaj imie palo:'))
nazwisko = str(input('nazwisko:'))
telefon = int(input('numer 😏:'))
with open('wizytowka.txt', 'w') as f:
f.write(f'imie: {imie}\n')
f.write(f'nazwisko: {nazwisko}\n')
f.write(f'nr. telefonu: {telefon}\n') |
# Copyright (C) 2019 The Android Open Source Project
#
# 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 ... |
#! /usr/bin/env python
# -*- python -*-
# -*- coding: utf-8 -*-
lang = {
"lang": "estonian", # should be in english
"flPoint_comma": True, # floating point symbol is `,` instead `.`
"translator": "Jüri Kormik"
}
messages = {
"program.ext": [".json", ".pickle"],
"program.title": "Liht... |
load("@npm//@bazel/typescript:index.bzl", "ts_library")
def ng_ts_library(**kwargs):
ts_library(
compiler = "//libraries/angular-tools:tsc_wrapped_with_angular",
supports_workers = True,
use_angular_plugin = True,
**kwargs
)
|
# Copyright (C) 2013 - 2016 - Oscar Campos <oscar.campos@member.fsf.org>
# This program is Free Software see LICENSE file for details
class StubProcess(object):
"""Self descriptive class name, right?
"""
def __init__(self, interpreter):
self._process = None
self._interpreter = None
... |
#!/usr/bin/env python3
#
# author : Michael Brockus.
# contact: <mailto:michaelbrockus@gmail.com>
# license: Apache 2.0 :http://www.apache.org/licenses/LICENSE-2.0
#
# copyright 2020 The Meson-UI development team
#
class OutputConsole:
def __init__(self, context=None):
self._context = context
def a... |
def comb(n, k):
if n - k < k:
k = n - k
if k == 0:
return 1
a = 1
b = 1
for i in range(k):
a *= n - i
b *= i + 1
return a // b
N, P = map(int, input().split())
A = list(map(int, input().split()))
odds = sum(a % 2 for a in A)
evens = len(A) - odds
print(sum(com... |
class Solution:
def medianSlidingWindow(self, nums: List[int], k: int) -> List[float]:
if k == 0: return []
win = sorted(nums[:k])
ans = []
for i in range(k, len(nums) + 1):
median = (win[k // 2] + win[(k - 1) // 2]) / 2.0
ans.append(median)
if i =... |
# https://codeforces.com/problemset/problem/230/A
s, n = [int(x) for x in input().split()]
dragons = []
new_dragons = []
for _ in range(n):
x, y = [int(x) for x in input().split()]
dragons.append([x, y])
dragons.sort()
for row in range(n - 1):
current_row = dragons[row]
next_row = dragons[row + 1]
... |
#
# PySNMP MIB module NMS-EPON-ONU-RESET (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/NMS-EPON-ONU-RESET
# Produced by pysmi-0.3.4 at Mon Apr 29 20:12:13 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, ... |
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you m... |
# -*- coding: utf-8 -*-
'''
File name: code\sums_of_power_sums\sol_487.py
Author: Vaidic Joshi
Date created: Oct 20, 2018
Python Version: 3.x
'''
# Solution to Project Euler Problem #487 :: Sums of power sums
#
# For more information see:
# https://projecteuler.net/problem=487
# Problem Statement
'... |
def centuryFromYear(year):
remainer = year % 100
if remainer == 0:
return year/100
else:
return int(year/100)+1
|
"""
Crie um programa que leia dois valores e mostre um menu como o abaixo na tela:
[ 1 ] Somar
[ 2 ] Multiplicar
[ 3 ] Maior
[ 4 ] Novos Números
[ 5 ] Sair do Programa
Seu programa deverá realizar a operação solicitada em cada caso.
"""
num1 = int(input('Digite um valor: '))
num2 = int(input('Digite outro valor: '))
... |
#Christine Logan
#9/10/2017
#CS 3240
#Lab 3: Pre-lab
#hello.py
def greeting(msg):
print(msg)
def salutation(msg):
print(msg)
if __name__ == "__main__":
greeting("hello")
salutation("goodbye")
|
# TODO: to be deleted
class FieldMock:
def __init__(self):
self.find = lambda _: FieldMock()
self.skip = lambda _: FieldMock()
self.limit = lambda _: FieldMock()
class BeaconMock:
def __init__(self):
self.datasets = FieldMock()
class DBMock:
def __init__(self):
self... |
class SecurityKeyError(Exception):
def __init__(self, message):
super().__init__(message)
class ListenError(Exception):
def __init__(self, message):
super().__init__(message)
class ChildError(Exception):
def __init__(self, message):
super().__init__(message)
|
def main():
single_digit = 36
teens = 70
second_digit = 46
hundred = 7
nd = 3
thousand = 11
a = single_digit * (10 * 19)
a += second_digit * 10 * 10
a += teens * 10
a += hundred * 900
a += nd * 891
a += thousand
print(a)
main()
|
class CreditCard:
def __init__(self, cc_number, expiration, security_code):
self.cc_number = cc_number
self.expiration = expiration
self.security_code = security_code
class Charge:
def __init__(self, success, error=''):
self.success = success
self.error = error
|
{
'targets': [
{
'target_name': 'xxhash',
'cflags!': [ '-fno-exceptions' ],
'cflags_cc!': [ '-fno-exceptions' ],
'xcode_settings': { 'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
'CLANG_CXX_LIBRARY': 'libc++',
'MACOSX_DEPLOYMENT_TARGET': '10.7',
},
'msvs_settings': {
... |
class Solution:
def canCross(self, stones):
memo, stones, target = {}, set(stones), stones[-1]
def dfs(unit, last):
if unit == target: return True
if (unit, last) not in memo:
memo[(unit, last)] = any(dfs(unit + move, move) for move in (last - 1, last, last +... |
# Print recebe Strings como argumentos ou coisas que podem ser convertidas em strings
umFloat = 3.14
print("Numero convertido para string", umFloat)
print("Hello World")
print()
# São aceitos varias strings ou uma conjunta
print("Hello", "World")
print("Hello" + "World")
print("Podemos notar que a diferença entre uma g... |
path2file = sys.argv[1]
file = open(path2file, 'r')
while True:
line = file.readline()
if not line:
break
stroka = unicode(line, 'utf-8')
type('f', KeyModifier.CTRL)
sleep(1)
paste(stroka)
sleep(1)
type(Key.ENTER)
sleep(1)
break
exit(0)
|
class Solution:
def lengthOfLongestSubstring(self, s: str) -> int:
longestSubstring = 0
start = -1
end = 0
characterSet = set()
stringLength = len(s)
while start < stringLength and end < stringLength:
currentChar = s[end]
if currentChar in char... |
def Swap(a,b):
temp = a
a=b
b=temp
lst = [a,b]
return lst |
class Solution(object):
def removeDuplicates(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
ind = 0
pos = 0
while ind < len(nums):
if ind > 0 and ind < len(nums) and nums[ind] == nums[ind - 1]:
ind += 1
continue
nums[pos] = nums[ind]
pos += 1
... |
class Solution(object):
def kthSmallest(self, root, k):
"""
:type root: TreeNode
:type k: int
:rtype: int
"""
if not root:
return 0
stack = [root]
count, curr = 0, root
while stack:
if curr.left:
stack.ap... |
"""
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 writing, software
distributed under the Li... |
# 5
# 5 3
# 1 5 2 6 1
# 1 6
# 6
# 3 2
# 1 2 3
# 4 3
# 3 1 2 3
# 10 3
# 1 2 3 4 5 6 7 8 9 10
i = int(input())
l = []
for j in range(i):
k = list(map(int,(input().split(' '))))
il = list(map(int,input().split(' ')))
if k[1] in il and len(il)==1:
l.append('yes')
elif k[1] in il[1:] and len(il) %... |
class Solution:
def minTimeToVisitAllPoints(self, points: List[List[int]]) -> int:
now = points[0]
ans = 0
for point in points[1:]:
ans += max(abs(now[0] - point[0]), abs(now[1] - point[1]))
now = point
return ans
|
# Runtime: 176 ms, faster than 97.52% of Python3 online submissions for Set Mismatch.
# Memory Usage: 15.9 MB, less than 42.22% of Python3 online submissions for Set Mismatch.
def find_error_nums(nums: [int]) -> [int]:
"""You have a set of integers s, which originally contains all the numbers from 1 to n. Unfortuna... |
# Write a Python class which has two methods get_String and print_String....
# get_String accept a string from the user and print_String print the string in upper case.
class IOString():
def __init__(self):
self.str1 = ""
def get_String(self):
self.str1 = input()
def print_String(self):
... |
#####################
### Base classes. ###
#####################
class room:
repr = "room"
m_description = "You are in a simple room."
def __init__(self, contents=[]):
self.contents = contents
def __str__(self):
s = ""
for object in self.contents:
... |
# Source
# ======
# https://www.hackerrank.com/contests/projecteuler/challenges/euler008
#
# Problem
# =======
# Find the greatest product of K consecutive digits in the N digit number.
#
# Input Format
# ============
# First line contains T that denotes the number of test cases.
# First line of each test case will co... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.