content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
# -*- 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... |
number=0
list1=[]
wnumber=0
lnumber=0
while number<7:
winnumber=input().upper()
number+=1
list1.append(winnumber)
for i in list1:
if 'W' == i:
wnumber+=1
else:
lnumber+=1
if wnumber>=5:
print('1')
elif wnumber<=4 and wnumber>=3:
print('2')
elif wnum... | number = 0
list1 = []
wnumber = 0
lnumber = 0
while number < 7:
winnumber = input().upper()
number += 1
list1.append(winnumber)
for i in list1:
if 'W' == i:
wnumber += 1
else:
lnumber += 1
if wnumber >= 5:
print('1')
elif wnumber <= 4 and wnumber >= 3:
print('2')
elif wnumber... |
#!/usr/bin/env python3
steps = 316
circ_buffer = [0]
pos = 0
num = 0
for cnt in range(1, 50000001):
pos = (pos + steps) % cnt
if pos == 0:
num = cnt
pos += 1
print(num)
| steps = 316
circ_buffer = [0]
pos = 0
num = 0
for cnt in range(1, 50000001):
pos = (pos + steps) % cnt
if pos == 0:
num = cnt
pos += 1
print(num) |
# 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 th... | class Dbcolumn:
def __init__(self, name: str, type: str, description: str=None, ordinal_position: int=None):
self.name = name
self.type = type
self.description = description
self.ordinal_position = ordinal_position
def __eq__(self, other):
return self.name == other.name... |
#Kunal Gautam
#Codewars : @Kunalpod
#Problem name: Sum of Odd Numbers
#Problem level: 7 kyu
def row_sum_odd_numbers(n):
return n**3
| def row_sum_odd_numbers(n):
return n ** 3 |
class Solution:
def XXX(self, nums: List[int]) -> None:
rgb = [0, 0, 0]
for i in nums:
rgb[i] += 1
nums[:rgb[0]] = [0 for _ in range(rgb[0])]
nums[rgb[0]:rgb[0] + rgb[1]] = [1 for _ in range(rgb[1])]
nums[rgb[0] + rgb[1]:] = [2 for _ in range(rgb[2])]
| class Solution:
def xxx(self, nums: List[int]) -> None:
rgb = [0, 0, 0]
for i in nums:
rgb[i] += 1
nums[:rgb[0]] = [0 for _ in range(rgb[0])]
nums[rgb[0]:rgb[0] + rgb[1]] = [1 for _ in range(rgb[1])]
nums[rgb[0] + rgb[1]:] = [2 for _ in range(rgb[2])] |
"""Constants used in the library."""
EMAIL_HEADER_SUBJECT = "email-header-subject"
EMAIL_HEADER_DATE = "email-header-date"
| """Constants used in the library."""
email_header_subject = 'email-header-subject'
email_header_date = 'email-header-date' |
def orelse(*iters):
found = False
for iter in iters:
for elem in iter:
found = True
yield elem
if found:
break
def extract(it, pred):
extracted = []
def filtered_it():
nonlocal extracted
for elem in it:
if pred(elem):
... | def orelse(*iters):
found = False
for iter in iters:
for elem in iter:
found = True
yield elem
if found:
break
def extract(it, pred):
extracted = []
def filtered_it():
nonlocal extracted
for elem in it:
if pred(elem):
... |
# -*- coding: utf-8 -*-
competidores, n_voltas = list(map(int, input().split()))
competidor_1 = list(map(int, input().split()))
melhor_tempo = sum(competidor_1)
vencedor = 1
for i in range(1, competidores):
competidor_i = list(map(int, input().split()))
tempo_i = sum(competidor_i)
if (tempo_i < melhor_tem... | (competidores, n_voltas) = list(map(int, input().split()))
competidor_1 = list(map(int, input().split()))
melhor_tempo = sum(competidor_1)
vencedor = 1
for i in range(1, competidores):
competidor_i = list(map(int, input().split()))
tempo_i = sum(competidor_i)
if tempo_i < melhor_tempo:
melhor_tempo ... |
CURSOR_TO_BOTTOM = 0
CURSOR_TO_CENTER = 1
CURSOR_TO_TOP = 2
VIEWPORT_LINE_UP = 3
VIEWPORT_LINE_DOWN = 4
HERE = 0
ELSEWHERE = 1
class ViewportNote(object):
pass
class ViewportContextChange(ViewportNote):
def __init__(self, context, change_source):
"""`change_source` is either HERE or ELSEWHERE; the... | cursor_to_bottom = 0
cursor_to_center = 1
cursor_to_top = 2
viewport_line_up = 3
viewport_line_down = 4
here = 0
elsewhere = 1
class Viewportnote(object):
pass
class Viewportcontextchange(ViewportNote):
def __init__(self, context, change_source):
"""`change_source` is either HERE or ELSEWHERE; the di... |
DEFAULT_BRANCH = "unstable"
GITREPOS = {}
GITREPOS["builders_extra"] = [
"https://github.com/threefoldtech/jumpscaleX_builders",
"%s" % DEFAULT_BRANCH,
"JumpscaleBuildersExtra",
"{DIR_BASE}/lib/jumpscale/JumpscaleBuildersExtra",
]
GITREPOS["installer"] = [
"https://github.com/threefoldtech/jumpsca... | default_branch = 'unstable'
gitrepos = {}
GITREPOS['builders_extra'] = ['https://github.com/threefoldtech/jumpscaleX_builders', '%s' % DEFAULT_BRANCH, 'JumpscaleBuildersExtra', '{DIR_BASE}/lib/jumpscale/JumpscaleBuildersExtra']
GITREPOS['installer'] = ['https://github.com/threefoldtech/jumpscaleX_core', '%s' % DEFAULT_... |
#!/usr/bin/env python
script_version = "0.21"
processed_comp_list = []
spdx_lics = []
# The name of a custom attribute which should override the default package supplier
SBOM_CUSTOM_SUPPLIER_NAME = "PackageSupplier"
usage_dict = {
"SOURCE_CODE": "CONTAINS",
"STATICALLY_LINKED": "STATIC_LINK",
"DYNAMICALL... | script_version = '0.21'
processed_comp_list = []
spdx_lics = []
sbom_custom_supplier_name = 'PackageSupplier'
usage_dict = {'SOURCE_CODE': 'CONTAINS', 'STATICALLY_LINKED': 'STATIC_LINK', 'DYNAMICALLY_LINKED': 'DYNAMIC_LINK', 'SEPARATE_WORK': 'OTHER', 'MERELY_AGGREGATED': 'OTHER', 'IMPLEMENTATION_OF_STANDARD': 'OTHER', ... |
gos_file = open('GOS.csv')
gos_lines = gos_file.readlines()
gos_file.close()
gos_map = {}
for l in gos_lines[1:]:
sl = l.split(',')
gos_map[int(sl[0])] = int(sl[1])
observe_file = open('rf_observ - Copy.csv')
obs_lines = observe_file.readlines()
observe_file.close()
obs_tot_map = {}
obs_rea_map = {}
obs_pre_map ... | gos_file = open('GOS.csv')
gos_lines = gos_file.readlines()
gos_file.close()
gos_map = {}
for l in gos_lines[1:]:
sl = l.split(',')
gos_map[int(sl[0])] = int(sl[1])
observe_file = open('rf_observ - Copy.csv')
obs_lines = observe_file.readlines()
observe_file.close()
obs_tot_map = {}
obs_rea_map = {}
obs_pre_map... |
class Solution:
def maxNumberOfBalloons(self, text: str) -> int:
b = text.count('b')
a = text.count('a')
l = int(text.count('l') / 2)
o = int(text.count('o') / 2)
n = text.count('n')
f = [b, a, l, o, n]
return min(f)
class Solution:
def maxNumberOfB... | class Solution:
def max_number_of_balloons(self, text: str) -> int:
b = text.count('b')
a = text.count('a')
l = int(text.count('l') / 2)
o = int(text.count('o') / 2)
n = text.count('n')
f = [b, a, l, o, n]
return min(f)
class Solution:
def max_number_of... |
#!/usr/bin/env python
files = [ "oiio-logo-no-alpha.png", "oiio-logo-with-alpha.png" ]
for f in files:
command += rw_command (OIIO_TESTSUITE_IMAGEDIR, f)
| files = ['oiio-logo-no-alpha.png', 'oiio-logo-with-alpha.png']
for f in files:
command += rw_command(OIIO_TESTSUITE_IMAGEDIR, f) |
# Enter your code here. Read input from STDIN. Print output to STDOUT
# Take 2 input sets A and B
input()
A = set(map(int, input().split()))
input()
B = set(map(int, input().split()))
# Print union by set.union
print(len(A.union(B)))
| input()
a = set(map(int, input().split()))
input()
b = set(map(int, input().split()))
print(len(A.union(B))) |
# -*- coding: utf-8 -*-
def main():
n, w = map(int, input().split())
ws = [0 for _ in range(n)]
vs = [0 for _ in range(n)]
inf = 10 ** 12
dp = [[inf for _ in range(((n + 1) * 10 ** 3) + 1)] for _ in range(n + 1)]
for i in range(n):
wi, vi = map(int, input().split())
... | def main():
(n, w) = map(int, input().split())
ws = [0 for _ in range(n)]
vs = [0 for _ in range(n)]
inf = 10 ** 12
dp = [[inf for _ in range((n + 1) * 10 ** 3 + 1)] for _ in range(n + 1)]
for i in range(n):
(wi, vi) = map(int, input().split())
ws[i] = wi
vs[i] = vi
d... |
OCTICON_DIFF_REMOVED = """
<svg class="octicon octicon-diff-removed" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M2.75 2.5h10.5a.25.25 0 01.25.25v10.5a.25.25 0 01-.25.25H2.75a.25.25 0 01-.25-.25V2.75a.25.25 0 01.25-.25zM13.25 1H2.75A1.75 1.75 0 001 2.75v10... | octicon_diff_removed = '\n<svg class="octicon octicon-diff-removed" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M2.75 2.5h10.5a.25.25 0 01.25.25v10.5a.25.25 0 01-.25.25H2.75a.25.25 0 01-.25-.25V2.75a.25.25 0 01.25-.25zM13.25 1H2.75A1.75 1.75 0 001 2.75v10.5... |
# The isBadVersion API is already defined for you.
# @param version, an integer
# @return a bool
# def isBadVersion(version):
class Solution:
def firstBadVersion(self, n):
"""
:type n: int
:rtype: int
"""
left, right = 1, n
while left <= right:
mid = left... | class Solution:
def first_bad_version(self, n):
"""
:type n: int
:rtype: int
"""
(left, right) = (1, n)
while left <= right:
mid = left + (right - left) / 2
if is_bad_version(mid):
right = mid - 1
else:
... |
class DayOfAGossipingBusDriver(object):
def __init__(self, drivers, gossip_universe):
self.drivers = drivers
self.gossip_universe = gossip_universe
def one_minute_passed(self):
self.share_gossips_between_all_drivers()
self.all_drivers_drive()
def share_gossips_between_all_d... | class Dayofagossipingbusdriver(object):
def __init__(self, drivers, gossip_universe):
self.drivers = drivers
self.gossip_universe = gossip_universe
def one_minute_passed(self):
self.share_gossips_between_all_drivers()
self.all_drivers_drive()
def share_gossips_between_all_... |
class ModelError(Exception):
"""
Errors about Models
"""
pass
| class Modelerror(Exception):
"""
Errors about Models
"""
pass |
# Example which shows using ANSI color codes to print color to the terminal
# window.
def color(this_color, string):
return "\033[" + this_color + "m" + string + "\033[0m"
for i in range(30, 38):
c = str(i)
print('This is %s' % color(c, 'color ' + c))
c = '1;' + str(i)
print('This is %s' % color(... | def color(this_color, string):
return '\x1b[' + this_color + 'm' + string + '\x1b[0m'
for i in range(30, 38):
c = str(i)
print('This is %s' % color(c, 'color ' + c))
c = '1;' + str(i)
print('This is %s' % color(c, 'color ' + c)) |
# @Author : guopeiming
# @Contact : guopeiming2016@{qq, gmail, 163}.com
oovKey = '<unk>'
oovId = 0
padKey = '<pad>'
padId = 1
BOS = '<BOS>'
EOS = '<EOS>'
APP = 0
SEG = 1
actionPadId = 2
bertAttr = 'bert'
embeddings_layer_keyword = 'embeddings'
EPSILON = 1e-10
MAX_OOV_NUM = 1500
| oov_key = '<unk>'
oov_id = 0
pad_key = '<pad>'
pad_id = 1
bos = '<BOS>'
eos = '<EOS>'
app = 0
seg = 1
action_pad_id = 2
bert_attr = 'bert'
embeddings_layer_keyword = 'embeddings'
epsilon = 1e-10
max_oov_num = 1500 |
class BaseTestCSVUpload(object):
def test_generate_username_from_email(self):
reader = [['', 'cleartext$password', 'rohith@openwisp.com', 'Rohith', 'ASRK']]
batch = self.radius_batch_model.objects.create()
batch.add(reader)
self.assertEqual(self.radius_batch_model.objects.all().count... | class Basetestcsvupload(object):
def test_generate_username_from_email(self):
reader = [['', 'cleartext$password', 'rohith@openwisp.com', 'Rohith', 'ASRK']]
batch = self.radius_batch_model.objects.create()
batch.add(reader)
self.assertEqual(self.radius_batch_model.objects.all().coun... |
a3, a2, a1 = int(input()), int(input()), int(input())
b3, b2, b1 = int(input()), int(input()), int(input())
a_total = a3 * 3 + a2 * 2 + a1
b_total = b3 * 3 + b2 * 2 + b1
if a_total > b_total:
print("A")
elif a_total == b_total:
print("T")
else:
print("B")
| (a3, a2, a1) = (int(input()), int(input()), int(input()))
(b3, b2, b1) = (int(input()), int(input()), int(input()))
a_total = a3 * 3 + a2 * 2 + a1
b_total = b3 * 3 + b2 * 2 + b1
if a_total > b_total:
print('A')
elif a_total == b_total:
print('T')
else:
print('B') |
"""
1598. Crawler Log Folder
Easy
The Leetcode file system keeps a log each time some user performs a change folder operation.
The operations are described below:
"../" : Move to the parent folder of the current folder. (If you are already in the main folder, remain in the same folder).
"./" : Remain in the same fol... | """
1598. Crawler Log Folder
Easy
The Leetcode file system keeps a log each time some user performs a change folder operation.
The operations are described below:
"../" : Move to the parent folder of the current folder. (If you are already in the main folder, remain in the same folder).
"./" : Remain in the same fol... |
def indval(x):
return '@' + str(x)
def immval(x):
return '#' + str(x) | def indval(x):
return '@' + str(x)
def immval(x):
return '#' + str(x) |
class FeatureExtractor(object):
def __init__(self, files):
self.files = files
def retrieve_coords(self):
return self._retrieve_coords()
def retrieve_dihedrals(self):
return self._retrieve_dihedrals()
| class Featureextractor(object):
def __init__(self, files):
self.files = files
def retrieve_coords(self):
return self._retrieve_coords()
def retrieve_dihedrals(self):
return self._retrieve_dihedrals() |
class Imaging(object):
""" Provides managed to unmanaged interoperation support for creating image objects. """
@staticmethod
def CreateBitmapSourceFromHBitmap(bitmap,palette,sourceRect,sizeOptions):
"""
CreateBitmapSourceFromHBitmap(bitmap: IntPtr,palette: IntPtr,sourceRect: Int32Rect,sizeOptions: BitmapSi... | class Imaging(object):
""" Provides managed to unmanaged interoperation support for creating image objects. """
@staticmethod
def create_bitmap_source_from_h_bitmap(bitmap, palette, sourceRect, sizeOptions):
"""
CreateBitmapSourceFromHBitmap(bitmap: IntPtr,palette: IntPtr,sourceRect: Int32Rect,si... |
# quicksort algorithms for linked list
class ListNode:
def __init__(self, val, next=None):
self.val = val
self.next = next
def __repr__(self):
rv = str(self.val)
if self.next:
rv = rv + ' -> ' + repr(self.next)
return rv
def qsort(start, end=None):
if... | class Listnode:
def __init__(self, val, next=None):
self.val = val
self.next = next
def __repr__(self):
rv = str(self.val)
if self.next:
rv = rv + ' -> ' + repr(self.next)
return rv
def qsort(start, end=None):
if start is end or start.next is end:
... |
class Solution:
def romanToInt(self, s: str) -> int:
d = {'I':1, 'V':5, 'X':10,'L':50,'C':100, 'D':500,'M':1000, 'IV':4, 'IX':9, 'XL':40, 'XC':90,'CD':400, 'CM':900}
i, res = 0, 0
while i < len(s):
twoDig = s[i:i+2]
oneDig = s[i... | class Solution:
def roman_to_int(self, s: str) -> int:
d = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000, 'IV': 4, 'IX': 9, 'XL': 40, 'XC': 90, 'CD': 400, 'CM': 900}
(i, res) = (0, 0)
while i < len(s):
two_dig = s[i:i + 2]
one_dig = s[i]
... |
description = 'Installs the Triple Axis Calculations into ZEBRA '
requires = ['monochromator', 'sample']
excludes = ['zebraeuler', 'zebranb']
sysconfig = dict(instrument = 'ZEBRA',)
devices = dict(
ZEBRA = device('nicos_sinq.sxtal.instrument.TASSXTal',
description = 'instrument object',
instrume... | description = 'Installs the Triple Axis Calculations into ZEBRA '
requires = ['monochromator', 'sample']
excludes = ['zebraeuler', 'zebranb']
sysconfig = dict(instrument='ZEBRA')
devices = dict(ZEBRA=device('nicos_sinq.sxtal.instrument.TASSXTal', description='instrument object', instrument='SINQ ZEBRA', responsible='Ok... |
class Solution(object):
def reverse(self, x):
"""
:type x: int
:rtype: int
"""
res = 0
if x >= 0:
flag = True
else:
flag = False
x = -x
while x is not 0:
res = (res * 10) + x % 10
x = x/10
... | class Solution(object):
def reverse(self, x):
"""
:type x: int
:rtype: int
"""
res = 0
if x >= 0:
flag = True
else:
flag = False
x = -x
while x is not 0:
res = res * 10 + x % 10
x = x / 10
... |
cont=0
soma=0
numero=int(input("Digite um numero: "))
while cont <=10:
soma = soma + cont*2
cont = cont +1
print (soma)
| cont = 0
soma = 0
numero = int(input('Digite um numero: '))
while cont <= 10:
soma = soma + cont * 2
cont = cont + 1
print(soma) |
a = input('please input a number: ')
b = input('please input a second number: ')
ax = a
bx = b
a = bx
b = ax
print(a)
print(b)
| a = input('please input a number: ')
b = input('please input a second number: ')
ax = a
bx = b
a = bx
b = ax
print(a)
print(b) |
def ex7():
running = True
while running:
try:
user_input = int(input("Enter an integer: "))
if user_input < 2 or str(user_input) == 0:
print("Invalid input")
if user_input == 1:
print(f"Btw the integer {user_input} is no... | def ex7():
running = True
while running:
try:
user_input = int(input('Enter an integer: '))
if user_input < 2 or str(user_input) == 0:
print('Invalid input')
if user_input == 1:
print(f'Btw the integer {user_input} is not a prim... |
# -*- coding: utf-8 -*-
"""
__init__.py
Created on 2017-11-19 by hbldh <henrik.blidh@nedomkull.com>
"""
| """
__init__.py
Created on 2017-11-19 by hbldh <henrik.blidh@nedomkull.com>
""" |
class Column:
def __init__(self, key, label, auto=False):
self.key = key
self.label = label
self.auto = auto
def get_json(self):
return {"key": self.key, "label": self.label}
def render(self, val):
return val if val else ""
class AggrColumn(Column):
def __init... | class Column:
def __init__(self, key, label, auto=False):
self.key = key
self.label = label
self.auto = auto
def get_json(self):
return {'key': self.key, 'label': self.label}
def render(self, val):
return val if val else ''
class Aggrcolumn(Column):
def __ini... |
class Solution(object):
def XXX(self, root):
"""
:type root: TreeNode
:rtype: int
"""
if not root:
return 0
max_depth=0
ret=[]
def dfs(root,max_depth):
if root:
max_depth+=1
if not root.left and n... | class Solution(object):
def xxx(self, root):
"""
:type root: TreeNode
:rtype: int
"""
if not root:
return 0
max_depth = 0
ret = []
def dfs(root, max_depth):
if root:
max_depth += 1
if not root.l... |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
d = {
'Michael': 95,
'Bob': 75,
'Tracy': 85,
'95':95,
90:90,
'stanford':100
}
print('d[\'Michael\'] =', d['Michael'])
print('d[\'Bob\'] =', d['Bob'])
print('d[\'Tracy\'] =', d['Tracy'])
print('d[\'95\'] =',d['95'])
print('d[90] =',d[90])
print('d[s... | d = {'Michael': 95, 'Bob': 75, 'Tracy': 85, '95': 95, 90: 90, 'stanford': 100}
print("d['Michael'] =", d['Michael'])
print("d['Bob'] =", d['Bob'])
print("d['Tracy'] =", d['Tracy'])
print("d['95'] =", d['95'])
print('d[90] =', d[90])
print('d[stanford] =', d['stanford'])
print("d.get('Thomas', -1) =", d.get('Thomas', -1... |
"""
Ex 07 -Develop a program that reads two grade of a student, calculate and shows it the mean
"""
print('Student average')
print('-' * 30)
n1 = float(input("Student's first grade: "))
n2 = float(input("Student's second grade: "))
m = (n1 + n2) / 2
print(f"The student's average is: {m}")
input('Enter to exit')
| """
Ex 07 -Develop a program that reads two grade of a student, calculate and shows it the mean
"""
print('Student average')
print('-' * 30)
n1 = float(input("Student's first grade: "))
n2 = float(input("Student's second grade: "))
m = (n1 + n2) / 2
print(f"The student's average is: {m}")
input('Enter to exit') |
def check_range_and_int(val, name, low=0, high=127):
"""Checks a parameter to match Loihi
Calls two methods to check if the parameter value is
integer and in a range between low and high.
Parameters
----------
val : int
The value of the parameter
name : str
The name of the ... | def check_range_and_int(val, name, low=0, high=127):
"""Checks a parameter to match Loihi
Calls two methods to check if the parameter value is
integer and in a range between low and high.
Parameters
----------
val : int
The value of the parameter
name : str
The name of the ... |
#!/usr/bin/env python
"""
__init__
Tests for creating
daemons.
"""
| """
__init__
Tests for creating
daemons.
""" |
"""Given the head of a linked list and a value x, partition it such that all nodes less than x come before nodes greater
than or equal to x. You should preserve the original relative order of the nodes in each of the two partitions.
Example 1:
Input: head = [1,4,3,2,5,2], x = 3
Output: [1,2,2,4,3,5]
Example 2:
Input:... | """Given the head of a linked list and a value x, partition it such that all nodes less than x come before nodes greater
than or equal to x. You should preserve the original relative order of the nodes in each of the two partitions.
Example 1:
Input: head = [1,4,3,2,5,2], x = 3
Output: [1,2,2,4,3,5]
Example 2:
Input:... |
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""TODO: Add v_r for pinch velocity"""
def calc_vr_pinch():
vr_pinch = 0 # TODO: Add the equation for vr_pinch
return vr_pinch
| """TODO: Add v_r for pinch velocity"""
def calc_vr_pinch():
vr_pinch = 0
return vr_pinch |
class Solution:
def get_balls(self, arr):
def dfs(i, j, r, c):
if(i == r):
return j
curr = arr[i][j]
if(curr == 1 and (j+1 == c or arr[i][j+1] == -1)):
return -1
elif(curr == -1) and (j-1<0 or arr[i][j-1] == 1):
... | class Solution:
def get_balls(self, arr):
def dfs(i, j, r, c):
if i == r:
return j
curr = arr[i][j]
if curr == 1 and (j + 1 == c or arr[i][j + 1] == -1):
return -1
elif curr == -1 and (j - 1 < 0 or arr[i][j - 1] == 1):
... |
pkgname = "libxrandr"
pkgver = "1.5.2"
pkgrel = 0
build_style = "gnu_configure"
configure_args = ["--enable-malloc0returnsnull"]
hostmakedepends = ["pkgconf"]
makedepends = ["xorgproto", "libxext-devel", "libxrender-devel"]
pkgdesc = "X RandR Library from X.org"
maintainer = "q66 <q66@chimera-linux.org>"
license = "MIT... | pkgname = 'libxrandr'
pkgver = '1.5.2'
pkgrel = 0
build_style = 'gnu_configure'
configure_args = ['--enable-malloc0returnsnull']
hostmakedepends = ['pkgconf']
makedepends = ['xorgproto', 'libxext-devel', 'libxrender-devel']
pkgdesc = 'X RandR Library from X.org'
maintainer = 'q66 <q66@chimera-linux.org>'
license = 'MIT... |
class Solution:
def numSimilarGroups(self, A):
def explore(s):
visited.add(s)
for v in edges[s]:
if v not in visited: explore(v)
res, edges, visited = 0, {}, set()
if len(A) >= 2 * len(A[0]):
strs = set(A)
for s in A:
... | class Solution:
def num_similar_groups(self, A):
def explore(s):
visited.add(s)
for v in edges[s]:
if v not in visited:
explore(v)
(res, edges, visited) = (0, {}, set())
if len(A) >= 2 * len(A[0]):
strs = set(A)
... |
class Restaurant():
def __init__(self,name,type):
self.restaurant_name = name
self.cuisine_type = type
def describe_restaurant(self):
print("Nombre: ", self.restaurant_name)
print("Tipo de cocina: ", self.cuisine_type)
def open_restaurant(self):
print("That ... | class Restaurant:
def __init__(self, name, type):
self.restaurant_name = name
self.cuisine_type = type
def describe_restaurant(self):
print('Nombre: ', self.restaurant_name)
print('Tipo de cocina: ', self.cuisine_type)
def open_restaurant(self):
print('That the res... |
N, Q = map(int,input().split())
A = [0] + list(map(int,input().split()))
# print(N, Q)
# print(A)
# print("----")
for i in range(Q):
t, x, y = map(int,input().split())
if t == 1:
A[x] = A[x] ^ y
if t == 2:
xor_list = A[x:-1] + [y]
for j in range(len(xor_list)-1):
res = ... | (n, q) = map(int, input().split())
a = [0] + list(map(int, input().split()))
for i in range(Q):
(t, x, y) = map(int, input().split())
if t == 1:
A[x] = A[x] ^ y
if t == 2:
xor_list = A[x:-1] + [y]
for j in range(len(xor_list) - 1):
res = xor_list[j] ^ xor_list[j + 1]
... |
"""
RENDER
"""
render_camera = 'cam1'
render_lights = ''
"""
MATERIAL
"""
mat = 'constant1'
mat_color = ''
"""
INSTANCES
"""
inst_state = 0
| """
RENDER
"""
render_camera = 'cam1'
render_lights = ''
'\nMATERIAL\n'
mat = 'constant1'
mat_color = ''
'\nINSTANCES\n'
inst_state = 0 |
def validate_x(w: int, x: int, r: int) -> bool:
if r <= x <= w - r:
return True
return False
def validate_y(h: int, y: int, r: int) -> bool:
if r <= y <= h - r:
return True
return False
def resolve():
w, h, x, y, r = map(int, input().split())
if validate_x(w, x, r) and valid... | def validate_x(w: int, x: int, r: int) -> bool:
if r <= x <= w - r:
return True
return False
def validate_y(h: int, y: int, r: int) -> bool:
if r <= y <= h - r:
return True
return False
def resolve():
(w, h, x, y, r) = map(int, input().split())
if validate_x(w, x, r) and valida... |
def swap_bits(num, i, j):
if (num>>i & 1) != (num>>j & 1):
num ^= ((1<<i) | (1<<j))
return num
num = 129
for x in range(num, num+10):
print(bin(x), bin(swap_bits(x, 1, 2)))
| def swap_bits(num, i, j):
if num >> i & 1 != num >> j & 1:
num ^= 1 << i | 1 << j
return num
num = 129
for x in range(num, num + 10):
print(bin(x), bin(swap_bits(x, 1, 2))) |
# -*- coding: utf-8 -*-
INPUT_PATH = "../data/data_reduced.json"
OUTPUT_PATH = "../data/recommendations.json"
NUM_RECS = 5 | input_path = '../data/data_reduced.json'
output_path = '../data/recommendations.json'
num_recs = 5 |
#!/bin/python3
"""
Task:
Write a program that asks the user for their name and greets them with their name.
"""
nameBuffer=input("State your name: ")
print(f"Greetings {nameBuffer}") | """
Task:
Write a program that asks the user for their name and greets them with their name.
"""
name_buffer = input('State your name: ')
print(f'Greetings {nameBuffer}') |
# Done by Carlos Amaral (2020/09/19)
taxi_ride_info = ["da7a62fce04", 180, 1.1, True]
print("The data type for the taxi_ride_info variable is: ", type(taxi_ride_info))
print("The data type for the first element of taxi_ride_info is: ", type(taxi_ride_info[0]))
print("The data type for the second element of taxi_rid... | taxi_ride_info = ['da7a62fce04', 180, 1.1, True]
print('The data type for the taxi_ride_info variable is: ', type(taxi_ride_info))
print('The data type for the first element of taxi_ride_info is: ', type(taxi_ride_info[0]))
print('The data type for the second element of taxi_ride_info is: ', type(taxi_ride_info[1]))
pr... |
class Solution:
def sumNumbers(self, root ):
self.result = 0
self.preOrder(root,0)
return self.result
def preOrder(self,root,tmp):
if not root:
return
if not root.left and not root.right:
# sum here
self.result += tmp*10 + root.val
... | class Solution:
def sum_numbers(self, root):
self.result = 0
self.preOrder(root, 0)
return self.result
def pre_order(self, root, tmp):
if not root:
return
if not root.left and (not root.right):
self.result += tmp * 10 + root.val
retur... |
problemDescription = '''
*problemDescription* \n
This problem was asked by Square.
You are given a histogram consisting of rectangles of different heights.
These heights are represented in an input list, such that [1, 3, 2, 5]
corresponds to the following diagram:
x
x
x x
x x x
x x x x
Determine ... | problem_description = '\n*problemDescription* \n\nThis problem was asked by Square.\n\nYou are given a histogram consisting of rectangles of different heights.\nThese heights are represented in an input list, such that [1, 3, 2, 5] \ncorresponds to the following diagram:\n\n x\n x \n x x\n x x x\nx x x x... |
# -*- coding: utf-8 -*-
# Copyright 2019 Carsten Blank
#
# 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 la... | result = {'simulation': {'qobj': {'qobj_id': 'sim_product_state_2_copies_20190610T110047Z', 'config': {'shots': 8192, 'memory_slots': 2, 'max_credits': 315, 'memory': False, 'n_qubits': 7}, 'experiments': [{'instructions': [{'name': 'u3', 'params': [0.0, -1.5707963267948966, 1.5707963267948966], 'texparams': ['0.0', '-... |
class Solution:
def tribonacci(self, n: int) -> int:
if n == 0 or n == 1:
return n
t0, t1, t2 = 0, 1, 1
for i in range(n - 2):
t2, t1, t0 = t2 + t1 + t0, t2, t1
return t2
| class Solution:
def tribonacci(self, n: int) -> int:
if n == 0 or n == 1:
return n
(t0, t1, t2) = (0, 1, 1)
for i in range(n - 2):
(t2, t1, t0) = (t2 + t1 + t0, t2, t1)
return t2 |
# -*- coding: utf-8 -*-
"""
Supply
Generic Supply functionality such as catalogs and items that are used across multiple applications
"""
module = request.controller
resourcename = request.function
if not (deployment_settings.has_module("inv") or deployment_settings.has_module("asset")):
raise HTTP(404,... | """
Supply
Generic Supply functionality such as catalogs and items that are used across multiple applications
"""
module = request.controller
resourcename = request.function
if not (deployment_settings.has_module('inv') or deployment_settings.has_module('asset')):
raise http(404, body='Module disabled: %s'... |
# -*- coding: utf-8 -*-
'''
This module is obsolete.
'''
PLUGS = [
("caps", "http://nsap.intra.cea.fr/caps-doc/"),
("qmri", "https://bioproj.extra.cea.fr/redmine/projects/qmri/publishing/"),
("funtk", "https://bioproj.extra.cea.fr/redmine/projects/funtk/publishing/"),
("pclinfmri", "")
]
| """
This module is obsolete.
"""
plugs = [('caps', 'http://nsap.intra.cea.fr/caps-doc/'), ('qmri', 'https://bioproj.extra.cea.fr/redmine/projects/qmri/publishing/'), ('funtk', 'https://bioproj.extra.cea.fr/redmine/projects/funtk/publishing/'), ('pclinfmri', '')] |
'''
Finding all maximal cliques of size "n"
Now that you've explored triangles (and open triangles), let's move on to the concept of maximal cliques. Maximal cliques are cliques that cannot be extended by adding an adjacent edge, and are a useful property of the graph when finding communities. NetworkX provides a func... | """
Finding all maximal cliques of size "n"
Now that you've explored triangles (and open triangles), let's move on to the concept of maximal cliques. Maximal cliques are cliques that cannot be extended by adding an adjacent edge, and are a useful property of the graph when finding communities. NetworkX provides a func... |
#!/usr/bin/env python3
def enb():
print("enb command line comming soon")
| def enb():
print('enb command line comming soon') |
#Given a string in which the letter h occurs at least two times,
# reverse the sequence of characters enclosed between the first and last appearances.
s = input()
i1 = s.find('h')
print(s.find('h'))
i2 = s.rfind('h')
print(s.rfind('h'))
sh = s[i1:(i2+1)]
new_s = s[:i1] + sh[::-1] + s[(i2+1):]
print(new_s) | s = input()
i1 = s.find('h')
print(s.find('h'))
i2 = s.rfind('h')
print(s.rfind('h'))
sh = s[i1:i2 + 1]
new_s = s[:i1] + sh[::-1] + s[i2 + 1:]
print(new_s) |
#!/usr/bin/env python
# BST
class Node:
def __init__(self, data):
self.left = None
self.right = None
self.data = data
def insert(self, data):
if self.data:
if data < self.data:
if self.left is None:
self.left = Node(data)
... | class Node:
def __init__(self, data):
self.left = None
self.right = None
self.data = data
def insert(self, data):
if self.data:
if data < self.data:
if self.left is None:
self.left = node(data)
else:
... |
URL = "url"
IOTA = "iota"
DOC = "document"
URL_TYPES = [URL, IOTA, DOC]
| url = 'url'
iota = 'iota'
doc = 'document'
url_types = [URL, IOTA, DOC] |
# unexpected indent
#a = 1
# + 2
# + 3
# invalid syntax
#a = 1 +
# 2 +
# 3
a = 1 + \
2 + \
3
print(a)
| a = 1 + 2 + 3
print(a) |
class DeltaCalculator:
def __init__(self):
self._values = {}
def delta(self, key, value):
last = self._values.get(key)
self._values[key] = value
if last is None:
return None
return value - last
| class Deltacalculator:
def __init__(self):
self._values = {}
def delta(self, key, value):
last = self._values.get(key)
self._values[key] = value
if last is None:
return None
return value - last |
"""
Creating the first queue. Not working right now, need to fix...
"""
SIZE = 5
REAR = -1
FRONT = -1
VALUES = []
def enQueue(value):
global FRONT
global REAR
if REAR == SIZE - 1:
print('Our Queue is full. \n')
else:
if FRONT:
FRONT = 0
REAR += 1
value = VAL... | """
Creating the first queue. Not working right now, need to fix...
"""
size = 5
rear = -1
front = -1
values = []
def en_queue(value):
global FRONT
global REAR
if REAR == SIZE - 1:
print('Our Queue is full. \n')
else:
if FRONT:
front = 0
rear += 1
value = VAL... |
# __init__.py
"""
Hi there!
"""
| """
Hi there!
""" |
def save_user(backend, user, response, *args, **kwargs) -> None:
if user and not user.is_staff:
user.is_staff = True
user.save()
| def save_user(backend, user, response, *args, **kwargs) -> None:
if user and (not user.is_staff):
user.is_staff = True
user.save() |
def snake_case_key(key: str) -> str:
assert isinstance(key, str)
new_key = key[0]
for char in key[1:]:
if char.isupper():
new_key += "_{char}".format(char=char.lower())
elif char == "-":
new_key += "__"
else:
new_key += char
return new_key
| def snake_case_key(key: str) -> str:
assert isinstance(key, str)
new_key = key[0]
for char in key[1:]:
if char.isupper():
new_key += '_{char}'.format(char=char.lower())
elif char == '-':
new_key += '__'
else:
new_key += char
return new_key |
#!/usr/bin/env python3
if __name__ == '__main__':
width = 1001
cur = 1
cur_w = 3
ans = 1
while cur_w <= width:
ans += 4 * cur + 10 * (cur_w - 1)
cur += 4 * (cur_w - 1)
cur_w += 2
print(ans)
| if __name__ == '__main__':
width = 1001
cur = 1
cur_w = 3
ans = 1
while cur_w <= width:
ans += 4 * cur + 10 * (cur_w - 1)
cur += 4 * (cur_w - 1)
cur_w += 2
print(ans) |
"""
LINK: https://leetcode.com/problems/3sum-closest/
Given an array nums of n integers and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of the three integers. You may assume that each input would have exactly one solution.
Example 1:
Input: nums = [-1,2,1,-4]... | """
LINK: https://leetcode.com/problems/3sum-closest/
Given an array nums of n integers and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of the three integers. You may assume that each input would have exactly one solution.
Example 1:
Input: nums = [-1,2,1,-4]... |
BROKER_URL = 'redis://localhost:6379/0'
CELERY_RESULT_BACKEND = 'redis://localhost:6379/0'
CELERY_IMPORTS = ("octavious.parallelizer.celery", )
CELERY_TASK_RESULT_EXPIRES = 300
| broker_url = 'redis://localhost:6379/0'
celery_result_backend = 'redis://localhost:6379/0'
celery_imports = ('octavious.parallelizer.celery',)
celery_task_result_expires = 300 |
def quick_sort(lst):
aux_quick_sort(lst, 0, len(lst) - 1)
return lst
def aux_quick_sort(lst, start, end):
if start >= end:
return
pivot_pos = partition(lst, start, end)
aux_quick_sort(lst, start, pivot_pos - 1)
aux_quick_sort(lst, pivot_pos + 1, end)
def partition(lst, start, end):
... | def quick_sort(lst):
aux_quick_sort(lst, 0, len(lst) - 1)
return lst
def aux_quick_sort(lst, start, end):
if start >= end:
return
pivot_pos = partition(lst, start, end)
aux_quick_sort(lst, start, pivot_pos - 1)
aux_quick_sort(lst, pivot_pos + 1, end)
def partition(lst, start, end):
... |
settings = {
"WIDTH": 200,
"HEIGHT": 66,
"CHANNELS": 3,
"BALANCE_MODE": 'RESAMPLE',
"DEFAULT_TRAIN_FILE_DIRECTORY": 'D:/train_data/raw/',
"DEFAULT_TRAIN_FILE": 'D:/train_data/raw/training_data_{}.npy',
"DEFAULT_TRAIN_FILE_PROCESSED_DIRECTORY": 'D:/train_data/processed/',
"DEFAULT_TRAIN_F... | settings = {'WIDTH': 200, 'HEIGHT': 66, 'CHANNELS': 3, 'BALANCE_MODE': 'RESAMPLE', 'DEFAULT_TRAIN_FILE_DIRECTORY': 'D:/train_data/raw/', 'DEFAULT_TRAIN_FILE': 'D:/train_data/raw/training_data_{}.npy', 'DEFAULT_TRAIN_FILE_PROCESSED_DIRECTORY': 'D:/train_data/processed/', 'DEFAULT_TRAIN_FILE_PROCESSED': 'D:/train_data/pr... |
# Agent Template.
#
# Copy this agent.py in your model dir (e.g. models/mymodel/agent.py)
# and implement predict(state) method to start
class Agent():
def __init__(self, **kwargs):
# initialize anything you need.
# e.g. load pre-trained model
pass
def predict(self, state):
# ... | class Agent:
def __init__(self, **kwargs):
pass
def predict(self, state):
action = 1
return action |
# The famous Hello, world! problem written in python.
# Author: Adrian Sypos
# Date: 21/09/2017
print("Hello, world!") | print('Hello, world!') |
def myPow(self,x,n):
if n<0:
x=1/x
n=-n
pow=1
while n:
if n&1:
pow*=x
x*=x
n>>=1
return pow
def myPow2(self,x,n):
if not n:
return 1
if n<0:
return 1/self.myPow2(x,-n)
if n%2:
return x*self.myPow2(... | def my_pow(self, x, n):
if n < 0:
x = 1 / x
n = -n
pow = 1
while n:
if n & 1:
pow *= x
x *= x
n >>= 1
return pow
def my_pow2(self, x, n):
if not n:
return 1
if n < 0:
return 1 / self.myPow2(x, -n)
if n % 2:
return x... |
def is_palindrome(string):
# base case: the string is less than 1 character
if len(string) <= 1:
return True
if string[0] == string[-1]:
return is_palindrome(string[1:-1])
return False
""" print(f"kayak : {is_palindrome("kayak")}")
print(f"empty string : {is_palindrome(""... | def is_palindrome(string):
if len(string) <= 1:
return True
if string[0] == string[-1]:
return is_palindrome(string[1:-1])
return False
' print(f"kayak : {is_palindrome("kayak")}")\nprint(f"empty string : {is_palindrome("")}")\nprint(f"a : {is_palindrome("a")}")\nprint(f"alessandra : {is_pal... |
#
# PySNMP MIB module COLUBRIS-VIRTUAL-AP-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/COLUBRIS-VIRTUAL-AP-MIB
# Produced by pysmi-0.3.4 at Wed May 1 12:25:40 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 ... | (object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_union, value_size_constraint, single_value_constraint, constraints_intersection, value_range_constraint) ... |
def can_build(env, platform):
return env["tools"]
def configure(env):
pass
def get_doc_path():
return "doc_classes"
def get_doc_classes():
return [
"VGColor",
"VGGradient",
"VGLinearGradient",
"VGMeshRenderer",
"VGPaint",
"VGPath",
"VGRadialG... | def can_build(env, platform):
return env['tools']
def configure(env):
pass
def get_doc_path():
return 'doc_classes'
def get_doc_classes():
return ['VGColor', 'VGGradient', 'VGLinearGradient', 'VGMeshRenderer', 'VGPaint', 'VGPath', 'VGRadialGradient', 'VGRenderer', 'EditorSceneImporterSVG'] |
def can_partition(num):
s = sum(num)
if s % 2 != 0: # if 's' is a an odd number, we can't have two subsets with same total
return False
s = int(s / 2) # we are trying to find a subset of given numbers that has a total sum of 's/2'.
n = len(num)
dp = [[False for x in range(s + 1)] for y in... | def can_partition(num):
s = sum(num)
if s % 2 != 0:
return False
s = int(s / 2)
n = len(num)
dp = [[False for x in range(s + 1)] for y in range(n)]
for i in range(0, n):
dp[i][0] = True
for j in range(1, s + 1):
dp[0][j] = num[0] == j
for i in range(1, n):
... |
text = input("Enter text: ")
count = 0
for char in text:
if char == "a":
count +=1
if char == "e":
count += 2
if char == "i":
count += 3
if char == "o":
count += 4
if char == "u":
count += 5
print(count) | text = input('Enter text: ')
count = 0
for char in text:
if char == 'a':
count += 1
if char == 'e':
count += 2
if char == 'i':
count += 3
if char == 'o':
count += 4
if char == 'u':
count += 5
print(count) |
'''
Author : MiKueen
Level : Easy
Problem Statement : Happy Number
Write an algorithm to determine if a number n is "happy".
A happy number is a number defined by the following process: Starting with any positive integer,
replace the number by the sum of the squares of its digits, and repeat the process until the num... | """
Author : MiKueen
Level : Easy
Problem Statement : Happy Number
Write an algorithm to determine if a number n is "happy".
A happy number is a number defined by the following process: Starting with any positive integer,
replace the number by the sum of the squares of its digits, and repeat the process until the num... |
""" Dummy tests
"""
def test_pass():
"""Test nothing at all (well, "pass" anyway)."""
pass
def test_true():
"""Test True."""
assert True
| """ Dummy tests
"""
def test_pass():
"""Test nothing at all (well, "pass" anyway)."""
pass
def test_true():
"""Test True."""
assert True |
# Maximum Subarray: https://leetcode.com/problems/maximum-subarray/
# Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.
# A subarray is a contiguous part of an array.
# This problem is actually kind of like a dynamic programming pr... | class Solution:
def max_sub_array(self, nums) -> int:
result = nums[0]
cur_sum = nums[0]
for i in range(1, len(nums)):
cur_sum = max(curSum + nums[i], nums[i])
result = max(curSum, result)
return result |
x = float(input())
if x <= 400.00:
s = x * 1.15
r = s - x
p = 15
if 400.01 <= x <= 800.00:
s = x * 1.12
r = s - x
p = 12
if 800.01 <= x <= 1200.00:
s = x * 1.10
r = s - x
p = 10
if 1200.01 <= x <= 2000.00:
s = x * 1.07
r = s - x
p = 7
if x > 2000.00:
s = x * 1.04
... | x = float(input())
if x <= 400.0:
s = x * 1.15
r = s - x
p = 15
if 400.01 <= x <= 800.0:
s = x * 1.12
r = s - x
p = 12
if 800.01 <= x <= 1200.0:
s = x * 1.1
r = s - x
p = 10
if 1200.01 <= x <= 2000.0:
s = x * 1.07
r = s - x
p = 7
if x > 2000.0:
s = x * 1.04
r = s ... |
for k in range(int(input())):
D1 = input()
D2, D3, D4, D5 = tuple(input().split())
D6 = input()
probs = 0
if D1 == '*' and D6 == '*': probs += 1
if D2 == '*' and D4 == '*': probs += 1
if D3 == '*' and D5 == '*': probs += 1
print(48 if probs == 3 else 8 if probs == 2 else 2 if probs ==... | for k in range(int(input())):
d1 = input()
(d2, d3, d4, d5) = tuple(input().split())
d6 = input()
probs = 0
if D1 == '*' and D6 == '*':
probs += 1
if D2 == '*' and D4 == '*':
probs += 1
if D3 == '*' and D5 == '*':
probs += 1
print(48 if probs == 3 else 8 if probs ... |
patches = [
# Remove attribute property EventIntegrationAssociation and Metadata
{
"op": "remove",
"path": "/PropertyTypes/AWS::AppIntegrations::EventIntegration.EventIntegrationAssociation",
},
{
"op": "remove",
"path": "/PropertyTypes/AWS::AppIntegrations::EventIntegrat... | patches = [{'op': 'remove', 'path': '/PropertyTypes/AWS::AppIntegrations::EventIntegration.EventIntegrationAssociation'}, {'op': 'remove', 'path': '/PropertyTypes/AWS::AppIntegrations::EventIntegration.Metadata'}] |
class TwoPointers(object):
def removeElement(self, nums, val):
"""
:type nums: List[int]
:type val: int
:rtype: int
"""
#initialize count
count = 0
#loop in range of length of list nums
for i in range(len(nums)):
#if element at inde... | class Twopointers(object):
def remove_element(self, nums, val):
"""
:type nums: List[int]
:type val: int
:rtype: int
"""
count = 0
for i in range(len(nums)):
if nums[i] != val:
nums[count] = nums[i]
count += 1
... |
print ('\033[35m Bem vindo a calculadora do Luis \n')
n1 = int(input('\033[33m Digite um valor: '))
n2 = int(input('\033[34m Digite outro numero: '))
s = n1 + n2
#print('A soma vale:',s)
#print ('A soma entre ',n1,'e ',n2,' eh ',s)
print ('\033[31m A soma entre {} e {} vale {}'.format(n1,n2,s)) | print('\x1b[35m Bem vindo a calculadora do Luis \n')
n1 = int(input('\x1b[33m Digite um valor: '))
n2 = int(input('\x1b[34m Digite outro numero: '))
s = n1 + n2
print('\x1b[31m A soma entre {} e {} vale {}'.format(n1, n2, s)) |
def sum():
result = 21 + 14
print("Inside the function : ", result)
return result
total = sum()
print("Outside the function : ", total )
def print_info( name, age = 35 ):
print("Name: ", name)
print("Age ", age)
return
print_info( age=50, name="miki" )
print_info( name="miki" ) | def sum():
result = 21 + 14
print('Inside the function : ', result)
return result
total = sum()
print('Outside the function : ', total)
def print_info(name, age=35):
print('Name: ', name)
print('Age ', age)
return
print_info(age=50, name='miki')
print_info(name='miki') |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.