content stringlengths 7 1.05M |
|---|
'''3-4. Guest List: If you could invite anyone, living or deceased, to dinner, who
would you invite? Make a list that includes at least three people you’d like to
invite to dinner. Then use your list to print a message to each person, inviting
them to dinner.'''
guests = ['Angelina Jolie', 'Jennifer Aniston', 'Adam Sa... |
#
# PySNMP MIB module HP-ICF-LINKTEST (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HP-ICF-LINKTEST
# Produced by pysmi-0.3.4 at Wed May 1 13:34:33 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27... |
"""Configs for VisDA17 experiments."""
def get_weighting_config_class_pareto(alpha, reverse, seed):
return {
'name': 'class_pareto',
'kwargs': {
'alpha': alpha,
'reverse': reverse,
'seed': seed
},
}
def get_dataset_config_visda17_pareto_target_imba... |
"""
This file contains the implementation of a mixin that contains a
method that solves the collision between a rectangular shape with
the ball.
Collision solve algorithm taken from:
https://github.com/noooway/love2d_arkanoid_tutorial/wiki/Resolving-Collisions
Author: Alejandro Mujica
Date: 15/07/2020
"""
class Bal... |
for x in range(16):
with open(f'..\\data\\cpu\\functions\\opcode_switch\\opcode_7xxx\\opcode_7xxx_{x}.mcfunction', 'w') as f:
f.write(f'scoreboard players operation Global V{hex(x)[2:].upper()} += Global PC_nibble_4\n')
f.write(f'execute if score Global V{hex(x)[2:].upper()} matches 256.. run scoreb... |
class MoveGenerator:
"""
state=(BK,WK,WR)--> state=((x,y),(x,y,R),(x,y,K)) check for K and R for whose values most likely order you get is bk,w
where wk , wr and bk are positions for the pieces
"""
def __init__(self,state):
self.state=state #represennts initial state of the game p.s s... |
travel_route = input().split('||')
amount_of_fuel = int(input())
amount_of_ammunition = int(input())
travelled_distance = 0
for x in travel_route:
current_command = x.split(' ')
command = current_command[0]
if command == 'Travel':
value = int(current_command[1])
if amount_of_fuel >= value:
... |
'''
Author : MiKueen
Level : Medium
Problem Statement : Subarray Sum Equals K
Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k.
Example 1:
Input:nums = [1,1,1], k = 2
Output: 2
Constraints:
The length of the array is in range [1, 20,000].
T... |
class Node:
@property
def label(self):
return self.__label
@property
def left_child(self):
return self.__left_child
@left_child.setter
def left_child(self, n):
self.__left_child = n
self.__left_child.parent = self
@property
def right_sibling(self):
... |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
function
'''
def area(width, height=10):
'''
area
'''
print('width=%s, height=%s' % (width, height))
return width*height
print(area(10, 20))
print(area(height=10, width=20))
print(area(10))
def sum(a, b, *c):
'''
sum
'''
d = a+b
... |
# DEFEAT
# https://www.codechef.com/UNCO2021/problems/DEFEAT
NMK = [int(i) for i in input().split()]
matrix = []
for column in range(NMK[1]):
matrix.append([0]* NMK[0])
enemyLoc = []
for enemy in range(NMK[2]):
enemyLoc.append([i for i in input().split()])
for enemy in range(NMK[2]):
for enemyRow in enemyLoc[en... |
class UvMap(object):
def __init__(self, coords=[], texture_file_name='', name=''):
self.coords = tuple(coords)
self.texture_file_name = texture_file_name
self.name = name
|
# Aula de estrutura de repetição com variavel de controle
for c in range(0, 6):
print('oi')
print('fim')
for a in range(0, 10, 2): # o primeiro argumento e o segundo é o range de contagem, o terceiro é o metodo da contagem
print(a)
print('fim')
# Outro exemplo
for a in range(10, 0, -1): # Com uma condição d... |
# Copyright (c) 2012 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.
{
'variables': {
'cc_source_files': [
'animation.cc',
'animation.h',
'animation_curve.cc',
'animation_curve.h',
'anim... |
class FileLock:
def __init__(self, filename):
self.filename = filename
with open(self.filename, 'w') as f:
f.write('done')
def lock(self):
with open(self.filename, 'w') as f:
f.write('working')
def unlock(self):
with open(self.filename, 'w') as f:
... |
# Approach 1
def reverseList(A, start, end):
while start < end:
A[start], A[end] = A[end], A[start]
start += 1
end -= 1
# reverseList([1, 2, 3, 4, 5, 6], 0, 5) = [6 5 4 3 2 1]
# Approach 2
def reverseList(A, start, end):
if start >= end:
return
A[start], A[end] = A[end],... |
# -*- coding: utf-8 -*-
"""
Created on Wed Jul 22 12:37:10 2020
@author: Arthur Donizeti Rodrigues Dias
"""
def arithmetic_arranger(problems, resultado = False):
lista =[]
listaNumero = []
listaOperador = []
listaSoma = []
listaFormatada = []
listaFormatada2 = []
listaForm... |
#!/usr/bin/python3
# --- 001 > U5W2P1_Task1_w1
def solution(s):
return int(s)
if __name__ == "__main__":
print('----------start------------')
s = "12"
print(solution( s ))
print('------------end------------') |
def sort(num) :
for i in range(len(num) - 1) :
for j in range(i, len(num)) :
if num[i] > num[j] :
temp = num[i]
num[i] = num[j]
num[j] = temp
num = [2, 6, 4, 8, 7]
sort(num)
print(num)
'''
Output :
[2, 4, 6, 7, 8]
''' |
#! /usr/bin/env python3
def f(x):
def g(y):
# NEED THIS
nonlocal x
x = x - y
return x
return g
g0 = f(100)
ans0 = g0(42)
print(ans0)
g1 = f(200)
ans1 = g1(42)
print(ans1)
|
"""
This file is part of pynadc
https://github.com/rmvanhees/pynadc
GOSAT-2 package
Copyright (c) 2019 SRON - Netherlands Institute for Space Research
All Rights Reserved
License: BSD-3-Clause
"""
__all__ = ['db']
|
# input
N = int(input())
S = []
for i in range(N):
S.append(input())
# process & output
length_T = 0
left = 0
right = N-1
while length_T < N:
if S[left] < S[right]:
print(S[left], end='')
left += 1
elif S[left] > S[right]:
print(S[right], end='')
right -= 1
else:
temp_l = left
temp_r = right
while ... |
template = """
{
"packagingVersion": "4.0",
"upgradesFrom": ["%%(upgrades-from)s"],
"downgradesTo": ["%%(downgrades-to)s"],
"minDcosReleaseVersion": "1.9",
"name": "%(package-name)s",
"version": "%%(package-version)s",
"maintainer": "%%(maintainer)s",
"description": "%(package-name)s on DC/OS",
"selec... |
spin = input()
electric_charge = input()
if spin == '1' and electric_charge == '0':
print('Photon Boson')
else:
if electric_charge == '-1/3':
print('Strange Quark')
elif electric_charge == '2/3':
print('Charm Quark')
elif electric_charge == '-1':
print('Electron Lepton')
els... |
#! /usr/bin/python
@onRun
def run(args):
print("run")
return {"msg":"fsd"}
@onPause
def pause(args):
print("pause")
@onStart
def start(args):
print("start")
@onFinish
def finish(args):
print("finish") |
"""
@file
@brief shortcuts to exams
"""
|
#encoding:utf-8
subreddit = 'tf2+tf2memes+tf2shitposterclub'
t_channel = '@r_TF2'
def send_post(submission, r2t):
return r2t.send_simple(submission)
|
def gcd(x, y):
if y == 0:
return x
else:
return gcd(y, x % y)
print(gcd(24, 32))
|
def remove_lead_and_trail_slash(val):
if val.startswith('/'):
val = val[1:]
if val.endswith('/'):
val = val[:-1]
return val
|
#!/usr/bin/python3
"""
Surprisingly there are only three numbers that can be written as the sum of fourth powers of their digits:
1634 = 1^4 + 6^4 + 3^4 + 4^4
8208 = 8^4 + 2^4 + 0^4 + 8^4
9474 = 9^4 + 4^4 + 7^4 + 4^4
As 1 = 1^4 is not a sum it is not included.
The sum of these numbers is 1634 + 8208... |
def countItems(a: list) -> int:
if len(a) == 0:
return 0
else:
return 1 + countItems(a[1:])
|
def factorial(n):
return 1 if n < 2 else n * factorial(n-1)
if __name__=='__main__':
for i in range(1, 26):
print('%s! = %s' % (i, factorial(i)))
"""
output:
1! = 1
2! = 2
3! = 6
4! = 24
5! = 120
6! = 720
7! = 5040
8! = 40320
9! = 362880
10! = 3628800
11! = 39916800
12! = 479001600
13! = 6227020800
1... |
'''
# > File Name : P1655.py
# > Author : Tony_Wong
# > Created Time : 2019/12/07 12:05:15
# > Algorithm : Stirling II
'''
S = [[0] * 110 for i in range(110)]
for i in range(1, 110):
S[i][i] = S[i][1] = 1
for j in range(2, i):
S[i][j] = S[i - 1][j - 1] + S[i - 1][j] ... |
target_steps = 10000
steps_done = 0
while True:
line = input()
if line == "Going home":
home_steps = int(input())
steps_done = steps_done + home_steps
if steps_done >= target_steps:
print("Goal reached! Good job!")
print(f"{steps_done - target_steps} steps over ... |
def axisAlignedBoundingBox(x, y):
minX = x[0]
maxX = x[0]
minY = y[0]
maxY = y[0]
for i in range(1, len(x)):
minX = min(x[i], minX)
maxX = max(x[i], maxX)
minY = min(y[i], minY)
maxY = max(y[i], maxY)
return (maxX - minX) * (maxY - minY) |
def metade(metade,mostrar=False):
metade/=2
if mostrar:
return moeda(metade)
else:
return metade
def dobro(dobrar,mostrar=False):
dobrar*=2
if metade:
return moeda(dobrar)
else:
dobrar
def aumentar(numero,acrescentar,mostrar=False):
numero=acrescentar/100*nume... |
# -*- coding: utf-8 -*-
class Event(object):
"""
Event的基类,提供所有后续子类的一个接口,在后续的交易系统中会触发进一步的事件
"""
pass
class MarketEvent(Event):
"""
市场数据更新,由DataHandler对象发出,被Strategy对象接收
"""
def __init__(self):
self.type = 'MARKET'
class OrderEvent(Event):
"""
委托单提交,... |
def integrate(a, b, f, N=2000):
dx = (b-a)/N
s=0.0
for i in range(N):
s += f(a+i*dx)
return s * dx
|
#!/usr/bin/env python3
#coding: utf-8
### 1st line allows to execute this script by typing only its name in terminal, with no need to precede it with the python command
### 2nd line declaring source code charset should be not necessary but for exemple pydoc request it
__doc__ = "INI File Reading and Writing."#inform... |
while True:
try:
code = input("Enter customer code: ")
if code == 'r' or code=='R' or code =='c' or code=='C' or code =='i' or code == 'I':
tcode = 'ok'
else:
break
iread = float(input("Enter init read: "))
fread = float(input('Enter final reading: '))... |
# -*- coding: utf-8 -*-
"""
Created on Sat Mar 2 22:38:14 2019
@author: Pooyan
"""
######################################
class ID:
def __init__(hh,name,age):
hh.name=name
hh.age=age
def callback(hh):
print("Name: "+hh.name +"Age: "+hh.age)
del hh.n... |
# Definition for a binary tree node
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
# TODO: Do with good solutions
class Solution:
def convertToDoubly(self, root):
head = TreeNode(0)
pre = [head]
def doublyUtil(root, pre)... |
def find_count(numbers, target, expression=''):
if not numbers:
print(expression)
if target == 0:
return 1
else:
return 0
result = 0
result += find_count(numbers[1:], target - numbers[0], expression + f'+{numbers[0]}')
result += find_count(numbers[1:], ta... |
class Comodo:
__largura: float
__profundidade: float
__altura: float
def __init__(self,largura,profundidade):
self.largura = largura ## apenas quem acessa estas propriedades são os setters e getters
self.profundidade = profundidade
self.__altura = 2.9
@property ## indica qu... |
#1 Interation through lists
L1 = [3,4,5]
L2 = [1,2,3]
L3 = []
for i in range(len(L1)):
L3.append(L1[i] + L2[i])
print(L3)
#2
L1 = [3,4,5]
L2 = [1,2,3]
L4 = list(zip(L1,L2)) #The zip fuction takes two or more sequences and it makes a list of tuples
print(L4)
#3
L1 = [3,4,5]
L2 = [1,2,3]
L3 = []
L4 = list(zip(L1... |
class TeamConfig:
def __init__(self,
n_agents=2,
initial_epsilon=1.0,
final_epsilon=0.1,
epsilon_decay=0.999,
replay_buffer_size=250000,
replay_start_size=200000,
batch_size=32,
tr... |
def solution(st: str, limit: int) -> str:
if len(st) <= limit:
return st
for i in range(len(st)):
return st[i:limit]+'...' |
def MergeSort(m):
"""
If the length is less than or equal to 1, just return
since we don't even need to run SelectionSort
"""
if len(m) <= 1:
return m
#Calculate the midpoint and cast to int so there is no decimal
middle = int(len(m) / 2)
#Init some empty arrays. ls/rs a... |
# zdebeer 2021-08-14
# Collection of cuntions that can be used in a template for assiting in transforming values to the required text.
def list_format(items, fmt):
"""format each item in a list"""
out = []
for i in items:
out.append(fmt.format(i))
return out
|
class DetectLangsRequest:
def __init__(self, text, multi, count):
self.text = text
self.multi = multi
self.count = count |
print('hi\nmy name is : abdullah')
print("in this code we will do ")
#if elif else
print("if elif else")
print("\n\n")
#________________________#
age = int(input("enter your age "))
print(age)
if (age > 30 and age<60) :
print("wow")
elif (age > 60 ):
print("old")
else :
print("almost") |
# Exercise 5
#
# We will define a new object, SoccerPlayer
# 1) Think about what data attributes define a soccer player in real life
# Examples include: name, age, position, goals scored
# Feel free to be creative!
# 2) Write the __init__ method for SoccerPlayer
# 3) Write the getters and setters fo... |
"""
Provide help messages for command line interface's batch commands.
"""
BATCH_IDENTIFIER_ARGUMENT_HELP_MESSAGE = 'Identifier to get a batch by.'
BATCH_STATUS_IDENTIFIER_ARGUMENT_HELP_MESSAGE = 'Identifier to get a batch status by.'
BATCHES_IDENTIFIERS_ARGUMENT_HELP_MESSAGE = 'Identifiers to get a list of batches by.... |
g = 9.81
l1 = 1
l2 = 1
m1 = 1
m2 = 1
|
"""
The Jumping Cloud challenge is about a girl, Emma, that has to jump
through the clouds to reach the end point. In order to arrive safe, she
has to avoid the thunder clouds.
The path is given as an array (c) containing binary integers.
0 means that a cloud is safe and 1 means it must be avoided.
The objective is t... |
rand_map = [47, 20, 77, 91, 7, 18, 55, 46, 17, 60, 27, 40, 85, 15, 11, 12, 92, 9, 76, 62, 16, 80, 44, 13, 10, 67, 86, 65, 89, 81, 68, 26, 6, 64, 54, 57, 25, 45, 1, 83, 38, 71, 36, 75, 33, 79, 29, 63, 50, 70, 90, 56, 51, 37, 61, 42, 39, 93, 66, 43, 0, 2, 53, 74, 5, 22, 69, 82, 3, 28, 30, 34, 23, 19, 31, 84, 24, 41, 59, ... |
course = "Python 101"
name = ("Carl Richard Matson")
print(course) # Python 101
print(name) |
"""
给出一个 32 位的有符号整数,你需要将这个整数中每位上的数字进行反转。
"""
def reverse_force(x):
if -10 < x < 10:
return x
str_x = str(x)
if str_x[0] != "-": # 增加负数判断
str_x = str_x[::-1]
x = int(str_x)
else:
str_x = str_x[:0:-1]
x = int(str_x)
x = -x
return x if -2147483648 <... |
my_name = '제드 쇼'
my_age = 35 # not a lie
my_height = 188 # cm
my_weight = 82 # kg
my_eyes = '파랑'
my_teeth = '하양'
my_hair = '갈색'
print(f"{my_name}에 대해 이야기해 보죠.")
print(f"키는 {my_height} 센티미터구요.")
print(f"몸무게는 {my_weight} 킬로그램이에요.")
print("사실 아주 많이 나가는 건 아니죠.")
print(f"눈은 {my_eyes}이고 머리는 {my_hair}이에요.")
print(f"이는 보통 {my... |
def label_modes(trip_list, silent=True):
"""Labels trip segments by likely mode of travel.
Labels are "chilling" if traveler is stationary, "walking" if slow,
"driving" if fast, and "bogus" if too fast to be real.
trip_list [list]: a list of dicts in JSON format.
silent [bool]: if True, does n... |
def binary(a, tv):
minimum = 0
maximum = len(a) - 1
while minimum < maximum:
guess = round((minimum + maximum)/2)
if a[guess] == tv:
return guess
elif a[guess] < tv:
minimum = guess + 1
else:
maximum = guess - 1
return -1
arr = []
in... |
#
# PySNMP MIB module MERU-CONFIG-ICR-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/MERU-CONFIG-ICR-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 20:01:04 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default... |
N = int(input())
_hour = str(N // 3600)
N = N % 3600
_min = str(N // 60)
_sec = str(N % 60)
print(_hour + ':', _min + ':', _sec, sep='')
|
__all__ = ['Subcommand']
# placeholder class for subcommand classes to derive from
class Subcommand(object):
pass
# placeholder class for internal subcommand classes
class InternalSubcommand(object):
pass
|
soma = 0
for c in range(0, 6):
num = int(input('Digite um numero: '))
if num % 2 == 0:
soma += num
print(f'A soma dos valores digitados é {soma}')
|
class DataStructureError(ValueError):
"""
Exception signalling that there is something wrong in the data saved to the database
- might be missing data, conflict with existing data, etc.
"""
class SourceFileMissingError(Exception):
"""
Used in re-importing code if is finds that the file to read... |
start = "./img/start.png"
start1 = "./img/start1.png"
finish = "./img/finish.png"
# 指挥分队按钮,点两次,第二次是确认
zhihuifendui = (352, 896)
# 稳扎稳打选项,点两次,第二次是确认
wenzhawenda = (1022, 892)
zhongzhuang = (806, 814)
linguang = (1587, 644)
gumi = (2130, 830)
juji = (1662, 822)
landu = (1538, 218)
shushi = (1234, 812)
yanrong = (948... |
# -*- coding: utf-8 -*-
class School(object):
"""Data class for schools."""
def __init__(
self,
code,
name,
city,
state,
from_m,
from_y,
to_m,
to_y,
grad_m,
grad_y,
):
"""Intitalization method."""
self... |
def Alchemy(C, N):
return 'N' if abs(C.count('A') - C.count('B')) > 1 else 'Y'
if __name__ == "__main__":
T = int(input())
for i in range(T):
N = int(input())
C = input()
print("Case #{}:".format(i+1), end=" ")
print(Alchemy(list(C), N))
# s = "ABBBBABAAABAABBBAABAAAAAABBB... |
'''
Lab2
'''
#3.1
my_name = 'Tom'
print(my_name.upper())
#3.2
my_id = 123
print(my_id)
#3.3
# 123=my_id
my_id=your_id=123
print(my_id)
print(your_id)
#3.4
my_id_str = '123'
print(my_id_str)
#3.5
#print(my_name+my_id)
#3.6
print(my_name+my_id_str)
#3.7
print(my_name*3)
#3.8
print('hello, world. This is my fi... |
syscalls = [
"fork",
"exit",
"wait",
"pipe",
"read",
"write",
"close",
"kill",
"exec",
"open",
"mknod",
"unlink",
"fstat",
"link",
"mkdir",
"chdir",
"dup",
"getpid",
"sbrk",
"sleep",
"uptime"
]
|
class UndirectedGraphNode:
def __init__(self, x):
self.label = x
self.neighbors = []
class TreeNode:
def __init__(self, val):
self.val = val
self.left, self.right = None, None
class Solution:
"""
@param root: binary tree
@return: N-ary tree
"""
def decode(... |
class TranslationException(Exception):
"""
Error raised when a translation file can't be found.
"""
pass
class MediaNotSetUp(Exception):
"""
Error raised when a media file can't be found or set up.
"""
pass
class DataRetrievingError(Exception):
"""
Error raised when some raw ... |
class Config():
# simulation
T = 2200
sim_t = 2000 + 1
current_time = 0
# Job
process_t_lower = 1
process_t_upper = 5
job_resource_lower = 5
job_resource_upper = 15
# Server
server_r = 40
server_count = 6
server_heat_constant = 200
server_pos_x = [0, 1, -2, -2,... |
# 24. 两两交换链表中的节点
#
# 20200721
# huao
# 指针指来指去而已
# Definition for singly-linked list.
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
def swapPairs(self, head: ListNode) -> ListNode:
if head == None or head.next == None:
return head
... |
"""A module defining custom exceptions for the package.
Each subpackage has a base exception class.
"""
class OdkFormError(Exception):
"""The base exception class for the odkform subpackage."""
class MismatchedGroupOrRepeatError(OdkFormError):
"""An exception for parsing group or repeats."""
class LabelN... |
class maze_control():
def __init__(self, map, solution):
self.solution = solution
self.dmap = []
for x in map:
temp = []
for y in x:
temp.append(y)
self.dmap.append(temp)
def get_car(self):
if self.solution[0] !=... |
def print_hello(name=''):
print('Hello,'+name)
name = 'Ann'
name2 = 'Bob'
print_hello(name2) |
if __name__ == '__main__':
input = open('input', 'r').readlines()
inverse = {
'(': ')',
'[': ']',
'{': '}',
'<': '>'
}
points = {
')': 1,
']': 2,
'}': 3,
'>': 4
}
score = lambda x: points[x[0]] if len(x) == 1 else 5*score(x[1:]) ... |
"""
Space : O(n)
Time : O(n)
"""
class Solution:
def isToeplitzMatrix(self, matrix: List[List[int]]) -> bool:
if len(matrix) == 0:
return True
if len(matrix[0]) == 0:
return True
ly = len(matrix)
lx = len(matrix[0])
for y in range(ly-1):
... |
class Queue:
def __init__(self):
self.items = []
def push(self, e):
self.items.append(e)
def pop(self):
head = self.items[0]
self.items = self.items[1:]
return head
q = Queue()
q.push(5) # [5]
q.push(7) # [5, 7]
q.push(11) # [5, 7, 11]
print(q.pop()) # ... |
"""
Generate test code tool
copyrigth https://github.com/shigeshige/py-ut-generator
定数一覧
"""
AST_EXPR = 'Expr'
AST_FUCNTION = 'FunctionDef'
AST_FOR = 'For'
AST_IF = 'If'
AST_IMPORT_FROM = 'ImportFrom'
AST_IMPORT = 'Import'
AST_MODULE = 'Module'
AST_RETURN = 'Return'
AST_CALL = 'Call'
AST_NAME = 'Name'
AST_ATTRIBUTE =... |
def check(attempt, context):
if attempt.answer == flags[attempt.participant.id % len(flags)]:
return Checked(True)
if attempt.answer in flags:
return CheckedPlagiarist(False, flags.index(attempt.answer))
return Checked(False)
flags = ['LKL{s0_uSB_PXwlrPxA}', 'LKL{s0_uSB_z7dg8Y9I}... |
# Settings example file
# Edit as needed and save to local_settings.py
HOST = "imap.gmail.com"
USERNAME = "you@gmail.com"
PASSWORD = "IMAPappPassWord"
SEARCH_EMAIL = "tom@myspace.com"
DOWNLOAD_FOLDER = "."
POLLING_INTERVAL = 10000
DATABASE="/home/user/myfinances.gnucash"
|
# Whether to run the call graph tracer with debugging enabled. Turning off
# `if DEBUG: LOGGER.debug()` code completely yielded massive performance improvements.
DEBUG = False
FAIL_ON_UNKNOWN_BYTECODE = False
|
# --------------
# Code starts here
class_1=['Geoffrey Hinton','Andrew Ng','Sebastian Raschka','Yoshua Bengio']
class_2=['Hilary Mason','Carla Gentry','Corinna Cortes']
new_class = class_1+class_2
print(new_class)
new_class.append("Peter Warden")
print(new_class)
new_class.remove("Carla Gentry")
print(new_class)
# Code... |
"""Melhore o DESAFIO 61, perguntando para o usuário se ele quer mostrar mais alguns termos.
O programa encerrará quando ele disser que quer mostrar 0 termos. """
print('-=-'*14)
print('-'*12, 'TERMOS DE UMA PA', '-'*12)
print('-=-'*14)
termo = int(input('Digite o termo: '))
razao = int(input('Digite a razão: '))
total... |
x = int(input())
if(x % 2 == 0 or x % 5 == 0):
print(x)
else:
print("Not a multiple of 2 or 5")
|
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Jun 25 06:28:00 2018
@author: tuheenahmmed
"""
def integerDivision(x, a):
"""
x: a non-negative integer argument
a: a positive integer argument
returns: integer, the integer division of x divided by a.
"""
while x >= a:
... |
age = int(input("How old are you? "))
# if age >= 16 and age <=65:
# if 16 <= age <=65:
if age in range(16, 66):
print("Have a good day at work")
else:
print("Enjoy your free time!")
print("-" * 80)
if age <16 or age > 65:
print("Enjoy your free time!")
else:
print("Have a good day at work!") |
class Solution:
def longestConsecutive(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
if len(nums) <= 1:
return len(nums)
nums.sort()
length = 0
curLen = 1
for i in range(1, len(nums)):
if nums[i] == nums[i-1]+1:... |
"""Jest helper tools."""
load("@npm//@bazel/typescript:index.bzl", "ts_project")
load("@npm//jest-cli:index.bzl", _jest_test = "jest_test")
def ts_jest_test(name, srcs, deps = [], **kwargs):
"""Run a Jest test suite for a TS project.
Args:
name: name of the resulting test rule
srcs: typescrip... |
class Solution:
def addBinary(self, a: str, b: str) -> str:
ai,bi,carry = len(a)-1,len(b)-1,0
res = ''
while ai >= 0 or bi >= 0 or carry:
av = int(a[ai]) if ai >= 0 else 0
bv = int(b[bi]) if bi >= 0 else 0
sum3 = av+bv+carry
res = str(sum3%2)+r... |
sprinklers = [[False for j in range(1000)] for i in range(1000)]
def checkAndSwap(x1, x2):
if (x1 > x2):
return (x2, x1)
else:
return (x1, x2)
with open("D:\\Work\\Repositories\\programmingContest\\contest1\\programmingContest1Input2.txt") as file:
for line in file:
lin... |
politician_mapping = {
"properties": {
"name": {"type": "text", "analyzer": "indexing_analyzer", "search_analyzer":"search_analyzer"},
"occupation": {"type": "text", "analyzer": "indexing_analyzer", "search_analyzer":"search_analyzer"},
"party": {"type": "text", "analyzer": "indexing_analyze... |
class Project:
def __init__(self, id, name, country, altitude, currency):
self.id = id
self.name = name
self.country = country
self.altitude = altitude
self.currency = currency
def __str__(self):
return "ID: {} \nName: {} \nCountry: {} \nAltitude: {} \nCurrency: ... |
#!/usr/bin/env python3
# Thinking process:
# This doesn't work
# We need 3 DP tables:
# TD: at day i, if we have a 1-day pass, the [min cost, days left]
# TW: at day i, if we have a 1-week pass, the [min cost, days left]
# TM: at day i, if we have a 1-month pass, the [min cost, days left]
# Recurrence relation
# TD[... |
class Matrix(object):
"""
The Matrix represents a matrix containing a list of rows.
:param matrix_string: The string representing the matrix.
:type matrix_string: str
:ivar rows: Contains the rows of the matrix
:vartype rows: list(list(int))
"""
def __init__(self, matrix_string):
... |
"""
[8/10/2014] Challenge #174 [Extra] Functional Thinking
https://www.reddit.com/r/dailyprogrammer/comments/2d52d8/8102014_challenge_174_extra_functional_thinking/
# *(Extra)*: Functional Thinking
I'm trying a new bonus challenge today with any theme I can think of, such as rewriting an existing solution using a
dif... |
def to_list(string):
list_str = []
for tok in string:
list_str.append(tok)
return list_str
def to_string(list):
string_list = ""
for item in list:
string_list += item
return string_list
def fst_op(program):
raw = ""
for item in program:
if item == "(":
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.