content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
class Node:
def __init__(self, data) -> None:
self.data = data
self.left = None
self.right = None
def levelOrderTraversal(root):
if root is None:
return
queue = []
queue.append(root)
while len(queue) > 0:
print(queue[0].data)
node = q... | class Node:
def __init__(self, data) -> None:
self.data = data
self.left = None
self.right = None
def level_order_traversal(root):
if root is None:
return
queue = []
queue.append(root)
while len(queue) > 0:
print(queue[0].data)
node = queue.pop(0)
... |
def toTwoComp(n):
s = bin(n & int("1"*16, 2))[2:]
return ("{0:0>%s}" % (16)).format(s)
def fromTwoComp(n):
temp = n[:1]
num = ""
if int(temp):
for x in n[1:]:
if x == "1":
num = num + "0"
else:
num = num + "1"
... | def to_two_comp(n):
s = bin(n & int('1' * 16, 2))[2:]
return ('{0:0>%s}' % 16).format(s)
def from_two_comp(n):
temp = n[:1]
num = ''
if int(temp):
for x in n[1:]:
if x == '1':
num = num + '0'
else:
num = num + '1'
return -int(n... |
_.subdomain_matching
_.static_folder
Meta
csrf
csrf_class
csrf_secret
csrf_time_limit
confirm
get_user
_.user
catch_all
bad_gateway
page_not_found
| _.subdomain_matching
_.static_folder
Meta
csrf
csrf_class
csrf_secret
csrf_time_limit
confirm
get_user
_.user
catch_all
bad_gateway
page_not_found |
l1 = ["Bhindi","Aloo","Chopsticks","Chowmein"]
i = 1
# for item in l1:
# if i%2 != 0:
# print(f"Please buy {item}")
# i+=1
for index,item in enumerate(l1):
if index%2==0: # even 0 se start
print(f"Please buy {item}")
| l1 = ['Bhindi', 'Aloo', 'Chopsticks', 'Chowmein']
i = 1
for (index, item) in enumerate(l1):
if index % 2 == 0:
print(f'Please buy {item}') |
{
"targets": [
{
"target_name": "trusted",
"dependencies": [
"deps/wrapper/wrapper.gyp:wrapper",
],
"sources": [
"src/node/main.cpp",
"src/node/helper.cpp",
"src/node/stdafx.cpp",
... | {'targets': [{'target_name': 'trusted', 'dependencies': ['deps/wrapper/wrapper.gyp:wrapper'], 'sources': ['src/node/main.cpp', 'src/node/helper.cpp', 'src/node/stdafx.cpp', 'src/node/common/wopenssl.cpp', 'src/node/utils/wlog.cpp', 'src/node/utils/wrap.cpp', 'src/node/utils/wjwt.cpp', 'src/node/utils/wcsp.cpp', 'src/no... |
'''
urlycue's private modules
'''
type(1 or 0 @ 0) # Python >= 3.5 is required
| """
urlycue's private modules
"""
type(1 or 0 @ 0) |
with open ("testcopy.txt", "r") as test_copy:
chunk_size = 10
read_data = test_copy.read(chunk_size)
while len(read_data) > 0:
print(read_data)
read_data = test_copy.read (chunk_size) | with open('testcopy.txt', 'r') as test_copy:
chunk_size = 10
read_data = test_copy.read(chunk_size)
while len(read_data) > 0:
print(read_data)
read_data = test_copy.read(chunk_size) |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Author: Dusan Klinec, ph4r05, 2018
def collect(*args, **kwargs):
pass
def mem_free(*args, **kwargs):
return 1000
def mem_alloc(*args, **kwargs):
return 100
| def collect(*args, **kwargs):
pass
def mem_free(*args, **kwargs):
return 1000
def mem_alloc(*args, **kwargs):
return 100 |
def part01(input, slope_right, slope_down):
total = 0
pos = 0
for i in range(0, len(input), slope_down):
if input[i][pos] == "#":
total += 1
pos = (pos + slope_right) % len(input[i])
return total
def part02(input):
return part01(input, 1, 1) * part01(input, 3, 1) * part0... | def part01(input, slope_right, slope_down):
total = 0
pos = 0
for i in range(0, len(input), slope_down):
if input[i][pos] == '#':
total += 1
pos = (pos + slope_right) % len(input[i])
return total
def part02(input):
return part01(input, 1, 1) * part01(input, 3, 1) * part0... |
def meme1():
return str(
bytes(
list(
map(
lambda i: i + 48,
[
int("49"),
int("3c", 16),
int("60"),
int(str(-16)),
int("... | def meme1():
return str(bytes(list(map(lambda i: i + 48, [int('49'), int('3c', 16), int('60'), int(str(-16)), int('38', 16), int('41', 12), int('1l', 36), int('2020', 3), int('-100', 4), int('30', 21), int('1o', 26), int('3h', 18), int('2j', 25), int('29', 31), int(str(63), int('1011', 2))]))), ''.join(map(lambda c... |
def is_valid(input_line: str) -> bool:
min_max, pass_char, password = input_line.split(' ')
min_count, max_count = [int(i) for i in min_max.split('-')]
pass_char = pass_char.rstrip(':')
min_valid = (password[min_count-1] == pass_char)
max_valid = (password[max_count-1] == pass_char)
ret_val =... | def is_valid(input_line: str) -> bool:
(min_max, pass_char, password) = input_line.split(' ')
(min_count, max_count) = [int(i) for i in min_max.split('-')]
pass_char = pass_char.rstrip(':')
min_valid = password[min_count - 1] == pass_char
max_valid = password[max_count - 1] == pass_char
ret_val ... |
X = 'spam'
Y = 'eggs'
# will swap
X, Y = Y, X
print((X, Y)) | x = 'spam'
y = 'eggs'
(x, y) = (Y, X)
print((X, Y)) |
fout=open('oops.txt','wt')
print('oops, i created a file',file=fout)
fout.close()
fin=open('oops.txt','rt')
po=fin.read()
fin.close()
print(po) | fout = open('oops.txt', 'wt')
print('oops, i created a file', file=fout)
fout.close()
fin = open('oops.txt', 'rt')
po = fin.read()
fin.close()
print(po) |
# Curbrock Summon 3
CURBROCK3 = 9400931 # MOD ID
CURBROCKS_ESCAPE_ROUTE_VER3 = 600050050 # MAP ID
sm.spawnMob(CURBROCK3, 320, -208, False)
sm.createClock(1800)
sm.addEvent(sm.invokeAfterDelay(1800000, "warp", CURBROCKS_ESCAPE_ROUTE_VER3, 0))
sm.waitForMobDeath(CURBROCK3)
sm.warp(CURBROCKS_ESCAPE_ROUTE_VER3)
sm.stopEv... | curbrock3 = 9400931
curbrocks_escape_route_ver3 = 600050050
sm.spawnMob(CURBROCK3, 320, -208, False)
sm.createClock(1800)
sm.addEvent(sm.invokeAfterDelay(1800000, 'warp', CURBROCKS_ESCAPE_ROUTE_VER3, 0))
sm.waitForMobDeath(CURBROCK3)
sm.warp(CURBROCKS_ESCAPE_ROUTE_VER3)
sm.stopEvents() |
#! /usr/bin/python
class Calculator(object):
def add(self, operanda, operandb):
return operanda + operandb
| class Calculator(object):
def add(self, operanda, operandb):
return operanda + operandb |
#!/usr/bin/python3
def print_matrix_integer(matrix=[[]]):
for X in matrix:
for Y in X:
print('{:d}'.format(Y), end="")
if Y != X[-1]:
print(' ', end="")
print()
| def print_matrix_integer(matrix=[[]]):
for x in matrix:
for y in X:
print('{:d}'.format(Y), end='')
if Y != X[-1]:
print(' ', end='')
print() |
#!/usr/bin/env python3
bday_dict = {}
while True:
name = input("\nEnter name: ")
if len(name) != 0 and type(name) == str:
# Check the existence of the name in bday_dict
if bday_dict.get(name):
print("\n{} found in db".format(name))
print("Name: {}".format(name))
... | bday_dict = {}
while True:
name = input('\nEnter name: ')
if len(name) != 0 and type(name) == str:
if bday_dict.get(name):
print('\n{} found in db'.format(name))
print('Name: {}'.format(name))
print('Date : {}\n'.format(bday_dict[name]))
else:
pri... |
N=int(input())
A=list(map(int,input().split()))
diff=0
ans=N
for i in range(N-1):
if A[i]<A[i+1]:
diff+=1
ans+=diff
else:
diff=0
print(ans) | n = int(input())
a = list(map(int, input().split()))
diff = 0
ans = N
for i in range(N - 1):
if A[i] < A[i + 1]:
diff += 1
ans += diff
else:
diff = 0
print(ans) |
inFile = open('input.txt')
primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37,
41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]
for line in inFile:
n = int(line)
if n == 0:
break
lenPrime = len(primes)
counter = [0] * lenPrime
for i in range(1, n + 1):
number = i
... | in_file = open('input.txt')
primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]
for line in inFile:
n = int(line)
if n == 0:
break
len_prime = len(primes)
counter = [0] * lenPrime
for i in range(1, n + 1):
number = i
for (... |
structure = {
'Public_encryption': 'public Alice key for encoding',
'Public_signing': 'public Alice key for signing',
'Message':
{'message_id_hash': #message_id_5383710b780583f1f462b6e719071523147cde25a5a47c380126c3395f84b9b3
{'Address': address, #e6jB08WPeBjoPS4Lb4CFRVW/TAWSrGq7MD5OG8NVA794z4GwhlXz7vov1i2w6GLWY... | structure = {'Public_encryption': 'public Alice key for encoding', 'Public_signing': 'public Alice key for signing', 'Message': {'message_id_hash': {'Address': address, 'Files': ['Qm...', 'Qm...', 'Qm...']}}, 'Points': []} |
# We are dealing with the "Young's Double Slit Experiment" simulation here:
# https://github.com/NSLS-II/sirepo-bluesky/blob/master/sirepo_bluesky/tests/SIREPO_SRDB_ROOT/user/SdP3aU5G/srw/00000000/sirepo-data.json
RE(
optimization_plan(
fly_plan=run_fly_sim,
bounds=param_bounds,
db=db,
... | re(optimization_plan(fly_plan=run_fly_sim, bounds=param_bounds, db=db, run_parallel=True, num_interm_vals=1, num_scans_at_once=4, sim_id='00000000', server_name='http://localhost:8000', root_dir=root_dir, watch_name='W60', flyer_name='sirepo_flyer', intensity_name='mean', opt_type='sirepo', max_iter=5)) |
'''class Pessoa(object):
def __init__(self, nome, idade, peso):
self.nome = nome
self.idade = idade
self.peso = peso
def andar(self):
print('anda')
pessoa1 = Pessoa("Juliana", 23, 75)
pessoa2 = Pessoa("Carlos", 39, 72)
print(pessoa1.nome)
pessoa1.andar()
def fatorial(n):
i... | """class Pessoa(object):
def __init__(self, nome, idade, peso):
self.nome = nome
self.idade = idade
self.peso = peso
def andar(self):
print('anda')
pessoa1 = Pessoa("Juliana", 23, 75)
pessoa2 = Pessoa("Carlos", 39, 72)
print(pessoa1.nome)
pessoa1.andar()
def fatorial(n):
i... |
{
"targets": [
{
"target_name": "addon",
"sources": ["./src/cpp/nodeBridge.cpp", "./src/cpp/os/windows.cpp"],
"include_dirs": [
"<!@(node -p \"require('node-addon-api').include\")"
],
'defines': [ 'NAPI_CPP_EXCEPTIONS' ]
}
... | {'targets': [{'target_name': 'addon', 'sources': ['./src/cpp/nodeBridge.cpp', './src/cpp/os/windows.cpp'], 'include_dirs': ['<!@(node -p "require(\'node-addon-api\').include")'], 'defines': ['NAPI_CPP_EXCEPTIONS']}]} |
expected_output = {'interface':
{'Eth5/48.106':
{'interface_status': 'protocol-down/link-down/admin-up',
'ip_address': '10.81.6.1'},
'Lo3':
{'interface_status': ... | expected_output = {'interface': {'Eth5/48.106': {'interface_status': 'protocol-down/link-down/admin-up', 'ip_address': '10.81.6.1'}, 'Lo3': {'interface_status': 'protocol-up/link-up/admin-up', 'ip_address': '192.168.205.1'}, 'Po1.102': {'interface_status': 'protocol-up/link-up/admin-up', 'ip_address': '192.168.70.2'}, ... |
#!/usr/bin/env python3
grid = {}
def sum_neighboors(x, y):
sum = 0
for i in range(-1, 2):
for k in range(-1, 2):
sum = sum + grid.get((x + i, y + k), 0)
return sum
def print_grid(grid):
print("---")
for i in range(-10, 10):
for k in range(-10, 10):
print(... | grid = {}
def sum_neighboors(x, y):
sum = 0
for i in range(-1, 2):
for k in range(-1, 2):
sum = sum + grid.get((x + i, y + k), 0)
return sum
def print_grid(grid):
print('---')
for i in range(-10, 10):
for k in range(-10, 10):
print(grid.get((i, k), 0), end='... |
#!/usr/bin/env python3
ipchk = "192.168.0.1"
# a string tests as True
if ipchk:
print("Looks like the IP address was set: " + ipchk)
| ipchk = '192.168.0.1'
if ipchk:
print('Looks like the IP address was set: ' + ipchk) |
class BloxplorerException(Exception):
def __init__(self, message, resource_url, request_method):
self.message = message
self.resource_url = resource_url
self.request_method = request_method
def __str__(self):
return f'{self.message} (URL: {self.resource_url}, Method: {self.requ... | class Bloxplorerexception(Exception):
def __init__(self, message, resource_url, request_method):
self.message = message
self.resource_url = resource_url
self.request_method = request_method
def __str__(self):
return f'{self.message} (URL: {self.resource_url}, Method: {self.requ... |
__author__ = 'Managed by Q, Inc.',
__author_email__ = 'open-source@managedbyq.com'
__description__ = 'MBQ Atomiq'
__license__ = 'Apache 2.0'
__title__ = 'mbq.atomiq'
__url__ = 'https://github.com/managedbyq/mbq.atomiq'
__version__ = '1.1.0'
| __author__ = ('Managed by Q, Inc.',)
__author_email__ = 'open-source@managedbyq.com'
__description__ = 'MBQ Atomiq'
__license__ = 'Apache 2.0'
__title__ = 'mbq.atomiq'
__url__ = 'https://github.com/managedbyq/mbq.atomiq'
__version__ = '1.1.0' |
# -*- coding: utf-8 -*-
__author__ = "Thomas Bianchi"
__copyright__ = "Thomas Bianchi"
__license__ = "mit"
| __author__ = 'Thomas Bianchi'
__copyright__ = 'Thomas Bianchi'
__license__ = 'mit' |
num1=int(input("enter a num"))
num2=int(input("enter a num"))
if num1<0 and num2<0:
print("enter a positive number")
else:
sum=0
while(num1>0 and num2>0):
sum = num1+num2
print("the sum is",sum)
break
| num1 = int(input('enter a num'))
num2 = int(input('enter a num'))
if num1 < 0 and num2 < 0:
print('enter a positive number')
else:
sum = 0
while num1 > 0 and num2 > 0:
sum = num1 + num2
print('the sum is', sum)
break |
def counting_sort(A, B, k):
C = [0 for i in range(0, k+1)]
for j in A:
C[j] += 1
for i in range(1, k+1):
C[i] += C[i-1]
for n in reversed(A):
B[C[n]-1] = n
C[n] = C[n] - 1
return B
if __name__ == "__main__":
myList = [4,0,3,6,1,5,7,0,4]
otherList = [0 for i in range(0, len(myList))]
pri... | def counting_sort(A, B, k):
c = [0 for i in range(0, k + 1)]
for j in A:
C[j] += 1
for i in range(1, k + 1):
C[i] += C[i - 1]
for n in reversed(A):
B[C[n] - 1] = n
C[n] = C[n] - 1
return B
if __name__ == '__main__':
my_list = [4, 0, 3, 6, 1, 5, 7, 0, 4]
other_... |
class APP:
APPLICATION = "denon-commander"
AUTHOR = "Aleksander Psuj"
VERSION = "V1.0"
class CONNECTION:
# I recommend to set static IP address on device
IP = "192.168.1.150"
class DEFAULT:
# Default volume from -80 to 18
VOLUME = "-40"
# Default input
INPUT = "GAME"
... | class App:
application = 'denon-commander'
author = 'Aleksander Psuj'
version = 'V1.0'
class Connection:
ip = '192.168.1.150'
class Default:
volume = '-40'
input = 'GAME'
sound_mode = 'MCH STEREO' |
def longestSubsequence(A, N):
L = [1]*N
hm = {}
for i in range(1,N):
if abs(A[i]-A[i-1]) == 1:
L[i] = 1 + L[i-1]
elif hm.get(A[i]+1,0) or hm.get(A[i]-1,0):
L[i] = 1+max(hm.get(A[i]+1,0), hm.get(A[i]-1,0))
hm[A[i]] = L[i]
return max(L)
A = [1, 2, 3, 4, 5, 3, 2]
N = len(A)
print(longestSubsequence(A, N))
| def longest_subsequence(A, N):
l = [1] * N
hm = {}
for i in range(1, N):
if abs(A[i] - A[i - 1]) == 1:
L[i] = 1 + L[i - 1]
elif hm.get(A[i] + 1, 0) or hm.get(A[i] - 1, 0):
L[i] = 1 + max(hm.get(A[i] + 1, 0), hm.get(A[i] - 1, 0))
hm[A[i]] = L[i]
return max(... |
#reversing a string using loop
s = ('Python is the best programming language')
reversed_string = ''
for i in range(len(s)-1, -1, -1):
reversed_string += s[i]
print("reversed string: ", reversed_string)
exit()
#The range() function has two sets of parameters, as follows:
#range(stop)
#stop: Number of integer... | s = 'Python is the best programming language'
reversed_string = ''
for i in range(len(s) - 1, -1, -1):
reversed_string += s[i]
print('reversed string: ', reversed_string)
exit() |
# math3d_side.py
class Side:
NEITHER = 'NEITHER'
BACK = 'BACK'
FRONT = 'FRONT' | class Side:
neither = 'NEITHER'
back = 'BACK'
front = 'FRONT' |
first_space = int(input())
end_space = int(input())
magic_num = int(input())
combinations = 0
is_found = False
for a in range(first_space, end_space + 1):
for b in range(first_space, end_space + 1):
combinations +=1
if a + b == magic_num:
print(f'Combination N:{combinations} ({a} + {b} =... | first_space = int(input())
end_space = int(input())
magic_num = int(input())
combinations = 0
is_found = False
for a in range(first_space, end_space + 1):
for b in range(first_space, end_space + 1):
combinations += 1
if a + b == magic_num:
print(f'Combination N:{combinations} ({a} + {b} ... |
#!/bin/python
PrimerTypes = ["ForwardPrimer", "ReversePrimer"]
FastaRegionPrefix = "REGION_"
ClustalCommand = "clustalo"
| primer_types = ['ForwardPrimer', 'ReversePrimer']
fasta_region_prefix = 'REGION_'
clustal_command = 'clustalo' |
# Read two integer numbers and, after that, exchange their values. Print the variable values before and after the exchange, as shown below:
a = int(input())
b = int(input())
print(f'Before:\na = {a}\nb = {b}')
a, b = b, a
print(f'After:\na = {a}\nb = {b}')
| a = int(input())
b = int(input())
print(f'Before:\na = {a}\nb = {b}')
(a, b) = (b, a)
print(f'After:\na = {a}\nb = {b}') |
IDENTITY = lambda a: a
IF = IDENTITY
# boolean values
TRUE = lambda a: lambda b: a
FALSE = lambda a: lambda b: b
# base boolean operations
OR = lambda a: lambda b: a(TRUE)(b)
AND = lambda a: lambda b: a(b)(FALSE)
NOT = lambda a: a(FALSE)(TRUE)
# additional boolean operations
XOR = lambda a: lambda b: a(b(FALSE)(T... | identity = lambda a: a
if = IDENTITY
true = lambda a: lambda b: a
false = lambda a: lambda b: b
or = lambda a: lambda b: a(TRUE)(b)
and = lambda a: lambda b: a(b)(FALSE)
not = lambda a: a(FALSE)(TRUE)
xor = lambda a: lambda b: a(b(FALSE)(TRUE))(b(TRUE)(FALSE))
xnor = lambda a: lambda b: not(xor(a)(b)) |
# example to understand variables
a = [2, 4, 6]
b = a
a.append(8)
print(b)
# example to understand variables scope
a = 15; b = 25
def my_function():
global a
a = 11; b = 21
my_function()
print(a) #11
print(b) #25 | a = [2, 4, 6]
b = a
a.append(8)
print(b)
a = 15
b = 25
def my_function():
global a
a = 11
b = 21
my_function()
print(a)
print(b) |
def multiply(a,b):
return a*b
def divide(a,b):
return a/b
| def multiply(a, b):
return a * b
def divide(a, b):
return a / b |
expected_output = {
"version": {
"build_time": "08:13:43 Apr 7, 2021",
"firmware_ver": "18r.1.00h",
"install_time": "07:14:32 Jun 1, 2021",
"slot": {
"L1/0": {
"name": "L1/0",
"primary_ver": "18r.1.00h",
"secondary_ver": "... | expected_output = {'version': {'build_time': '08:13:43 Apr 7, 2021', 'firmware_ver': '18r.1.00h', 'install_time': '07:14:32 Jun 1, 2021', 'slot': {'L1/0': {'name': 'L1/0', 'primary_ver': '18r.1.00h', 'secondary_ver': '18r.1.00h', 'status': 'ACTIVE'}, 'L2/0': {'name': 'L2/0', 'primary_ver': '18r.1.00h', 'secondary_ver... |
# testNamespace.someFunction
testNamespace.some_function("", 0, False)
# testNamespace.someFunctionWithDefl
testNamespace.some_function_with_defl(5, True)
| testNamespace.some_function('', 0, False)
testNamespace.some_function_with_defl(5, True) |
def solve():
n = int(input())
f = [1, 2] + [0] * (n - 2)
for i in range(2, n):
f[i] = (f[i - 2] + f[i - 1]) % 15746
print(f[n - 1])
solve()
| def solve():
n = int(input())
f = [1, 2] + [0] * (n - 2)
for i in range(2, n):
f[i] = (f[i - 2] + f[i - 1]) % 15746
print(f[n - 1])
solve() |
m, n = map(int, input().split())
dicionario = {}
for i in range(m):
cargo, valor = input().split()
dicionario[cargo] = int(valor)
for i in range(n):
a = input().split()
total = 0
while a != ["."]:
for word in a:
if word in dicionario:
total += dicionario[word]
a = input().split()
print(total)
| (m, n) = map(int, input().split())
dicionario = {}
for i in range(m):
(cargo, valor) = input().split()
dicionario[cargo] = int(valor)
for i in range(n):
a = input().split()
total = 0
while a != ['.']:
for word in a:
if word in dicionario:
total += dicionario[word]... |
f = lambda seg,c: sum([v[0]/(v[1]+c) for v in seg])
n,t = [int(i) for i in input().split()]
seg = []
l,r = -2011,10**9
for i in range(n):
seg.append([int(j) for j in input().split()])
l = max(l,-seg[i][1])
c = (l+r)/2
curr = f(seg,c)
it = 1000
while abs(curr-t) > 10**(-7) and it > 0:
if curr >= t:
... | f = lambda seg, c: sum([v[0] / (v[1] + c) for v in seg])
(n, t) = [int(i) for i in input().split()]
seg = []
(l, r) = (-2011, 10 ** 9)
for i in range(n):
seg.append([int(j) for j in input().split()])
l = max(l, -seg[i][1])
c = (l + r) / 2
curr = f(seg, c)
it = 1000
while abs(curr - t) > 10 ** (-7) and it > 0:
... |
# Copyright (c) 2020 Graphcore Ltd. All rights reserved
# signatures for manually added operators
signatures = {
'beginIpuBlock': [['clong'], ['clong'], ['clong']],
'cast': ['Args', ['scalar_type']],
'internalCast': ['Args', ['cstr']],
'constantPad': ['Args', ['clong_list'], ['cfloat']],
'edgePad':... | signatures = {'beginIpuBlock': [['clong'], ['clong'], ['clong']], 'cast': ['Args', ['scalar_type']], 'internalCast': ['Args', ['cstr']], 'constantPad': ['Args', ['clong_list'], ['cfloat']], 'edgePad': ['Args', ['clong_list']], 'optimizerGroup': [['clong'], ['tensor_list']], 'printIpuTensor': ['Args', ['cstr']], 'callCp... |
def post(settings):
data = {"dynaconf_merge": True}
if settings.get("ADD_BEATLES") is True:
data["BANDS"] = ["Beatles"]
return data
| def post(settings):
data = {'dynaconf_merge': True}
if settings.get('ADD_BEATLES') is True:
data['BANDS'] = ['Beatles']
return data |
class Text():
RED = "\033[1;31;1m"
GREEN = '\033[1;32;1m'
YELLOW = '\033[1;33;1m'
UNDERLINE = '\033[4m'
def apply(str, format):
return(format + str + '\033[0m')
| class Text:
red = '\x1b[1;31;1m'
green = '\x1b[1;32;1m'
yellow = '\x1b[1;33;1m'
underline = '\x1b[4m'
def apply(str, format):
return format + str + '\x1b[0m' |
# parsetab.py
# This file is automatically generated. Do not edit.
_tabversion = '3.10'
_lr_method = 'LALR'
_lr_signature = 'leftIDleftNUMBERINFINITYleftBEGIN_CASEEND_CASEBEGIN_BMATRIXEND_BMATRIXBEGIN_PMATRIXEND_PMATRIXBACKSLASHESleftINTEGRALDIFFERENTIALDIEPARTIALLIMITTOrightCOMMArightPIPErightLPARENRPARENrightLBRAC... | _tabversion = '3.10'
_lr_method = 'LALR'
_lr_signature = 'leftIDleftNUMBERINFINITYleftBEGIN_CASEEND_CASEBEGIN_BMATRIXEND_BMATRIXBEGIN_PMATRIXEND_PMATRIXBACKSLASHESleftINTEGRALDIFFERENTIALDIEPARTIALLIMITTOrightCOMMArightPIPErightLPARENRPARENrightLBRACERBRACELBRACKETRBRACKETFRACleftPIPRIMErightLEGELTGTEQNEQleftINrightDOT... |
class EndPointParam:
NO_VALUE = (None, ) # Simple tuple for testing with `is`
def __init__(self, vtype=str, default=NO_VALUE, help_text=None, required=False):
self.name = 'param'
self.data_type = vtype
self.default = default
self.help_text = help_text
self.required = ... | class Endpointparam:
no_value = (None,)
def __init__(self, vtype=str, default=NO_VALUE, help_text=None, required=False):
self.name = 'param'
self.data_type = vtype
self.default = default
self.help_text = help_text
self.required = required
def clean(self, value):
... |
async def test_index(test_cli):
resp = await test_cli.get('/')
assert resp.status == 200
data = await resp.text()
assert '<title>squash</title>' in data
| async def test_index(test_cli):
resp = await test_cli.get('/')
assert resp.status == 200
data = await resp.text()
assert '<title>squash</title>' in data |
if name:
env = 1
else:
env = 2
| if name:
env = 1
else:
env = 2 |
n,k = map(int,input().split())
s = input()
if n//2 >= k:
for i in range(k-1):
print("LEFT")
for i in range(n-1):
print("PRINT",s[i])
print("RIGHT")
print("PRINT",s[n-1])
else:
for i in range(n-k):
print("RIGHT")
for i in range(1,n):
print("PRINT",s[-i])
... | (n, k) = map(int, input().split())
s = input()
if n // 2 >= k:
for i in range(k - 1):
print('LEFT')
for i in range(n - 1):
print('PRINT', s[i])
print('RIGHT')
print('PRINT', s[n - 1])
else:
for i in range(n - k):
print('RIGHT')
for i in range(1, n):
print('PRI... |
def stringsRearrangement(inputArray):
'''
Given an array of equal-length strings, check if it is possible to rearrange the strings in
such a way that after the rearrangement the strings at consecutive positions would differ
by exactly one character.
'''
totalLen = len(inputArray)
for i in ... | def strings_rearrangement(inputArray):
"""
Given an array of equal-length strings, check if it is possible to rearrange the strings in
such a way that after the rearrangement the strings at consecutive positions would differ
by exactly one character.
"""
total_len = len(inputArray)
for i i... |
# https://projecteuler.net/problem=20
def reverse_str(s):
return s[::-1]
def sum_str(a, b):
if len(b) > len(a):
return sum_str(b, a)
reverseA = reverse_str(a)
reverseB = reverse_str(b)
i = 0
add = 0
result = []
while i < len(a):
o1 = int(reverseA[i])
o2 = 0
... | def reverse_str(s):
return s[::-1]
def sum_str(a, b):
if len(b) > len(a):
return sum_str(b, a)
reverse_a = reverse_str(a)
reverse_b = reverse_str(b)
i = 0
add = 0
result = []
while i < len(a):
o1 = int(reverseA[i])
o2 = 0
if i < len(b):
o2 = i... |
'''
lec 3
'''
my_list = [1,2,3,4,5]
print(my_list)
my_nested_list = [1,2,3,my_list]
print(my_nested_list)
my_list [0] = 6
print(my_list)
print(my_list[0])
print(my_list[1])
print(my_list[-1])
print(my_list)
print(my_list[1:3])
print(my_list[:])
x,y = ['a', 'b']
print(x,y)
print(my_list)
my_list.append(7)
print... | """
lec 3
"""
my_list = [1, 2, 3, 4, 5]
print(my_list)
my_nested_list = [1, 2, 3, my_list]
print(my_nested_list)
my_list[0] = 6
print(my_list)
print(my_list[0])
print(my_list[1])
print(my_list[-1])
print(my_list)
print(my_list[1:3])
print(my_list[:])
(x, y) = ['a', 'b']
print(x, y)
print(my_list)
my_list.append(7)
prin... |
class dummy_storage:
def retrieve(self):
return {}
def persist(self, credentials):
return None
| class Dummy_Storage:
def retrieve(self):
return {}
def persist(self, credentials):
return None |
# https://app.codesignal.com/interview-practice/task/5vcioHMkhGqkaQQYt/solutions
# Singly-linked lists are already defined with this interface:
# class ListNode(object):
# def __init__(self, x):
# self.value = x
# self.next = None
#
def rearrangeLastN(head, n):
if n < 1:
return head
l = 0... | def rearrange_last_n(head, n):
if n < 1:
return head
l = 0
iterator = head
while iterator:
iterator = iterator.next
l += 1
if l <= 1 or n >= l:
return head
reversing_elements = l - n
i = 0
start = head
while head:
i += 1
if i == reversi... |
x = int(input())
ans = 0
ans = (x//500)*1000
x = x % 500
ans += (x//5)*5
print(ans)
| x = int(input())
ans = 0
ans = x // 500 * 1000
x = x % 500
ans += x // 5 * 5
print(ans) |
student = {
"name": "Mark",
"student_id": 15163,
"feedback": None
}
all_students = [
{"name": "Mark", "student_id": 15163},
{"name": "Katarina", "student_id": 63112},
{"name": "Jessica", "student_id": 30021}
]
student["name"] == "Mark"
student["last_name"] == KeyError
student.get("last_name", ... | student = {'name': 'Mark', 'student_id': 15163, 'feedback': None}
all_students = [{'name': 'Mark', 'student_id': 15163}, {'name': 'Katarina', 'student_id': 63112}, {'name': 'Jessica', 'student_id': 30021}]
student['name'] == 'Mark'
student['last_name'] == KeyError
student.get('last_name', 'Unknown') == 'Unknown'
studen... |
og=list(input("Enter number "))
new=set(og)
print("".join(og),"is a Unique Number") if len(new)==len(og) else print("".join(og),"is not a Unique Number")
| og = list(input('Enter number '))
new = set(og)
print(''.join(og), 'is a Unique Number') if len(new) == len(og) else print(''.join(og), 'is not a Unique Number') |
n = int(input())
cont = 0
while cont < n:
num = int(input())
if cont == 0:
maior = num
elif num > maior:
maior = num
cont += 1
print(maior)
| n = int(input())
cont = 0
while cont < n:
num = int(input())
if cont == 0:
maior = num
elif num > maior:
maior = num
cont += 1
print(maior) |
class Solution:
def climbStairs(self, n: int) -> int:
if n==1:
return 1
if n==2:
return 2
l=[1,2]
for i in range(2,n):
l.append(l[i-1]+l[i-2])
return l.pop()
| class Solution:
def climb_stairs(self, n: int) -> int:
if n == 1:
return 1
if n == 2:
return 2
l = [1, 2]
for i in range(2, n):
l.append(l[i - 1] + l[i - 2])
return l.pop() |
class PipelineException(Exception):
def __init__(self, msg=''):
self.msg = msg
super(PipelineException, self).__init__(msg)
| class Pipelineexception(Exception):
def __init__(self, msg=''):
self.msg = msg
super(PipelineException, self).__init__(msg) |
b=[9,6,3,2,5,8,7,4,1,0]
def selection_sort(b):
for i in range((len(b))-1):
min = b[i]
for j in range(i + 1, len(b)):
if b[j] < min:
min = b[j]
pos=j
b[pos] = b[i]
b[i]=min
print(b)
selection_sort(b)
pri... | b = [9, 6, 3, 2, 5, 8, 7, 4, 1, 0]
def selection_sort(b):
for i in range(len(b) - 1):
min = b[i]
for j in range(i + 1, len(b)):
if b[j] < min:
min = b[j]
pos = j
b[pos] = b[i]
b[i] = min
print(b)
selection_sort(b)
p... |
def cipher(s):
return ''.join((map(lambda c: chr(219-ord(c)) if 97 <= ord(c) <= 122 else c, s)))
print(cipher('Anyone who has never made a mistake has never tried anything new.'))
| def cipher(s):
return ''.join(map(lambda c: chr(219 - ord(c)) if 97 <= ord(c) <= 122 else c, s))
print(cipher('Anyone who has never made a mistake has never tried anything new.')) |
# BOJ 9465
n = 5
stickers = [[50, 10, 100, 20, 40], [30, 50, 70, 10, 60]]
memo = [[0 for _ in range(n)] for _ in range(2)]
memo[0][0] = stickers[0][0]
memo[0][1] = stickers[0][1]
def solve(n):
for i in range(1, n):
if i < 2:
memo[0][i] = memo[1][i - 1] + stickers[0][i]
memo[1][i] ... | n = 5
stickers = [[50, 10, 100, 20, 40], [30, 50, 70, 10, 60]]
memo = [[0 for _ in range(n)] for _ in range(2)]
memo[0][0] = stickers[0][0]
memo[0][1] = stickers[0][1]
def solve(n):
for i in range(1, n):
if i < 2:
memo[0][i] = memo[1][i - 1] + stickers[0][i]
memo[1][i] = memo[0][i -... |
class GenericMachine():
alphabet = set()
trans_func = dict()
start_state = str()
final_states = set()
def __init__(self, _alphabet, _trans_func, _start_state, _final_states):
self.alphabet = _alphabet
self.trans_func = _trans_func
self.start_state = _start_state
self... | class Genericmachine:
alphabet = set()
trans_func = dict()
start_state = str()
final_states = set()
def __init__(self, _alphabet, _trans_func, _start_state, _final_states):
self.alphabet = _alphabet
self.trans_func = _trans_func
self.start_state = _start_state
self.f... |
'''
Python has built-in string validation methods for basic data. It can check if a string is composed of alphabetical characters, alphanumeric characters, digits, etc.
str.isalnum()
This method checks if all the characters of a string are alphanumeric (a-z, A-Z and 0-9).
>>> print 'ab123'.isalnum()
True
>>> print 'a... | """
Python has built-in string validation methods for basic data. It can check if a string is composed of alphabetical characters, alphanumeric characters, digits, etc.
str.isalnum()
This method checks if all the characters of a string are alphanumeric (a-z, A-Z and 0-9).
>>> print 'ab123'.isalnum()
True
>>> print 'a... |
# -*- encoding: utf-8 -*-
class WebError(Exception):
def __init__(self, code, message=''):
Exception.__init__(self)
self.code = code
self.message = message
def __str__(self):
return self.message
| class Weberror(Exception):
def __init__(self, code, message=''):
Exception.__init__(self)
self.code = code
self.message = message
def __str__(self):
return self.message |
# EG7-09 get_value investigation 2
def get_value(prompt, value_min, value_max):
return
ride_number=get_value(prompt='Please enter the ride number you want:',value_min=1,value_max=5)
print('You have selected ride:',ride_number)
| def get_value(prompt, value_min, value_max):
return
ride_number = get_value(prompt='Please enter the ride number you want:', value_min=1, value_max=5)
print('You have selected ride:', ride_number) |
# https://www.codewars.com/kata/5266876b8f4bf2da9b000362/train/python
def likes(names):
counter=0
for name in names:
counter+=1
if counter==0:
return("no one likes this")
elif counter==1:
return(f"{names[0]} likes this")
elif counter==2:
return(f"{names[0]} and {n... | def likes(names):
counter = 0
for name in names:
counter += 1
if counter == 0:
return 'no one likes this'
elif counter == 1:
return f'{names[0]} likes this'
elif counter == 2:
return f'{names[0]} and {names[1]} like this'
elif counter == 3:
return f'{names... |
# Created by MechAviv
# Quest ID :: 20865
# The Path of a Thunder Breaker
sm.setSpeakerID(1101007)
if sm.sendAskYesNo("Yer sure about this? Remember, ye can't change yer mind, so ye'll want to pick carefully. Ye really want to join me as a Thunder Breaker?"):
sm.setSpeakerID(1101007)
sm.sendNext("Just like tha... | sm.setSpeakerID(1101007)
if sm.sendAskYesNo("Yer sure about this? Remember, ye can't change yer mind, so ye'll want to pick carefully. Ye really want to join me as a Thunder Breaker?"):
sm.setSpeakerID(1101007)
sm.sendNext('Just like that, yer a Thunder Breaker! Now let me give ye some abilities.')
sm.giveI... |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
arr = [6,5,4,2,1,8,3]
def qsort(l, r):
global arr
if l >= r: return
first, last, key = l, r, arr[l]
while first < last:
while first < last and arr[last] >= key: last -= 1
arr[first] = arr[last]
while first < last and arr[first] <= key... | arr = [6, 5, 4, 2, 1, 8, 3]
def qsort(l, r):
global arr
if l >= r:
return
(first, last, key) = (l, r, arr[l])
while first < last:
while first < last and arr[last] >= key:
last -= 1
arr[first] = arr[last]
while first < last and arr[first] <= key:
f... |
def test_accounts(client):
client.session.get.return_value.json.return_value.update({'accounts': [1, ]})
client.accounts()
client.session.get.called_once_with('https://api.getdrip.com/v2/accounts/')
def test_account(client):
client.session.get.return_value.json.return_value.update({'accounts': [1, ]... | def test_accounts(client):
client.session.get.return_value.json.return_value.update({'accounts': [1]})
client.accounts()
client.session.get.called_once_with('https://api.getdrip.com/v2/accounts/')
def test_account(client):
client.session.get.return_value.json.return_value.update({'accounts': [1]})
... |
# model
model = Model()
i1 = Input("op1", "TENSOR_INT32", "{1, 2, 2, 1}")
i2 = Output("op2", "TENSOR_INT32", "{1, 2, 2, 1}")
model = model.Operation("ZEROS_LIKE_EX", i1).To(i2)
# Example 1. Input in operand 0,
input0 = {i1: # input 0
[-2, -1, 0, 3]}
output0 = {i2: # output 0
[0, 0, 0, 0]}
# Inst... | model = model()
i1 = input('op1', 'TENSOR_INT32', '{1, 2, 2, 1}')
i2 = output('op2', 'TENSOR_INT32', '{1, 2, 2, 1}')
model = model.Operation('ZEROS_LIKE_EX', i1).To(i2)
input0 = {i1: [-2, -1, 0, 3]}
output0 = {i2: [0, 0, 0, 0]}
example((input0, output0)) |
def hello():
# Hey i'm a comment
# I am a helpful note for humans, and will not be ran
pass
if __name__ == '__main__':
hello() | def hello():
pass
if __name__ == '__main__':
hello() |
# Prob 2
# Create a small program that will:
# Ask for user input
# Count the number of vowels in the user text ('a', 'e', 'i', 'o', 'u', 'y')
# Display the number of vowels in user text
print("Please enter a string")
my_string = input()
vowels = ['a', 'e', 'i', 'o', 'u', 'y']
count = 0
for letter in my_string.lower()... | print('Please enter a string')
my_string = input()
vowels = ['a', 'e', 'i', 'o', 'u', 'y']
count = 0
for letter in my_string.lower():
if letter in vowels:
count += 1
print('Number of vowels in string: ' + str(count))
print('Please enter a Gmail email')
email = input()
print(email[-10:] == '@gmail.com') |
def my_func(arr1, arr2, arr3):
ln1 = len(arr1)
ln2 = len(arr2)
ln3 = len(arr3)
ptr1 = 0
ptr2 = 0
ptr3 = 0
while ptr1 < ln1 and ptr2 < ln2 and ptr3 < ln3:
if arr1[ptr1] < arr2[ptr2]:
if arr3[ptr3] < arr2[ptr2]:
arr1[ptr1] = -1
arr3[ptr3... | def my_func(arr1, arr2, arr3):
ln1 = len(arr1)
ln2 = len(arr2)
ln3 = len(arr3)
ptr1 = 0
ptr2 = 0
ptr3 = 0
while ptr1 < ln1 and ptr2 < ln2 and (ptr3 < ln3):
if arr1[ptr1] < arr2[ptr2]:
if arr3[ptr3] < arr2[ptr2]:
arr1[ptr1] = -1
arr3[ptr3] =... |
#
# PySNMP MIB module RAPTOR-SNMPv1-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/RAPTOR-SNMPv1-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 20:43:39 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Ma... | (octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, constraints_intersection, value_size_constraint, constraints_union, value_range_constraint) ... |
class AppNotFoundError(Exception):
pass
class ClassNotFoundError(Exception):
pass
| class Appnotfounderror(Exception):
pass
class Classnotfounderror(Exception):
pass |
#!/usr/bin/env python3
# fileencoding=utf-8
def char_width(char):
# For japanese.
if len(char) == 1:
return 1
else:
return 2
def string_width(_string):
char_width_list = []
for c in _string.decode('utf-8'):
char_width_list.append(char_width(c))
return char_width_list
d... | def char_width(char):
if len(char) == 1:
return 1
else:
return 2
def string_width(_string):
char_width_list = []
for c in _string.decode('utf-8'):
char_width_list.append(char_width(c))
return char_width_list
def add_space(_string, num):
return _string + ' ' * num
def c... |
x = "Hello"
y = 15
print(bool(x))
print(bool(y))
| x = 'Hello'
y = 15
print(bool(x))
print(bool(y)) |
class Solution:
def findMedianSortedArrarys(self, A, B):
lengthA = len(A)
lengthB = len(B)
new_arr = []
i = j = 0
while i < lengthA and j < lengthB:
if A[i] < B[j]:
new_arr.append(A[i])
i += 1
else:
new_... | class Solution:
def find_median_sorted_arrarys(self, A, B):
length_a = len(A)
length_b = len(B)
new_arr = []
i = j = 0
while i < lengthA and j < lengthB:
if A[i] < B[j]:
new_arr.append(A[i])
i += 1
else:
... |
#!/usr/bin/env python3
count = 0
with open("romeo.txt") as romeo:
text = romeo.readlines()
for line in text:
if "ROMEO" in line:
count += 1
print(count)
| count = 0
with open('romeo.txt') as romeo:
text = romeo.readlines()
for line in text:
if 'ROMEO' in line:
count += 1
print(count) |
# 22004 | Fixing the Fence (Evan intro)
sm.setSpeakerID(1013103)
sm.sendNext("Ah, did you bring all the Thick Branches? That's my kid! What shall i give you as reward?... Let's see... Oh, right! \r\n #fUI/UIWindow2.img/QuestIcon/4/0# \r\n #v3010097# Strong Wooden Chair \r\n #fUI/UIWindow2.img/QuestIcon/8/0# 210 exp")... | sm.setSpeakerID(1013103)
sm.sendNext("Ah, did you bring all the Thick Branches? That's my kid! What shall i give you as reward?... Let's see... Oh, right! \r\n #fUI/UIWindow2.img/QuestIcon/4/0# \r\n #v3010097# Strong Wooden Chair \r\n #fUI/UIWindow2.img/QuestIcon/8/0# 210 exp")
if sm.canHold(3010097):
sm.giveItem(3... |
# Definition for a binary tree node
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def levelOrder(self, A):
queue = []
ansr_queue = []
queue.append(A)
marker = "$"
queue.append(marker)
... | class Treenode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def level_order(self, A):
queue = []
ansr_queue = []
queue.append(A)
marker = '$'
queue.append(marker)
row = []
while len(queu... |
class Solution:
def numberOfWays(self, numPeople: int) -> int:
kMod = int(1e9) + 7
# dp[i] := # of ways i handshakes pair w//o crossing
dp = [1] + [0] * (numPeople // 2)
for i in range(1, numPeople // 2 + 1):
for j in range(i):
dp[i] += dp[j] * dp[i - 1 - j]
dp[i] %= kMod
r... | class Solution:
def number_of_ways(self, numPeople: int) -> int:
k_mod = int(1000000000.0) + 7
dp = [1] + [0] * (numPeople // 2)
for i in range(1, numPeople // 2 + 1):
for j in range(i):
dp[i] += dp[j] * dp[i - 1 - j]
dp[i] %= kMod
return ... |
# Language: Python 3
n = int(input())
if (n % 2 != 0):
print("Weird")
elif (2 <= n <= 5):
print("Not Weird")
elif (6 <= n <= 20):
print("Weird")
else:
print("Not Weird")
| n = int(input())
if n % 2 != 0:
print('Weird')
elif 2 <= n <= 5:
print('Not Weird')
elif 6 <= n <= 20:
print('Weird')
else:
print('Not Weird') |
bot_token = ""
bot_token_dev = ""
db_url = ""
mod_db_url = ""
cloudflare_email = ""
cloudflare_token = ""
error_webhook_token = ""
error_webhook_id = 0
consumer_key = ""
consumer_secret_key = ""
access_token = ""
access_token_secret = "" | bot_token = ''
bot_token_dev = ''
db_url = ''
mod_db_url = ''
cloudflare_email = ''
cloudflare_token = ''
error_webhook_token = ''
error_webhook_id = 0
consumer_key = ''
consumer_secret_key = ''
access_token = ''
access_token_secret = '' |
# map function
#iterable as list or array
#function as def or lambda
#map(function,iterable) or
numbers=[1,2,3,4,5,6]
#example
def Sqrt(number):
return number**2
a=list(map(Sqrt,numbers))
print(a)
#example
b=list(map(lambda number:number**3,numbers))
print(b)
#map(str,int,double variable as ... | numbers = [1, 2, 3, 4, 5, 6]
def sqrt(number):
return number ** 2
a = list(map(Sqrt, numbers))
print(a)
b = list(map(lambda number: number ** 3, numbers))
print(b)
str_numbers = ['1', '2', '3', '4', '5', '6']
c = list(map(int, str_numbers))
print(c) |
#
# PySNMP MIB module ChrTrap-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ChrTrap-MIB
# Produced by pysmi-0.3.4 at Wed May 1 12:36:20 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 0... | (octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, value_size_constraint, value_range_constraint, constraints_union, constraints_intersection) ... |
# Time: 218 ms
# Memory: 4 KB
for i in range(5):
m = list(map(int, input().split()))
if 1 in m:
r, c = (m.index(1)), (i)
sol = abs(r - 2) + abs(2 - c)
print(sol)
| for i in range(5):
m = list(map(int, input().split()))
if 1 in m:
(r, c) = (m.index(1), i)
sol = abs(r - 2) + abs(2 - c)
print(sol) |
nama = "azmi"
umur_5_tahun_lalu = 23
print ("nama saya")
print(nama)
print("sedangkan umur saat ini adalah")
print(umur_5_tahun_lalu + 5)
if (nama == "nathan") :
print("selamat datang Nathan!")
elif (nama == "azmi") :
print("selamat datang Azmi!")
else :
print("Selamat datang pak")
print(nama)
| nama = 'azmi'
umur_5_tahun_lalu = 23
print('nama saya')
print(nama)
print('sedangkan umur saat ini adalah')
print(umur_5_tahun_lalu + 5)
if nama == 'nathan':
print('selamat datang Nathan!')
elif nama == 'azmi':
print('selamat datang Azmi!')
else:
print('Selamat datang pak')
print(nama) |
def exact_cover(X, Y):
X = {j: set() for j in X}
for i, row in Y.items():
for j in row:
X[j].add(i)
return X, Y
def select(X, Y, r):
cols = []
for j in Y[r]:
for i in X[j]:
for k in Y[i]:
if k != j:
X[k].re... | def exact_cover(X, Y):
x = {j: set() for j in X}
for (i, row) in Y.items():
for j in row:
X[j].add(i)
return (X, Y)
def select(X, Y, r):
cols = []
for j in Y[r]:
for i in X[j]:
for k in Y[i]:
if k != j:
X[k].remove(i)
... |
class Node(object):
'''Binary Tree Node'''
def __init__(self, data):
self.data = data
self.left = None
self.right = None
class BinaryTree(object):
'''Building binary Tree'''
def __init__(self, data):
self.root = Node(data)
def addLeft(self, data):
if self... | class Node(object):
"""Binary Tree Node"""
def __init__(self, data):
self.data = data
self.left = None
self.right = None
class Binarytree(object):
"""Building binary Tree"""
def __init__(self, data):
self.root = node(data)
def add_left(self, data):
if self... |
YELLOW = (255, 255, 0)
CYAN = (0, 255, 255)
RED = (255, 0, 0)
| yellow = (255, 255, 0)
cyan = (0, 255, 255)
red = (255, 0, 0) |
# this is a python file created in jupyter notbook
def list_fruits(fruits=[]):
for fruit in fruits:
print(fruit)
fruits = ['apple','kiwi','banana']
list_fruit(fruits)
| def list_fruits(fruits=[]):
for fruit in fruits:
print(fruit)
fruits = ['apple', 'kiwi', 'banana']
list_fruit(fruits) |
lst = [['Harry', 37.21],['Berry', 37.21],['Tina', 37.2],['Akriti', 41],['Harsh', 39]]
second_highest = sorted(list(set([marks for name, marks in lst])))[1]
print('\n'.join([a for a,b in sorted(lst) if b == second_highest])) | lst = [['Harry', 37.21], ['Berry', 37.21], ['Tina', 37.2], ['Akriti', 41], ['Harsh', 39]]
second_highest = sorted(list(set([marks for (name, marks) in lst])))[1]
print('\n'.join([a for (a, b) in sorted(lst) if b == second_highest])) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.