content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
num1 = 1.5
num2 = 6.3
sum = num1 + num2
print('The sum of {0} and {1} is {2}'.format(num1, num2, sum))
| num1 = 1.5
num2 = 6.3
sum = num1 + num2
print('The sum of {0} and {1} is {2}'.format(num1, num2, sum)) |
a = []
while True:
k = 0
resposta = str(input('digite uma expressao qualquer:')).strip()
for itens in resposta:
if itens == '(':
a.append(resposta)
elif itens == ')':
if len(a) == 0:
print('expressao invalida')
k = 1
... | a = []
while True:
k = 0
resposta = str(input('digite uma expressao qualquer:')).strip()
for itens in resposta:
if itens == '(':
a.append(resposta)
elif itens == ')':
if len(a) == 0:
print('expressao invalida')
k = 1
bre... |
# Copyright (c) 2019 Damian Grzywna
# Licensed under the zlib/libpng License
# http://opensource.org/licenses/zlib/
__all__ = ('__title__', '__summary__', '__uri__', '__version_info__',
'__version__', '__author__', '__maintainer__', '__email__',
'__copyright__', '__license__')
__title__ =... | __all__ = ('__title__', '__summary__', '__uri__', '__version_info__', '__version__', '__author__', '__maintainer__', '__email__', '__copyright__', '__license__')
__title__ = 'aptiv.digitRecognizer'
__summary__ = 'Small application to recognize handwritten digits on the image using machine learning algorithm.'
__uri__ =... |
class Array:
n = 0
arr = []
def print_array(self):
print(self.arr)
def get_user_input(self):
self.n = int(input('Enter the size of array: '))
print('Enter the elements of array in next line (space separated)')
self.arr = list(map(int, input().split()))
| class Array:
n = 0
arr = []
def print_array(self):
print(self.arr)
def get_user_input(self):
self.n = int(input('Enter the size of array: '))
print('Enter the elements of array in next line (space separated)')
self.arr = list(map(int, input().split())) |
def hello(name):
print("hello", name, "!")
hello("xxcfun") | def hello(name):
print('hello', name, '!')
hello('xxcfun') |
# def fun(num):
# if num>5:
# return True
# else:
# return False
fun=lambda x: x>5
l=[1,2,3,4,45,35,43,523]
print(list(filter(fun,l))) | fun = lambda x: x > 5
l = [1, 2, 3, 4, 45, 35, 43, 523]
print(list(filter(fun, l))) |
class Node:
def __init__(self, value):
self.value = value
self.next = None
self.previous = None
def remove_node(self):
if self.next:
self.next.previous = self.previous
if self.previous:
self.previous.next = self.next
self.next = None
... | class Node:
def __init__(self, value):
self.value = value
self.next = None
self.previous = None
def remove_node(self):
if self.next:
self.next.previous = self.previous
if self.previous:
self.previous.next = self.next
self.next = None
... |
path = "./Inputs/day5.txt"
# path = "./Inputs/day5Test.txt"
def part1():
seats = getSeats()
highestSeat = max(seats)
print("Part 1:")
print(highestSeat)
def part2():
seats = getSeats()
# get the missing seat
difference = sorted(set(range(seats[0], seats[-1] + 1)).diff... | path = './Inputs/day5.txt'
def part1():
seats = get_seats()
highest_seat = max(seats)
print('Part 1:')
print(highestSeat)
def part2():
seats = get_seats()
difference = sorted(set(range(seats[0], seats[-1] + 1)).difference(seats))
print('Part 2:')
print(difference[0])
def get_seats():
... |
def max(*args):
if len(args) == 0:
return 'no numbers given'
m = args[0]
for arg in args:
if arg > m:
m = arg
return m
print(max())
print(max(5, 12, 3, 6, 7, 10, 9))
| def max(*args):
if len(args) == 0:
return 'no numbers given'
m = args[0]
for arg in args:
if arg > m:
m = arg
return m
print(max())
print(max(5, 12, 3, 6, 7, 10, 9)) |
def solution(N):
n = 0; current = 1; nex = 1
while n <N-1:
current, nex = nex, current+nex
n +=1
return 2*(current+nex)
| def solution(N):
n = 0
current = 1
nex = 1
while n < N - 1:
(current, nex) = (nex, current + nex)
n += 1
return 2 * (current + nex) |
a = [2012, 2013, 2014]
print (a)
print (a[0])
print (a[1])
print (a[2])
b = 2012
c = [b, 2015, 20.1, "Hello", "Hi"]
print (c[1:4])
| a = [2012, 2013, 2014]
print(a)
print(a[0])
print(a[1])
print(a[2])
b = 2012
c = [b, 2015, 20.1, 'Hello', 'Hi']
print(c[1:4]) |
class Solution:
def _breakIntoLines(self, words: List[str], maxWidth: int) -> List[List[str]]:
allLines = []
charCount = 0
# list of strings for easy append
currLine = []
for word in words:
wordLen = len(word)
if wordLen + charCount > maxWidth:
... | class Solution:
def _break_into_lines(self, words: List[str], maxWidth: int) -> List[List[str]]:
all_lines = []
char_count = 0
curr_line = []
for word in words:
word_len = len(word)
if wordLen + charCount > maxWidth:
allLines.append(currLine)
... |
# parsetab.py
# This file is automatically generated. Do not edit.
_tabversion = '3.2'
_lr_method = 'LALR'
_lr_signature = '\xc2\xce\xc6\x9e\xff\xa7\x1b:\xc7O\x919\xdf=}d'
_lr_action_items = {'TAG':([20,25,32,44,45,],[-21,-19,39,-22,-20,]),'LBRACE':([10,13,15,24,],[-9,17,20,-10,]),'RPAREN':([14,18,19,26,31,],[-... | _tabversion = '3.2'
_lr_method = 'LALR'
_lr_signature = 'ÂÎÆ\x9eÿ§\x1b:ÇO\x919ß=}d'
_lr_action_items = {'TAG': ([20, 25, 32, 44, 45], [-21, -19, 39, -22, -20]), 'LBRACE': ([10, 13, 15, 24], [-9, 17, 20, -10]), 'RPAREN': ([14, 18, 19, 26, 31], [-11, -12, 24, 34, -13]), 'RBRACE': ([17, 20, 22, 25, 32, 35, 41, 42, 44, 45]... |
class Solution:
def romanToInt(self, s: str) -> int:
symbol_map = {
"I": (0, 1),
"V": (1, 5),
"X": (2, 10),
"L": (3, 50),
"C": (4, 100),
"D": (5, 500),
"M": (6, 1000)
}
position = 0
value = 0
... | class Solution:
def roman_to_int(self, s: str) -> int:
symbol_map = {'I': (0, 1), 'V': (1, 5), 'X': (2, 10), 'L': (3, 50), 'C': (4, 100), 'D': (5, 500), 'M': (6, 1000)}
position = 0
value = 0
for symbol in reversed(s):
if symbol_map[symbol][0] < position:
... |
#!/bin/python
#This script is made to remove ID's from a file that contains every ID of every contig.
def file_opener(of_file):
with open(of_file, 'r') as f:
return f.readlines()
def filter(all, matched):
filterd = []
for a in matched:
if a not in matched:
filterd.append(a... | def file_opener(of_file):
with open(of_file, 'r') as f:
return f.readlines()
def filter(all, matched):
filterd = []
for a in matched:
if a not in matched:
filterd.append(a)
return filterd
def file_writer(data, of_file):
content = ''
for line in data:
content... |
# This is to write an escape function to escape text at the MarkdownV2 style.
#
# **NOTE**
# The [1]'s content provides some notes on how strings should be escaped,
# but let the user deal with it himself; there are such things as "the string
# ___italic underline___ should be changed to ___italic underline_\r__,
# wh... | _special_symbols = {'_', '*', '[', ']', '(', ')', '~', '`', '>', '#', '+', '-', '=', '|', '{', '}', '.', '!'}
def escape(string: str) -> str:
for symbol in _special_symbols:
string = string.replace(symbol, '\\' + symbol)
return string |
# Definition for singly-linked list.
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode:
def node2num(node):
val = 0
while node:
val = val * 10 + no... | class Listnode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
def add_two_numbers(self, l1: ListNode, l2: ListNode) -> ListNode:
def node2num(node):
val = 0
while node:
val = val * 10 + node.val
node = nod... |
#generator2.py
class Week:
def __init__(self):
self.days = {1:'Monday', 2: "Tuesday",
3:"Wednesday", 4: "Thursday",
5:"Friday", 6:"Saturday", 7:"Sunday"}
def week_gen(self):
for x in self.days:
yield self.days[x]
if(__name__ == "__main__"):... | class Week:
def __init__(self):
self.days = {1: 'Monday', 2: 'Tuesday', 3: 'Wednesday', 4: 'Thursday', 5: 'Friday', 6: 'Saturday', 7: 'Sunday'}
def week_gen(self):
for x in self.days:
yield self.days[x]
if __name__ == '__main__':
wk = week()
iter1 = wk.week_gen()
iter2 ... |
s1 = '854'
print(s1.isnumeric()) # -- ISN1
s2 = '\u00B2368'
print(s2.isnumeric()) # -- ISN2
s3 = '\u00BC'
print(s3.isnumeric()) # -- ISN3
s4='python895'
print(s4.isnumeric()) # -- ISN4
s5='100m2'
print(s5.isnumeric()) # -- ISN5
| s1 = '854'
print(s1.isnumeric())
s2 = '²368'
print(s2.isnumeric())
s3 = '¼'
print(s3.isnumeric())
s4 = 'python895'
print(s4.isnumeric())
s5 = '100m2'
print(s5.isnumeric()) |
# class LLNode:
# def __init__(self, val, next=None):
# self.val = val
# self.next = next
class Solution:
def solve(self, node, k):
# Write your code here
n = 0
curr = node
while curr:
curr = curr.next
n += 1
if k%n==0:
... | class Solution:
def solve(self, node, k):
n = 0
curr = node
while curr:
curr = curr.next
n += 1
if k % n == 0:
return node
if k > n:
k = k % n
curr = node
k1 = n - k - 1
while k1 != 0:
curr =... |
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution:
def nextLargerNodes(self, head: ListNode) -> List[int]:
if not head:
return [0]
node = head
... | class Solution:
def next_larger_nodes(self, head: ListNode) -> List[int]:
if not head:
return [0]
node = head
stack = [(0, node.val)]
node = node.next
result = [0]
i = 1
while node:
while stack and node.val > stack[-1][-1]:
... |
class Config():
API_KEY = '9b680a8b-22d4-4069-b0e6-f6cc97cd9d71'
API_URL = 'https://api.demo.11b.io'
API_ACCOUNT = 'A00-000-030'
config = Config() | class Config:
api_key = '9b680a8b-22d4-4069-b0e6-f6cc97cd9d71'
api_url = 'https://api.demo.11b.io'
api_account = 'A00-000-030'
config = config() |
'''
One cool aspect of using an outer join is that, because it returns all rows from both merged tables and null where they do not match, you can use it to find rows that do not have a match in the other table. To try for yourself, you have been given two tables with a list of actors from two popular movies: Iron Man 1... | """
One cool aspect of using an outer join is that, because it returns all rows from both merged tables and null where they do not match, you can use it to find rows that do not have a match in the other table. To try for yourself, you have been given two tables with a list of actors from two popular movies: Iron Man 1... |
#
# PySNMP MIB module CISCO-ANNOUNCEMENT-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-ANNOUNCEMENT-MIB
# Produced by pysmi-0.3.4 at Wed May 1 11:50:09 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (d... | (object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_intersection, value_size_constraint, value_range_constraint, single_value_constraint, constraints_union) ... |
# Will you make it?
def zero_fuel(distance_to_pump, mpg, fuel_left):
if ( distance_to_pump - mpg*fuel_left )>0:
result = False
else:
result = True
return result
| def zero_fuel(distance_to_pump, mpg, fuel_left):
if distance_to_pump - mpg * fuel_left > 0:
result = False
else:
result = True
return result |
def fib(n, calc):
if n == 0 or n == 1:
if len(calc) < 2:
calc.append(n)
return calc[n], calc
elif len(calc)-1 >= n:
return calc[n], calc
elif n >= 2:
res1, c = fib(n-1, calc)
res2, c = fib(n-2, calc)
res = res1 + res2
calc.append(res)
... | def fib(n, calc):
if n == 0 or n == 1:
if len(calc) < 2:
calc.append(n)
return (calc[n], calc)
elif len(calc) - 1 >= n:
return (calc[n], calc)
elif n >= 2:
(res1, c) = fib(n - 1, calc)
(res2, c) = fib(n - 2, calc)
res = res1 + res2
calc.app... |
def Tproduct(arg0, *args):
p = arg0
for arg in args:
p *= arg
return p
| def tproduct(arg0, *args):
p = arg0
for arg in args:
p *= arg
return p |
mylist = input('Enter your list: ')
mylist = [int(x) for x in mylist.split(' ')]
points = [0,15,10,10,25,15,15,20,10,25,20,25,25,5,20,30,20,15,10,5,5,15,20,20,20,20,15,15,20,25,15,20,20,20,15,40,15,30,35,20,25,15,20,15,25,20,25,20,25,20,10]
total = 0
for index in mylist:
total += points[index]
print (total) | mylist = input('Enter your list: ')
mylist = [int(x) for x in mylist.split(' ')]
points = [0, 15, 10, 10, 25, 15, 15, 20, 10, 25, 20, 25, 25, 5, 20, 30, 20, 15, 10, 5, 5, 15, 20, 20, 20, 20, 15, 15, 20, 25, 15, 20, 20, 20, 15, 40, 15, 30, 35, 20, 25, 15, 20, 15, 25, 20, 25, 20, 25, 20, 10]
total = 0
for index in mylist... |
URLS = 'app.urls'
POSTGRESQL_DATABASE_URI = ""
DEBUG = True
BASE_HOSTNAME = 'http://192.168.30.101:8080'
HOST = '0.0.0.0'
USERNAME = 'user'
PASSWORD = 'pass'
| urls = 'app.urls'
postgresql_database_uri = ''
debug = True
base_hostname = 'http://192.168.30.101:8080'
host = '0.0.0.0'
username = 'user'
password = 'pass' |
class ModelMetrics:
def __init__(self, model_name, model_version, metric_by_feature):
self.model_name = model_name
self.model_version = model_version
self.metrics_by_feature = metric_by_feature
| class Modelmetrics:
def __init__(self, model_name, model_version, metric_by_feature):
self.model_name = model_name
self.model_version = model_version
self.metrics_by_feature = metric_by_feature |
def constraint_in_set(_set = range(0,128)):
def f(context):
note, seq, tick = context
if seq.to_pitch_set() == {}:
return False
return seq.to_pitch_set().issubset(_set)
return f
def constraint_no_repeated_adjacent_notes():
def f(context):
note, seq, tick = co... | def constraint_in_set(_set=range(0, 128)):
def f(context):
(note, seq, tick) = context
if seq.to_pitch_set() == {}:
return False
return seq.to_pitch_set().issubset(_set)
return f
def constraint_no_repeated_adjacent_notes():
def f(context):
(note, seq, tick) = c... |
load("@rules_scala_annex//rules:providers.bzl", "LabeledJars")
def labeled_jars_implementation(target, ctx):
if JavaInfo not in target:
return []
deps_labeled_jars = [dep[LabeledJars] for dep in getattr(ctx.rule.attr, "deps", []) if LabeledJars in dep]
java_info = target[JavaInfo]
return [
... | load('@rules_scala_annex//rules:providers.bzl', 'LabeledJars')
def labeled_jars_implementation(target, ctx):
if JavaInfo not in target:
return []
deps_labeled_jars = [dep[LabeledJars] for dep in getattr(ctx.rule.attr, 'deps', []) if LabeledJars in dep]
java_info = target[JavaInfo]
return [label... |
# 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 may... | class Tablejoiner:
def __init__(self, hive_context, query):
self.query = query
self.hive_context = hive_context
def join_tables(self):
df = self.hive_context.sql(self.query)
return df |
#Escreva um programa que leia a velocidade de um carro.
velocidade = float(input('Velocidade: '))
# Se ele ultrapassar 80Km/h, mostre uma mensagem dizendo que ele foi multado
if velocidade > 80:
print(f'Passou a {velocidade} numa pista de 80 !!! \nVai pagar R${((velocidade-80)*30):.2f} de multa')
#A multa vai custa... | velocidade = float(input('Velocidade: '))
if velocidade > 80:
print(f'Passou a {velocidade} numa pista de 80 !!! \nVai pagar R${(velocidade - 80) * 30:.2f} de multa')
else:
print(f'{velocidade}Km. Voce estava dentro do limite de 80Km') |
# This is the version string assigned to the entire egg post
# setup.py install
__version__ = "0.0.9"
# Ownership and Copyright Information.
__author__ = "Colin Bell <colin.bell@uwaterloo.ca>"
__copyright__ = "Copyright 2011-2014, University of Waterloo"
__license__ = "BSD-new"
| __version__ = '0.0.9'
__author__ = 'Colin Bell <colin.bell@uwaterloo.ca>'
__copyright__ = 'Copyright 2011-2014, University of Waterloo'
__license__ = 'BSD-new' |
#This file was created by Diego Saldana
TITLE = " SUPREME JUMP "
TITLE2 = " GAME OVER FOO :( "
# screen dims
WIDTH = 480
HEIGHT = 600
# frames per second
FPS = 60
# player settings
PLAYER_ACC = 0.5
PLAYER_FRICTION = -0.12
PLAYER_GRAV = 0.8
PLAYER_JUMP = 100
FONT_NAME = 'arcade'
# platform settings
PLATFO... | title = ' SUPREME JUMP '
title2 = ' GAME OVER FOO :( '
width = 480
height = 600
fps = 60
player_acc = 0.5
player_friction = -0.12
player_grav = 0.8
player_jump = 100
font_name = 'arcade'
platform_list = [(0, HEIGHT - 40, WIDTH, 40), (65, HEIGHT - 300, WIDTH - 400, 40), (20, HEIGHT - 350, WIDTH - 300, 40), (200, HEIGHT ... |
#
# PySNMP MIB module XYLAN-HEALTH-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/XYLAN-HEALTH-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 21:38:37 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar ... | (octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_size_constraint, constraints_union, value_range_constraint, constraints_intersection, single_value_constraint) ... |
expected_output = {
'vll': {
'MY-UNTAGGED-VLL': {
'vcid': 3566,
'vll_index': 37,
'local': {
'type': 'untagged',
'interface': 'ethernet2/8',
'state': 'Up',
'mct_state': 'None',
'ifl_id': '--',
'vc_type': 'tag',
'mtu': 9190,
'cos': '-... | expected_output = {'vll': {'MY-UNTAGGED-VLL': {'vcid': 3566, 'vll_index': 37, 'local': {'type': 'untagged', 'interface': 'ethernet2/8', 'state': 'Up', 'mct_state': 'None', 'ifl_id': '--', 'vc_type': 'tag', 'mtu': 9190, 'cos': '--', 'extended_counters': True}, 'peer': {'ip': '192.168.1.2', 'state': 'UP', 'vc_type': 'tag... |
class User:
def __init__(self, id = None, email = None, name = None, surname = None, password = None, wallet = 0.00, disability = False, active_account = False, id_user_category = 2): # id_user_category = 2 -> Student
self._id = id
self._email = email
self._name = name
self._surna... | class User:
def __init__(self, id=None, email=None, name=None, surname=None, password=None, wallet=0.0, disability=False, active_account=False, id_user_category=2):
self._id = id
self._email = email
self._name = name
self._surname = surname
self._password = password
... |
# 487. Max Consecutive Ones II
# Runtime: 420 ms, faster than 12.98% of Python3 online submissions for Max Consecutive Ones II.
# Memory Usage: 14.5 MB, less than 11.06% of Python3 online submissions for Max Consecutive Ones II.
class Solution:
_FLIP_COUNT = 1
# Sliding Window
def findMaxConsecutiveOne... | class Solution:
_flip_count = 1
def find_max_consecutive_ones(self, nums: list[int]) -> int:
assert Solution._FLIP_COUNT > 0
max_count = 0
left = 0
zero_idx = []
for right in range(len(nums)):
if nums[right] == 0:
zero_idx.append(right)
... |
x1, y1, x2, y2 = map(int, input().split())
dx = x2 - x1
dy = y2 - y1
ans = []
for i in range(2):
dx, dy = -dy, dx
x2 += dx
y2 += dy
ans.append(x2)
ans.append(y2)
print(*ans)
| (x1, y1, x2, y2) = map(int, input().split())
dx = x2 - x1
dy = y2 - y1
ans = []
for i in range(2):
(dx, dy) = (-dy, dx)
x2 += dx
y2 += dy
ans.append(x2)
ans.append(y2)
print(*ans) |
# O(NlogM) / O(1)
class Solution:
def shipWithinDays(self, weights: List[int], D: int) -> int:
def count(t):
ans, cur = 1, 0
for w in weights:
cur += w
if cur > t:
ans += 1
cur = w
return ans... | class Solution:
def ship_within_days(self, weights: List[int], D: int) -> int:
def count(t):
(ans, cur) = (1, 0)
for w in weights:
cur += w
if cur > t:
ans += 1
cur = w
return ans
(l, r) = (... |
x=oi()
q=x
z(q)
| x = oi()
q = x
z(q) |
class Output:
def __init__(self,
race_nr,
winner,
loser,
):
self.race_nr = race_nr
self.winner = winner
self.loser = loser
def get_output_template(self):
if self.winner == 'O' or 'X':
results = f'\nR... | class Output:
def __init__(self, race_nr, winner, loser):
self.race_nr = race_nr
self.winner = winner
self.loser = loser
def get_output_template(self):
if self.winner == 'O' or 'X':
results = f'\nRace {self.race_nr}: car {self.winner} - WIN, car {self.loser} - LOSE\... |
#-*- coding:utf-8 -*-
# <component_name>.<environment>[.<group_number>]
HostGroups = {
'web.dev': ['web.dev.example.com'],
'ap.dev': ['ap.dev.example.com'],
'web.prod.1': ['web001.example.com'],
'web.prod.2': ['web{:03d}.example.com'.format(n) for n in range(2,4)],
'web.prod.3': ['web{:03d}... | host_groups = {'web.dev': ['web.dev.example.com'], 'ap.dev': ['ap.dev.example.com'], 'web.prod.1': ['web001.example.com'], 'web.prod.2': ['web{:03d}.example.com'.format(n) for n in range(2, 4)], 'web.prod.3': ['web{:03d}.example.com'.format(n) for n in range(4, 6)], 'ap.prod.1': ['ap001.example.com'], 'ap.prod.2': ['ap... |
class NewsValidator:
def __init__(self, config):
self._config = config
def validate_news(self, news):
news = news.as_dict()
assert self.check_languages(news), "Wrong language!"
assert self.check_null_values(news), "Null values!"
assert self.check_description_length(new... | class Newsvalidator:
def __init__(self, config):
self._config = config
def validate_news(self, news):
news = news.as_dict()
assert self.check_languages(news), 'Wrong language!'
assert self.check_null_values(news), 'Null values!'
assert self.check_description_length(news... |
#https://programmers.co.kr/learn/courses/30/lessons/42860
def solution(name):
answer = 0
name_length = len(name)
move = [1 if name[i]=='A' else 0 for i in range(name_length)]
for i in range(name_length):
now_str = name[i]
answer += get_move_num_alphabet(now_str, 'A')
a... | def solution(name):
answer = 0
name_length = len(name)
move = [1 if name[i] == 'A' else 0 for i in range(name_length)]
for i in range(name_length):
now_str = name[i]
answer += get_move_num_alphabet(now_str, 'A')
answer += get_move_num_cursor(move)
return answer
def get_move_num_... |
#code
def SelectionSort(arr,n):
for i in range(0,n):
minpos = i
for j in range(i,n):
if(arr[j]<arr[minpos]):
minpos = j
arr[i],arr[minpos] = arr[minpos],arr[i]
#or
#temp = arr[minpos]
#arr[minpos] = arr[i]
#arr[i] = temp
#driver
ar... | def selection_sort(arr, n):
for i in range(0, n):
minpos = i
for j in range(i, n):
if arr[j] < arr[minpos]:
minpos = j
(arr[i], arr[minpos]) = (arr[minpos], arr[i])
arr = [5, 2, 8, 6, 9, 1, 4]
n = len(arr)
selection_sort(arr, n)
print('Sorted array is :')
for i in... |
ES_HOST = 'localhost:9200'
ES_INDEX = 'pending-pseudocap_go'
ES_DOC_TYPE = 'gene'
API_PREFIX = 'pseudocap_go'
API_VERSION = ''
| es_host = 'localhost:9200'
es_index = 'pending-pseudocap_go'
es_doc_type = 'gene'
api_prefix = 'pseudocap_go'
api_version = '' |
# V1.43 messages
# PID advanced
# does not include feedforward data or vbat sag comp or thrust linearization
# pid_advanced = b"$M>2^\x00\x00\x00\x00x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x007\x00\xfa\x00\xd8\x0e\x00\x00\x00\x00\x01\x01\x00\n\x14H\x00H\x00H\x00\x00\x15\x1a\x00(\x14\x00\xc8\x0fd\x04\x00\xb1"
p... | pid_advanced = b'$M>2^\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x007\x00\xfa\x00\xd8\x0e\x00\x00\x00\x00\x01\x01\x00\n\x14H\x00H\x00H\x00\x00\x15\x1a\x00(\x14\x00\xc8\x0fd\x04\x00\xb1'
pid = b'$M>\x0fp\x16D\x1f\x1aD\x1f\x1dL\x0457K(\x00\x00G'
fc_version = b'$M>\x03\x03\x01\x0c\x15\x18'
fc_version... |
N = int(input())
swifts = [int(n) for n in input().split(' ')]
semaphores = [int(n) for n in input().split(' ')]
swift_sum = 0
semaphore_sum = 0
largest = 0
for k in range(N):
swift_sum += swifts[k]
semaphore_sum += semaphores[k]
if swift_sum == semaphore_sum:
largest = k + 1
print(largest)
| n = int(input())
swifts = [int(n) for n in input().split(' ')]
semaphores = [int(n) for n in input().split(' ')]
swift_sum = 0
semaphore_sum = 0
largest = 0
for k in range(N):
swift_sum += swifts[k]
semaphore_sum += semaphores[k]
if swift_sum == semaphore_sum:
largest = k + 1
print(largest) |
# Iterate over the enitre array. Insert counts only if != 1. Pop repeated occurances of characters.
class Solution:
def compress(self, chars: List[str]) -> int:
run = 1
prev = chars[0]
i = 1
while i<len(chars):
c = chars[i]
if c==prev:
... | class Solution:
def compress(self, chars: List[str]) -> int:
run = 1
prev = chars[0]
i = 1
while i < len(chars):
c = chars[i]
if c == prev:
run += 1
chars.pop(i)
else:
if run > 1:
... |
{
"targets": [{
"target_name": "pifacecad",
"sources": ["piface.cc"],
"include_dirs": ["./src/"],
"link_settings": {
"libraries": [
"../lib/libpifacecad.a",
"../lib/libmcp23s17.a"
]
},
"cflags": ["-std=c++11"]
}]
} | {'targets': [{'target_name': 'pifacecad', 'sources': ['piface.cc'], 'include_dirs': ['./src/'], 'link_settings': {'libraries': ['../lib/libpifacecad.a', '../lib/libmcp23s17.a']}, 'cflags': ['-std=c++11']}]} |
# Definition for singly-linked list.
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
def removeNthFromEnd(self, head: ListNode, n: int) -> ListNode:
pre = ListNode(0)
pre.next = head
head1, head2 = pre, pre
for i in range(n)... | class Listnode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
def remove_nth_from_end(self, head: ListNode, n: int) -> ListNode:
pre = list_node(0)
pre.next = head
(head1, head2) = (pre, pre)
for i in range(n):
head2 = head2.n... |
with open("day10/input.txt", encoding='utf-8') as file:
data = file.read().splitlines()
opening_chars = '([{<'
closing_chars = ')]}>'
sum_of_corrupted = 0
mapping_dict = {'(' : [')', 3], '[' : [']', 57], '{' : ['}', 1197], '<' : ['>', 25137]}
mapping_dict_sums = {')' : 3, ']' : 57, '}' : 1197, '>' : 25137}
mappin... | with open('day10/input.txt', encoding='utf-8') as file:
data = file.read().splitlines()
opening_chars = '([{<'
closing_chars = ')]}>'
sum_of_corrupted = 0
mapping_dict = {'(': [')', 3], '[': [']', 57], '{': ['}', 1197], '<': ['>', 25137]}
mapping_dict_sums = {')': 3, ']': 57, '}': 1197, '>': 25137}
mapping_dict_par... |
{ 'application':{ 'type':'Application',
'name':'Template',
'backgrounds':
[
{ 'type':'Background',
'name':'bgTemplate',
'title':'Standard Template with File->Exit menu',
'size':( 400, 300 ),
'style':['resizeable'],
'statusBar':0,
'menubar':
{
'type':'MenuBar'... | {'application': {'type': 'Application', 'name': 'Template', 'backgrounds': [{'type': 'Background', 'name': 'bgTemplate', 'title': 'Standard Template with File->Exit menu', 'size': (400, 300), 'style': ['resizeable'], 'statusBar': 0, 'menubar': {'type': 'MenuBar', 'menus': [{'type': 'Menu', 'name': 'menuFile', 'label': ... |
class ErosionStatus:
is_running: bool
# signalize that the erosion (usually in other thread) should stop
stop_requested: bool = False
progress: int
def __init__(self, is_running: bool = False, progress: int = 0):
self.is_running = is_running
self.progress = progress
| class Erosionstatus:
is_running: bool
stop_requested: bool = False
progress: int
def __init__(self, is_running: bool=False, progress: int=0):
self.is_running = is_running
self.progress = progress |
# Any recipe starts with a list of ingredients. Below is an extract
# from a cookbook with the ingredients for some dishes. Write a
# program that tells you what recipe you can make based on the
# ingredient you have.
# The input format:
# A name of some ingredient.
# The ouput format:
# A message that says "food ti... | pasta = 'tomato, basil, garlic, salt, pasta, olive oil'
apple_pie = 'apple, sugar, salt, cinnamon, flour, egg, butter'
ratatouille = 'aubergine, carrot, onion, tomato, garlic, olive oil, pepper, salt'
chocolate_cake = 'chocolate, sugar, salt, flour, coffee, butter'
omelette = 'egg, milk, bacon, tomato, salt, pepper'
in... |
PROXIES = [
{'protocol':'http', 'ip_port':'118.193.26.18:8080'},
{'protocol':'http', 'ip_port':'213.136.77.246:80'},
{'protocol':'http', 'ip_port':'198.199.127.16:80'},
{'protocol':'http', 'ip_port':'103.78.213.147:80'},
{'protocol':'https', 'ip_port':'61.90.73.10:8080'},
{'protocol':'http', 'ip_port'... | proxies = [{'protocol': 'http', 'ip_port': '118.193.26.18:8080'}, {'protocol': 'http', 'ip_port': '213.136.77.246:80'}, {'protocol': 'http', 'ip_port': '198.199.127.16:80'}, {'protocol': 'http', 'ip_port': '103.78.213.147:80'}, {'protocol': 'https', 'ip_port': '61.90.73.10:8080'}, {'protocol': 'http', 'ip_port': '36.83... |
def dict_words(string):
dict_word={}
list_words=string.split()
for word in list_words:
if(dict_word.get(word)!=None):
dict_word[word]+=1
else:
dict_word[word]=1
return dict_word
def main():
with open('datasets/rosalind_ini6.txt... | def dict_words(string):
dict_word = {}
list_words = string.split()
for word in list_words:
if dict_word.get(word) != None:
dict_word[word] += 1
else:
dict_word[word] = 1
return dict_word
def main():
with open('datasets/rosalind_ini6.txt') as input_file:
... |
SORTIE_PREFIXE = "God save"
def get_enfants(parent, liens_parente, morts):
return [f for p, f in liens_parente if (p == parent) and (f not in morts)]
def get_parent(fils, liens_parente):
for p, f in liens_parente:
if f == fils:
return p
def get_heritier(mec_mort, liens_parente, morts)... | sortie_prefixe = 'God save'
def get_enfants(parent, liens_parente, morts):
return [f for (p, f) in liens_parente if p == parent and f not in morts]
def get_parent(fils, liens_parente):
for (p, f) in liens_parente:
if f == fils:
return p
def get_heritier(mec_mort, liens_parente, morts):
... |
###############################################
# #
# Created by Youssef Sully #
# Beginner python #
# While Loops 3 #
# #
################################... | print('\n{} {} {}\n'.format('-' * 9, 'While loop', '-' * 9))
iterator = 0
while iterator < 10:
print('{} '.format(iterator), end='')
iterator = iterator + 1
print('\n')
print('{} {} {}\n'.format('-' * 9, 'Using break', '-' * 9))
iterator = 0
while iterator < 10:
if iterator == 4:
print('Number 4 is ... |
class Solution:
def findOcurrences(self, text: str, first: str, second: str) -> List[str]:
text = text.split(' ')
return [text[i] for i in range(2, len(text)) if text[i - 2] == first and text[i - 1] == second]
| class Solution:
def find_ocurrences(self, text: str, first: str, second: str) -> List[str]:
text = text.split(' ')
return [text[i] for i in range(2, len(text)) if text[i - 2] == first and text[i - 1] == second] |
# Swap Pairs using Recursion
'''
Given a linked list, swap every two adjacent nodes and return its head.
You may not modify the values in the list's nodes, only nodes itself may be changed.
Example:
Given 1->2->3->4, you should return the list as 2->1->4->3.
'''
# Definition for singly-linked list.
# class ListNod... | """
Given a linked list, swap every two adjacent nodes and return its head.
You may not modify the values in the list's nodes, only nodes itself may be changed.
Example:
Given 1->2->3->4, you should return the list as 2->1->4->3.
"""
class Solution:
def swap_pairs(self, head: ListNode) -> ListNode:
if... |
class BaseMixin(object):
@property
def blocks(self):
return self.request.GET.getlist('hierarchy_block', [])
@property
def awcs(self):
return self.request.GET.getlist('hierarchy_awc', [])
@property
def gp(self):
return self.request.GET.getlist('hierarchy_gp', None)
def... | class Basemixin(object):
@property
def blocks(self):
return self.request.GET.getlist('hierarchy_block', [])
@property
def awcs(self):
return self.request.GET.getlist('hierarchy_awc', [])
@property
def gp(self):
return self.request.GET.getlist('hierarchy_gp', None)
def... |
n, k = input().strip().split(' ')
n, k = int(n), int(k)
imp_contests = 0
imp = []
nimp = []
for i in range(n):
l, t = input().strip().split(' ')
l, t = int(l), int(t)
if t == 1:
imp.append([l,t])
else:
nimp.append([l,t])
imp.sort()
ans = 0
ans_subtract = 0
for i in ran... | (n, k) = input().strip().split(' ')
(n, k) = (int(n), int(k))
imp_contests = 0
imp = []
nimp = []
for i in range(n):
(l, t) = input().strip().split(' ')
(l, t) = (int(l), int(t))
if t == 1:
imp.append([l, t])
else:
nimp.append([l, t])
imp.sort()
ans = 0
ans_subtract = 0
for i in range(le... |
def f(a):
s = 0
for i in range(1,a):
if a%i == 0:
s+=i
return "Perfect" if s==a else ("Abundant" if s > a else "Deficient")
T = int(input())
L = list(map(int,input().split()))
for i in L:
print(f(i)) | def f(a):
s = 0
for i in range(1, a):
if a % i == 0:
s += i
return 'Perfect' if s == a else 'Abundant' if s > a else 'Deficient'
t = int(input())
l = list(map(int, input().split()))
for i in L:
print(f(i)) |
#!/usr/bin/python
class Block(object):
def __init__(self):
print("Block")
class Chain(object):
def __init__(self):
print("Chain")
def main():
b = Block()
c = Chain()
if __name__ == "__main__":
main() | class Block(object):
def __init__(self):
print('Block')
class Chain(object):
def __init__(self):
print('Chain')
def main():
b = block()
c = chain()
if __name__ == '__main__':
main() |
class Config:
DEBUG = True
SQLALCHEMY_DATABASE_URI = "mysql+mysqldb://taewookim:1234@173.194.86.171:3306/roompi2_db"
SQLALCHEMY_TRACK_MODIFICATION = True
@classmethod
def init_app(cls, app):
# config setting for flask app instance
app.config.from_object(cls)
return app
| class Config:
debug = True
sqlalchemy_database_uri = 'mysql+mysqldb://taewookim:1234@173.194.86.171:3306/roompi2_db'
sqlalchemy_track_modification = True
@classmethod
def init_app(cls, app):
app.config.from_object(cls)
return app |
# -*- coding: utf-8 -*-
# segundo link: dobro do terceiro
# segundo link: metade do primeiro
clicks_on_3 = int(input())
clicks_on_2 = clicks_on_3 * 2
clicks_on_1 = clicks_on_2 * 2
print(clicks_on_1)
| clicks_on_3 = int(input())
clicks_on_2 = clicks_on_3 * 2
clicks_on_1 = clicks_on_2 * 2
print(clicks_on_1) |
#Coded by Ribhu Sengupta.
def solveKnightMove(board, n, move_no, currRow, currCol): #solveKnightMove(board, dimesion of board, Moves_already_done, currRoe, currCol)
if move_no == n*n: #Lets say n=8, if no of moves knight covered 64 then it will stop further recursion.
return True
rowDir = [+... | def solve_knight_move(board, n, move_no, currRow, currCol):
if move_no == n * n:
return True
row_dir = [+2, +1, -1, -2, -2, -1, +2, +2]
col_dir = [+1, +2, +2, +1, -1, -2, -2, -1]
for index in range(0, len(rowDir)):
next_row = currRow + rowDir[index]
next_col = currCol + colDir[in... |
# https://leetcode.com/problems/jewels-and-stones/description/
# input: J = "aA" | S = "aAAbbbb"
# output: 3
# input: J = "z", S = "ZZ"
# output: 0
# Solution: O(N^2)
def num_jewels_in_stones(J, S):
jewels = 0
for j in J:
for s in S:
if s == j:
jewels += 1
return j... | def num_jewels_in_stones(J, S):
jewels = 0
for j in J:
for s in S:
if s == j:
jewels += 1
return jewels
print(num_jewels_in_stones('aA', 'aAAbbbb'))
print(num_jewels_in_stones('z', 'ZZ'))
def num_jewels_in_stones_opt(J, S):
number_by_chars = {}
counter = 0
fo... |
def writeList(l,name):
wptr = open(name,"w")
wptr.write("%d\n" % len(l))
for i in l:
wptr.write("%d\n" % i)
wptr.close() | def write_list(l, name):
wptr = open(name, 'w')
wptr.write('%d\n' % len(l))
for i in l:
wptr.write('%d\n' % i)
wptr.close() |
# DEFAULT ROUTE
ROUTE_SANDBOX = 'https://sandbox.boletobancario.com/api-integration'
ROUTE_SANDBOX_AUTORIZATION_SERVER = "https://sandbox.boletobancario.com/authorization-server/oauth/token"
ROUTE_PRODUCAO = 'https://api.juno.com.br'
ROUTE_PRODUCAO_AUTORIZATION_SERVER = "https://api.juno.com.br/authorization-server/oa... | route_sandbox = 'https://sandbox.boletobancario.com/api-integration'
route_sandbox_autorization_server = 'https://sandbox.boletobancario.com/authorization-server/oauth/token'
route_producao = 'https://api.juno.com.br'
route_producao_autorization_server = 'https://api.juno.com.br/authorization-server/oauth/token' |
user_input = input("Enter maximum number: ")
number = int(user_input)
spaces_amount = number // 2
f = open("my_tree.txt", "w")
while (spaces_amount >= 0):
if (spaces_amount*2 == number):
spaces_amount -= 1
continue
for j in range(spaces_amount):
f.write(" ")
# print(" ", sep="", end="")
for ... | user_input = input('Enter maximum number: ')
number = int(user_input)
spaces_amount = number // 2
f = open('my_tree.txt', 'w')
while spaces_amount >= 0:
if spaces_amount * 2 == number:
spaces_amount -= 1
continue
for j in range(spaces_amount):
f.write(' ')
for j in range(number - spa... |
# Copyright (c) 2020. JetBrains s.r.o.
# Use of this source code is governed by the MIT license that can be found in the LICENSE file.
# from .corr import *
# from .im import *
# __all__ = (im.__all__ +
# corr.__all__)
# 'bistro' packages must be imported explicitly.
__all__ = []
| __all__ = [] |
if __name__ == "__main__":
net_amount=0
while(True):
person = input("Enter the amount that you want to Deposit/Withdral ? ")
transaction = person.split(" ")
type = transaction[0]
amount =int( transaction[1])
if type =="D" or type =='d':
net_amount += ... | if __name__ == '__main__':
net_amount = 0
while True:
person = input('Enter the amount that you want to Deposit/Withdral ? ')
transaction = person.split(' ')
type = transaction[0]
amount = int(transaction[1])
if type == 'D' or type == 'd':
net_amount += amount... |
# Put the token you got from https://discord.com/developers/applications/ here
token = 'x'
# Choose the prefix you'd like for your bot
prefix = "?"
# Copy your user id on Discord to set you as the owner of this bot
myid = 0
# Change None to the id of your logschannel (if you want one)
logschannelid = None
# Change 0 to... | token = 'x'
prefix = '?'
myid = 0
logschannelid = None
myserverid = 0 |
# course = "Python's course for Beginners"
# print(course[0])
# print(course[-1])
# print(course[-2])
# print(course[0:3])
# print(course[0:])
# print(course[1:])
# print(course[:5])
# print(course[:]) # copy string
#
# another = course[:]
# print(another)
#######################################
# f... | course = "Python's course for Beginners"
print(course.find('p'))
print(course.find('P'))
print(course.find('o'))
print(course.find('Beginners'))
print(course.replace('Beginners', 'Absolute Beginners'))
print('Python' in course)
print(course.title()) |
class bcolors:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
# default load test intervals, in milliseconds
INTERVAL_DEFAULT = 200
# load test speed, txs per second
TXS_PER_SE... | class Bcolors:
header = '\x1b[95m'
okblue = '\x1b[94m'
okgreen = '\x1b[92m'
warning = '\x1b[93m'
fail = '\x1b[91m'
endc = '\x1b[0m'
bold = '\x1b[1m'
underline = '\x1b[4m'
interval_default = 200
txs_per_sec_normal = 100
txs_per_sec_slow = 10
tx_commit = 1
tx_sync = 2
tx_async = 3 |
# -*- coding: utf-8 -*-
# @Time : 2020/1/23 13:38
# @Author : jwh5566
# @Email : jwh5566@aliyun.com
# @File : if_example.py
def check_if():
a = int(input("Enter a number \n"))
if (a == 100):
print("a is equal 100")
else:
print("a is not equal 100")
return a
| def check_if():
a = int(input('Enter a number \n'))
if a == 100:
print('a is equal 100')
else:
print('a is not equal 100')
return a |
amount_of_dancers = int(input())
amount_of_points = float(input())
season = input()
place = input()
money_left = 0
charity = 0
dancers_point_won = amount_of_dancers * amount_of_points
dancers_point_won_aboard = dancers_point_won + (dancers_point_won * 0.50)
money_per_dancer = 0
if place == "Bulgaria":
if season =... | amount_of_dancers = int(input())
amount_of_points = float(input())
season = input()
place = input()
money_left = 0
charity = 0
dancers_point_won = amount_of_dancers * amount_of_points
dancers_point_won_aboard = dancers_point_won + dancers_point_won * 0.5
money_per_dancer = 0
if place == 'Bulgaria':
if season == 'su... |
nome = input("Qual seu nome: ")
idade = int(input("Qual sua idade: "))
altura = float(input("Qual sua altura: "))
peso = float(input("Qual seu peso: "))
op= int(input("Estado civil:\n1.Casado\n2.Solteiro\n"))
if op==1:
op = True
else:
op = False
eu = [nome, idade, altura, peso, op]
for c in eu:
print(c,... | nome = input('Qual seu nome: ')
idade = int(input('Qual sua idade: '))
altura = float(input('Qual sua altura: '))
peso = float(input('Qual seu peso: '))
op = int(input('Estado civil:\n1.Casado\n2.Solteiro\n'))
if op == 1:
op = True
else:
op = False
eu = [nome, idade, altura, peso, op]
for c in eu:
print(c, ... |
#Example:
grocery = 'Milk\nChicken\r\nBread\rButter'
print(grocery.splitlines())
print(grocery.splitlines(True))
grocery = 'Milk Chicken Bread Butter'
print(grocery.splitlines())
| grocery = 'Milk\nChicken\r\nBread\rButter'
print(grocery.splitlines())
print(grocery.splitlines(True))
grocery = 'Milk Chicken Bread Butter'
print(grocery.splitlines()) |
class Document:
# general info about document
class Info:
def __init__(self):
self.author = "unknown"
self.producer = "unknown"
self.subject = "unknown"
self.title = "unknown"
self.table_of_contents = []
def __init__(self, path: str, is_pd... | class Document:
class Info:
def __init__(self):
self.author = 'unknown'
self.producer = 'unknown'
self.subject = 'unknown'
self.title = 'unknown'
self.table_of_contents = []
def __init__(self, path: str, is_pdf: bool):
self.is_pdf = ... |
class Solution:
def removeElement(self, nums: [int], val: int) -> int:
i = 0
j = len(nums)
while i < j:
if nums[i] == val:
nums[i] = nums[j - 1]
j -= 1
else:
i += 1
return i
| class Solution:
def remove_element(self, nums: [int], val: int) -> int:
i = 0
j = len(nums)
while i < j:
if nums[i] == val:
nums[i] = nums[j - 1]
j -= 1
else:
i += 1
return i |
class Solution:
def findItinerary(self, tickets: List[List[str]]) -> List[str]:
def dfs(graph, u, res):
while(len(graph[u])):
dfs(graph, graph[u].pop(), res)
res.append(u)
graph = defaultdict(list)
res = []
for ticket in tickets:
... | class Solution:
def find_itinerary(self, tickets: List[List[str]]) -> List[str]:
def dfs(graph, u, res):
while len(graph[u]):
dfs(graph, graph[u].pop(), res)
res.append(u)
graph = defaultdict(list)
res = []
for ticket in tickets:
... |
'''
Description:
X is a good number if after rotating each digit individually by 180 degrees, we get a valid number that is different from X. Each digit must be rotated - we cannot choose to leave it alone.
A number is valid if each digit remains a digit after rotation. 0, 1, and 8 rotate to themselves; 2 and 5 rot... | """
Description:
X is a good number if after rotating each digit individually by 180 degrees, we get a valid number that is different from X. Each digit must be rotated - we cannot choose to leave it alone.
A number is valid if each digit remains a digit after rotation. 0, 1, and 8 rotate to themselves; 2 and 5 rot... |
# Python - 2.7.6
Test.describe('Basic tests')
Test.assert_equals(logical_calc([True, False], 'AND'), False)
Test.assert_equals(logical_calc([True, False], 'OR'), True)
Test.assert_equals(logical_calc([True, False], 'XOR'), True)
Test.assert_equals(logical_calc([True, True, False], 'AND'), False)
Test.assert_equals(lo... | Test.describe('Basic tests')
Test.assert_equals(logical_calc([True, False], 'AND'), False)
Test.assert_equals(logical_calc([True, False], 'OR'), True)
Test.assert_equals(logical_calc([True, False], 'XOR'), True)
Test.assert_equals(logical_calc([True, True, False], 'AND'), False)
Test.assert_equals(logical_calc([True, T... |
# -*- coding: utf-8 -*-
class INITIALIZE(object):
def __init__(self, ALPHANUMERIC=' ', NUMERIC=0):
self.alphanumeric = ALPHANUMERIC
self.numeric = NUMERIC
def __call__(self, obj):
self.initialize(obj)
def initialize(self, obj):
if isinstance(obj, dict):
for k, ... | class Initialize(object):
def __init__(self, ALPHANUMERIC=' ', NUMERIC=0):
self.alphanumeric = ALPHANUMERIC
self.numeric = NUMERIC
def __call__(self, obj):
self.initialize(obj)
def initialize(self, obj):
if isinstance(obj, dict):
for (k, v) in obj.items():
... |
class Config:
SECRET_KEY = 'hard to guess string'
SQLALCHEMY_COMMIT_ON_TEARDOWN = True
MAIL_SERVER = 'smtp.qq.com'
MAIL_PORT = 465
MAIL_USE_TLS = False
MAIL_USE_SSL = True
MAIL_USERNAME = '536700549@qq.com'
MAIL_PASSWORD = 'mystery123.'
FLASKY_MAIL_SUBJECT_PREFIX = '[Flasky]'
FLA... | class Config:
secret_key = 'hard to guess string'
sqlalchemy_commit_on_teardown = True
mail_server = 'smtp.qq.com'
mail_port = 465
mail_use_tls = False
mail_use_ssl = True
mail_username = '536700549@qq.com'
mail_password = 'mystery123.'
flasky_mail_subject_prefix = '[Flasky]'
fla... |
n = int(input())
lst = [float('inf') for _ in range(n+1)]
lst[1] = 0
for i in range(1,n):
if 3*i<=n:lst[3*i]=min(lst[3*i],lst[i]+1)
if 2*i<=n:lst[2*i]=min(lst[2*i],lst[i]+1)
lst[i+1]=min(lst[i+1],lst[i]+1)
print(lst[n])
| n = int(input())
lst = [float('inf') for _ in range(n + 1)]
lst[1] = 0
for i in range(1, n):
if 3 * i <= n:
lst[3 * i] = min(lst[3 * i], lst[i] + 1)
if 2 * i <= n:
lst[2 * i] = min(lst[2 * i], lst[i] + 1)
lst[i + 1] = min(lst[i + 1], lst[i] + 1)
print(lst[n]) |
Till=int(input("Enter the upper limit\n"))
From=int(input("Enter the lower limit\n"))
i=1
print("\n")
while(From<=Till):
if((From%4==0)and(From%100!=0))or(From%400==0):
print(From)
From+=1
input()
| till = int(input('Enter the upper limit\n'))
from = int(input('Enter the lower limit\n'))
i = 1
print('\n')
while From <= Till:
if From % 4 == 0 and From % 100 != 0 or From % 400 == 0:
print(From)
from += 1
input() |
class Square:
piece = None
promoting = False
def __init__(self, promoting=False):
self.promoting = promoting
def set_piece(self, piece):
self.piece = piece
def remove_piece(self):
self.piece = None
def get_piece(self):
return self.piece
def is_empty(self)... | class Square:
piece = None
promoting = False
def __init__(self, promoting=False):
self.promoting = promoting
def set_piece(self, piece):
self.piece = piece
def remove_piece(self):
self.piece = None
def get_piece(self):
return self.piece
def is_empty(self)... |
# -*- coding: utf-8 -*-
# @Time : 2022/2/14 13:50
# @Author : ZhaoXiangPeng
# @File : __init__.py
class Monitor:
def update(self):
pass
| class Monitor:
def update(self):
pass |
print("Welcome to the tip calculator!!")
total_bill = float(input("What was the total bill? "))
percent = int(input("What percentage tip you would like to give: 10%, 12%, or 15%? "))
people = int(input("How many people to split the bill? "))
pay = round((total_bill/people) + ((total_bill*percent)/100)/people,2)
print(f... | print('Welcome to the tip calculator!!')
total_bill = float(input('What was the total bill? '))
percent = int(input('What percentage tip you would like to give: 10%, 12%, or 15%? '))
people = int(input('How many people to split the bill? '))
pay = round(total_bill / people + total_bill * percent / 100 / people, 2)
prin... |
'''
Starting with the number 1 and moving to the right in a clockwise direction a 5 by 5 spiral is formed as follows:
21 22 23 24 25
20 7 8 9 10
19 6 1 2 11
18 5 4 3 12
17 16 15 14 13
It can be verified that the sum of the numbers on the diagonals is 101.
What is the sum of the numbers on the diagonals in a... | """
Starting with the number 1 and moving to the right in a clockwise direction a 5 by 5 spiral is formed as follows:
21 22 23 24 25
20 7 8 9 10
19 6 1 2 11
18 5 4 3 12
17 16 15 14 13
It can be verified that the sum of the numbers on the diagonals is 101.
What is the sum of the numbers on the diagonals in a... |
__version__ = "0.19.2" # NOQA
if __name__ == "__main__":
print(__version__)
| __version__ = '0.19.2'
if __name__ == '__main__':
print(__version__) |
# Copyright 2015 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
DEPS = [
'depot_tools/bot_update',
'depot_tools/gclient',
'depot_tools/infra_paths',
'infra_checkout',
'recipe_engine/buildbucket',
'recipe_engin... | deps = ['depot_tools/bot_update', 'depot_tools/gclient', 'depot_tools/infra_paths', 'infra_checkout', 'recipe_engine/buildbucket', 'recipe_engine/json', 'recipe_engine/path', 'recipe_engine/platform', 'recipe_engine/properties', 'recipe_engine/python', 'recipe_engine/step']
def run_steps(api):
patch_root = 'infra-... |
input_image = itk.imread('data/BrainProtonDensitySlice.png', itk.ctype('unsigned char'))
isolated_connected = itk.IsolatedConnectedImageFilter.New(input_image)
isolated_connected.SetSeed1([98, 112])
isolated_connected.SetSeed2([98, 136])
isolated_connected.SetUpperValueLimit( 245 )
isolated_connected.FindUpperThreshold... | input_image = itk.imread('data/BrainProtonDensitySlice.png', itk.ctype('unsigned char'))
isolated_connected = itk.IsolatedConnectedImageFilter.New(input_image)
isolated_connected.SetSeed1([98, 112])
isolated_connected.SetSeed2([98, 136])
isolated_connected.SetUpperValueLimit(245)
isolated_connected.FindUpperThresholdOf... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.