content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
'''
Write a code which accepts a sequence of words as input and prints the words in a sequence after sorting them alphabetically.
Hint: In case of input data being supplied to the question, it should be assumed to be a console input.
'''
print('Input number word for : ')
n = input()
mp = list(map(lambda x: ord(... | """
Write a code which accepts a sequence of words as input and prints the words in a sequence after sorting them alphabetically.
Hint: In case of input data being supplied to the question, it should be assumed to be a console input.
"""
print('Input number word for : ')
n = input()
mp = list(map(lambda x: ord(x), n))
... |
class subject ():
def __init__(self):
x=[]
self.students=[]
def addstudents(self):
n=int(input("Enter No. Of Students :- "))
for i in range (n):
self.name=input("Enter Name :- ")
self.rno=input("Enter Roll No. :- ")
self.marks=input("E... | class Subject:
def __init__(self):
x = []
self.students = []
def addstudents(self):
n = int(input('Enter No. Of Students :- '))
for i in range(n):
self.name = input('Enter Name :- ')
self.rno = input('Enter Roll No. :- ')
self.marks = input('... |
def make_dot(count, left, right):
if left == "" and right == "":
return count * "."
if right == "":
if left == "L":
return '.'*count
else:
return 'R'*count
if left == "":
if right == "L":
return count * "L"
else:
retur... | def make_dot(count, left, right):
if left == '' and right == '':
return count * '.'
if right == '':
if left == 'L':
return '.' * count
else:
return 'R' * count
if left == '':
if right == 'L':
return count * 'L'
else:
ret... |
"""Do a one-time build of default.png"""
# Copyright (c) 2001-2009 ElevenCraft Inc.
# See LICENSE for details.
if __name__ == '__main__':
f = file('default.png', 'rb')
default_png = f.read()
f.close()
f = file('_default_png.py', 'wU')
f.write('DEFAULT_PNG = %r\n' % default_png)
f.close()
| """Do a one-time build of default.png"""
if __name__ == '__main__':
f = file('default.png', 'rb')
default_png = f.read()
f.close()
f = file('_default_png.py', 'wU')
f.write('DEFAULT_PNG = %r\n' % default_png)
f.close() |
"""
docsting of empty_all module.
"""
__all__ = []
def foo():
"""docstring"""
def bar():
"""docstring"""
def baz():
"""docstring"""
| """
docsting of empty_all module.
"""
__all__ = []
def foo():
"""docstring"""
def bar():
"""docstring"""
def baz():
"""docstring""" |
load(
"@io_bazel_rules_dotnet//dotnet/private:context.bzl",
"dotnet_context",
)
load(
"@io_bazel_rules_dotnet//dotnet/private:providers.bzl",
"DotnetLibrary",
"DotnetResource",
)
load(
"@io_bazel_rules_dotnet//dotnet/private:rules/launcher_gen.bzl",
"dotnet_launcher_gen",
)
def _core_bina... | load('@io_bazel_rules_dotnet//dotnet/private:context.bzl', 'dotnet_context')
load('@io_bazel_rules_dotnet//dotnet/private:providers.bzl', 'DotnetLibrary', 'DotnetResource')
load('@io_bazel_rules_dotnet//dotnet/private:rules/launcher_gen.bzl', 'dotnet_launcher_gen')
def _core_binary_impl(ctx):
"""dotnet_binary_impl... |
if sys.version_info.minor > 9:
phr = {"user_id": user_id} | content
else:
z = {"user_id": user_id}
phr = {**z, **content}
| if sys.version_info.minor > 9:
phr = {'user_id': user_id} | content
else:
z = {'user_id': user_id}
phr = {**z, **content} |
class Solution:
def numSubarrayProductLessThanK(self, nums: List[int], k: int) -> int:
if k <= 1 :
return 0
prod =1
res = 0
i,j = 0, 0
while j < len(nums):
prod *= nums[j]
if prod < k :
res += (j-i+1)
elif prod... | class Solution:
def num_subarray_product_less_than_k(self, nums: List[int], k: int) -> int:
if k <= 1:
return 0
prod = 1
res = 0
(i, j) = (0, 0)
while j < len(nums):
prod *= nums[j]
if prod < k:
res += j - i + 1
... |
"""
This module defines the learner interface.
"""
class Learner:
"""
A learner ingests data, manipulates internal state by learning off this
data, supplies agents for taking further actions, and provides an opaque
interface to internal evaluation.
"""
def train(self, data, timesteps):
... | """
This module defines the learner interface.
"""
class Learner:
"""
A learner ingests data, manipulates internal state by learning off this
data, supplies agents for taking further actions, and provides an opaque
interface to internal evaluation.
"""
def train(self, data, timesteps):
... |
# helpers
def create_data_list(dic):
""" This function creates a list from a data dictionary where all user data is stored """
lst = []
lst.append(dic['cough'])
lst.append(dic['fever'])
lst.append(dic['sore_throat'])
lst.append(dic['shortness_of_breath'])
lst.append(dic['head_ache'])
lst.append(int(dic['age']))... | def create_data_list(dic):
""" This function creates a list from a data dictionary where all user data is stored """
lst = []
lst.append(dic['cough'])
lst.append(dic['fever'])
lst.append(dic['sore_throat'])
lst.append(dic['shortness_of_breath'])
lst.append(dic['head_ache'])
lst.append(in... |
# -*- coding: utf-8 -*-
# ScrollBar part codes
# Left arrow of horizontal scroll bar.
# @see ScrollBar::scrollStep
sbLeftArrow = 0
# Right arrow of horizontal scroll bar.
# @see ScrollBar::scrollStep
sbRightArrow = 1
# Left paging area of horizontal scroll bar.
# @see ScrollBar::scrollStep
sbPageLeft = 2
# Right pag... | sb_left_arrow = 0
sb_right_arrow = 1
sb_page_left = 2
sb_page_right = 3
sb_up_arrow = 4
sb_down_arrow = 5
sb_page_up = 6
sb_page_down = 7
sb_indicator = 8
sb_horizontal = 0
sb_vertical = 1
sb_handle_keyboard = 2 |
BLACK = u"\u001b[30m"
RED = u"\u001b[31m"
GREEN = u"\u001b[32m"
YELLOW = u"\u001b[33m"
BLUE = u"\u001b[34m"
MAGENTA = u"\u001b[35m"
CYAN = u"\u001b[36m"
WHITE = u"\u001b[37m"
BBLACK = u"\u001b[30;1m"
BRED = u"\u001b[31;1m"
BGREEN = u"\u001b[32;1m"
BYELLOW = u"\u001b[33;1m"
BBLUE = u"\u001b[34;1m"
BMAGENTA = u"\u001b[3... | black = u'\x1b[30m'
red = u'\x1b[31m'
green = u'\x1b[32m'
yellow = u'\x1b[33m'
blue = u'\x1b[34m'
magenta = u'\x1b[35m'
cyan = u'\x1b[36m'
white = u'\x1b[37m'
bblack = u'\x1b[30;1m'
bred = u'\x1b[31;1m'
bgreen = u'\x1b[32;1m'
byellow = u'\x1b[33;1m'
bblue = u'\x1b[34;1m'
bmagenta = u'\x1b[35;1m'
bcyan = u'\x1b[36;1m'
b... |
'''
module for implementation of
merge sort
'''
def merge_sort(arr: list):
if len(arr) > 1:
mid = len(arr) // 2
L = arr[:mid]
R = arr[mid:]
merge_sort(L)
merge_sort(R)
i, j, k = 0, 0, 0
while (i < len(L) and j < len(R)):
if (L[i] < R[j])... | """
module for implementation of
merge sort
"""
def merge_sort(arr: list):
if len(arr) > 1:
mid = len(arr) // 2
l = arr[:mid]
r = arr[mid:]
merge_sort(L)
merge_sort(R)
(i, j, k) = (0, 0, 0)
while i < len(L) and j < len(R):
if L[i] < R[j]:
... |
#!/usr/bin/env python3
class MessageBroadcast:
def __init__(self, friend_graph, start_person):
self.friend_graph = friend_graph
self.start_person = start_person
self.people_without_message = list(friend_graph.keys())
self.step_number = 0
self.new_people_with_message_in_last... | class Messagebroadcast:
def __init__(self, friend_graph, start_person):
self.friend_graph = friend_graph
self.start_person = start_person
self.people_without_message = list(friend_graph.keys())
self.step_number = 0
self.new_people_with_message_in_last_step = []
def broa... |
''' pythagorean_triples.py: When given the sides of a triangle, tells the user
whether the triangle is a right triangle. Based on https://www.redd.it/19jwi6 '''
while True:
sides = input('Enter the three sides of a triangle, separated by spaces: ')
try:
sides = [int(x) for x in sides.split()]
e... | """ pythagorean_triples.py: When given the sides of a triangle, tells the user
whether the triangle is a right triangle. Based on https://www.redd.it/19jwi6 """
while True:
sides = input('Enter the three sides of a triangle, separated by spaces: ')
try:
sides = [int(x) for x in sides.split()]
ex... |
# -*- coding: utf-8 -*-
# Copyright (c) 2012 Fabian Barkhau <fabian.barkhau@gmail.com>
# License: MIT (see LICENSE.TXT file)
ID = r"[0-9]+"
SLUG = r"[a-z0-9\-]+"
USERNAME = r"[\w.@+-]+" # see django.contrib.auth.forms.UserCreationForm
def _build_arg(name, pattern):
return "(?P<%s>%s)" % (name... | id = '[0-9]+'
slug = '[a-z0-9\\-]+'
username = '[\\w.@+-]+'
def _build_arg(name, pattern):
return '(?P<%s>%s)' % (name, pattern)
def arg_id(name):
return _build_arg(name, ID)
def arg_slug(name):
return _build_arg(name, SLUG)
def arg_username(name):
return _build_arg(name, USERNAME) |
"""
(C) Copyright 2020
Scott Wiederhold, s.e.wiederhold@gmail.com
https://community.openglow.org
SPDX-License-Identifier: MIT
"""
_decode_step_codes = {
'LE': {'mask': 0b00010000, 'test': 0b00010000}, # Laser Enable (ON)
'LP': {'mask': 0b10000000, 'test': 0b01111111}, # Laser Power Setting
'XP': {'mas... | """
(C) Copyright 2020
Scott Wiederhold, s.e.wiederhold@gmail.com
https://community.openglow.org
SPDX-License-Identifier: MIT
"""
_decode_step_codes = {'LE': {'mask': 16, 'test': 16}, 'LP': {'mask': 128, 'test': 127}, 'XP': {'mask': 3, 'test': 1}, 'XN': {'mask': 3, 'test': 3}, 'YN': {'mask': 12, 'test': 4}, 'YP': {... |
translations = {
"startMessage": "I can help you see all of your EqualHash.pt statistics\n\nYou can control me by "
"sending these "
"commands:\n\n/newaddr - Add new address\n/myaddrs - View all address\n\n*Edit "
"Addresses*\n/setname - Ch... | translations = {'startMessage': "I can help you see all of your EqualHash.pt statistics\n\nYou can control me by sending these commands:\n\n/newaddr - Add new address\n/myaddrs - View all address\n\n*Edit Addresses*\n/setname - Change a address's name\n/setaddress - Change the address\n/deleteaddr - Delete a address\n\... |
# A Python program to demonstrate need
# of packing and unpacking
# A sample function that takes 4 arguments
# and prints them.
def fun(a, b, c, d):
print(a, b, c, d)
# Driver Code
my_list = [1, 2, 3, 4]
# This doesn't work
fun(my_list) | def fun(a, b, c, d):
print(a, b, c, d)
my_list = [1, 2, 3, 4]
fun(my_list) |
'''
1. Write a Python program for binary search.
Binary Search : In computer science, a binary search or half-interval search algorithm finds the position of a target value within a sorted array. The binary search algorithm can be classified as a dichotomies divide-and-conquer search algorithm and executes in logarith... | """
1. Write a Python program for binary search.
Binary Search : In computer science, a binary search or half-interval search algorithm finds the position of a target value within a sorted array. The binary search algorithm can be classified as a dichotomies divide-and-conquer search algorithm and executes in logarith... |
nums = int(input())
points = []
for i in range(0, nums):
read_list = list(map(int, input().split()))
# read_list = [int(i) for i in input().split()]
points.append((read_list[0], read_list[1]))
print(points)
"""
3
1 2
23 4
4 5
[(1, 2), (23, 4), (4, 5)]
"""
| nums = int(input())
points = []
for i in range(0, nums):
read_list = list(map(int, input().split()))
points.append((read_list[0], read_list[1]))
print(points)
'\n3\n1 2\n23 4\n4 5\n[(1, 2), (23, 4), (4, 5)]\n' |
# uncompyle6 version 2.9.10
# Python bytecode 2.7 (62211)
# Decompiled from: Python 3.6.0b2 (default, Oct 11 2016, 05:27:10)
# [GCC 6.2.0 20161005]
# Embedded file name: __init__.py
MCL_OS_ARCH_I386 = 0
MCL_OS_ARCH_SPARC = 1
MCL_OS_ARCH_ALPHA = 2
MCL_OS_ARCH_ARM = 3
MCL_OS_ARCH_PPC = 4
MCL_OS_ARCH_HPPA1 = 5
MCL_OS_ARC... | mcl_os_arch_i386 = 0
mcl_os_arch_sparc = 1
mcl_os_arch_alpha = 2
mcl_os_arch_arm = 3
mcl_os_arch_ppc = 4
mcl_os_arch_hppa1 = 5
mcl_os_arch_hppa2 = 6
mcl_os_arch_mips = 7
mcl_os_arch_x64 = 8
mcl_os_arch_ia64 = 9
mcl_os_arch_sparc64 = 10
mcl_os_arch_mips64 = 11
mcl_os_arch_unknown = 65535
arch_names = {MCL_OS_ARCH_I386: ... |
#!/usr/bin/python
'''
--- Part Two ---
"Great work; looks like we're on the right track after all. Here's a star for your effort." However, the program seems a little worried. Can programs be worried?
"Based on what we're seeing, it looks like all the User wanted is some information about the evenly divisible values... | """
--- Part Two ---
"Great work; looks like we're on the right track after all. Here's a star for your effort." However, the program seems a little worried. Can programs be worried?
"Based on what we're seeing, it looks like all the User wanted is some information about the evenly divisible values in the spreadsheet... |
File1 = open(input("File path of first list in text file:"), "rt")
File2 = open(input("File path of second list in text file:"), "rt")
file = open("Compared_List.txt", "a+")
suffix_sp = [] #a list of genuses with "sp." suffix to denote the entire genus
species = [] #list of species from File1
if __name__ =... | file1 = open(input('File path of first list in text file:'), 'rt')
file2 = open(input('File path of second list in text file:'), 'rt')
file = open('Compared_List.txt', 'a+')
suffix_sp = []
species = []
if __name__ == '__main__':
for line in File1:
if line[-4:-1] == 'sp.':
suffix_sp.append(line[:... |
class Solution:
def zigzagLevelOrder(self, root):
if root is None:
return []
res = []
res.append([root.val])
queue = []
queue.append(root)
level_nodes = []
level_node_count = 1
next_level_node_count = 0
left_to_right = True
... | class Solution:
def zigzag_level_order(self, root):
if root is None:
return []
res = []
res.append([root.val])
queue = []
queue.append(root)
level_nodes = []
level_node_count = 1
next_level_node_count = 0
left_to_right = True
... |
"""Adding routes for the configuration to find."""
def includeme(config):
config.add_static_view('static', 'static', cache_max_age=3600)
config.add_route('list', '/')
config.add_route('profile', '/profile/{id:\d+}')
config.add_route('login', '/login')
config.add_route('logout', '/logout')
conf... | """Adding routes for the configuration to find."""
def includeme(config):
config.add_static_view('static', 'static', cache_max_age=3600)
config.add_route('list', '/')
config.add_route('profile', '/profile/{id:\\d+}')
config.add_route('login', '/login')
config.add_route('logout', '/logout')
conf... |
# The guess API is already defined for you.
# @param num, your guess
# @return -1 if my number is lower, 1 if my number is higher, otherwise return 0
# def guess(num):
class Solution(object):
def guessNumber(self, n, lo=0):
"""
:type n: int
:rtype: int
"""
if lo >= n:
... | class Solution(object):
def guess_number(self, n, lo=0):
"""
:type n: int
:rtype: int
"""
if lo >= n:
return n
if guess(n) == 0:
return n
x = lo + (n - lo) // 2
compar = guess(x)
if compar < 0:
return self.g... |
"""Figure size settings."""
# Some useful constants
_GOLDEN_RATIO = (5.0 ** 0.5 - 1.0) / 2.0
_INCHES_PER_POINT = 1.0 * 72.27
# Double-column formats
def icml2022_half(**kwargs):
"""Double-column (half-width) figures for ICML 2022."""
return _icml2022_and_aistats2022_half(**kwargs)
def icml2022_full(**kwar... | """Figure size settings."""
_golden_ratio = (5.0 ** 0.5 - 1.0) / 2.0
_inches_per_point = 1.0 * 72.27
def icml2022_half(**kwargs):
"""Double-column (half-width) figures for ICML 2022."""
return _icml2022_and_aistats2022_half(**kwargs)
def icml2022_full(**kwargs):
"""Single-column (full-width) figures for I... |
"""
1: Client Message
2: Phase1A
3: Phase1B
4: Phase2A
5: Phase2B
6: Decision
7: Leader
8: Catchup
9: Catchup_Answer
"""
class Message:
def __init__(self, msg_type, message=0, instance=0, iid=0, c_rnd=0, c_val=0, rnd=0,
v_val=0, v_rnd=0, current_leader=0, prop_id=0, msg_memory=None,
... | """
1: Client Message
2: Phase1A
3: Phase1B
4: Phase2A
5: Phase2B
6: Decision
7: Leader
8: Catchup
9: Catchup_Answer
"""
class Message:
def __init__(self, msg_type, message=0, instance=0, iid=0, c_rnd=0, c_val=0, rnd=0, v_val=0, v_rnd=0, current_leader=0, prop_id=0, msg_memory=None, print_order=None, total_order=... |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Python for AHDA.
Part 1, Example 9.
"""
# Deduplication of a list
rhyme = ['Peter', 'Piper', 'picked', 'a', 'piece', 'of', 'pickled', 'pepper', 'A', 'piece', 'of', 'pickled', 'pepper', 'Peter', 'Piper', 'picked']
deduplicated_rhyme = set(rhyme)
print(deduplicated_rhy... | """Python for AHDA.
Part 1, Example 9.
"""
rhyme = ['Peter', 'Piper', 'picked', 'a', 'piece', 'of', 'pickled', 'pepper', 'A', 'piece', 'of', 'pickled', 'pepper', 'Peter', 'Piper', 'picked']
deduplicated_rhyme = set(rhyme)
print(deduplicated_rhyme) |
class Solution:
# @param {int[]} nums an integer array
# @return nothing, do this in-place
def moveZeroes(self, nums):
# Write your code here
i = 0
for j in xrange(len(nums)):
if nums[j]:
num = nums[j]
nums[j] = 0
nums[i] = ... | class Solution:
def move_zeroes(self, nums):
i = 0
for j in xrange(len(nums)):
if nums[j]:
num = nums[j]
nums[j] = 0
nums[i] = num
i += 1 |
''' key-value methods in dictionary '''
# Keys
key_dictionary = {
'sector': 'Keys method',
'variable': 'dictionary'
}
print(key_dictionary.keys())
# Values
value_dictionary = {
'sector': 'Values method',
'variable': 'dictionary'
}
print(value_dictionary.values())
# Key-value
key_value_dictionary =... | """ key-value methods in dictionary """
key_dictionary = {'sector': 'Keys method', 'variable': 'dictionary'}
print(key_dictionary.keys())
value_dictionary = {'sector': 'Values method', 'variable': 'dictionary'}
print(value_dictionary.values())
key_value_dictionary = {'sector': 'key-value method', 'variable': 'dictionar... |
for _ in range(int(input())):
tr = int(input())
ram_task = list(map(int, input().split(' ')))
dr = int(input())
ram_dare = list(map(int, input().split(' ')))
ts = int(input())
sham_task = list(map(int, input().split(' ')))
ds = int(input())
sham_dare = list(map(int, input().split(' ')))
... | for _ in range(int(input())):
tr = int(input())
ram_task = list(map(int, input().split(' ')))
dr = int(input())
ram_dare = list(map(int, input().split(' ')))
ts = int(input())
sham_task = list(map(int, input().split(' ')))
ds = int(input())
sham_dare = list(map(int, input().split(' ')))
... |
q1 = 1
q2 = -2
q3 = 4
state = (q1, q2, q3)
state = (-state[0], -state[1], -state[2])
#str(state[0]) = '33'
print(state) | q1 = 1
q2 = -2
q3 = 4
state = (q1, q2, q3)
state = (-state[0], -state[1], -state[2])
print(state) |
def dfs(at, graph, visited):
if visited[at]:
return
visited[at] = True
print(at, end=" -> ")
neighbours = graph[at]
for next in neighbours:
dfs(next, graph, visited)
if __name__ == "__main__":
n = int(input("No. of Nodes : "))
graph = []
for i in range(n):
graph... | def dfs(at, graph, visited):
if visited[at]:
return
visited[at] = True
print(at, end=' -> ')
neighbours = graph[at]
for next in neighbours:
dfs(next, graph, visited)
if __name__ == '__main__':
n = int(input('No. of Nodes : '))
graph = []
for i in range(n):
graph.a... |
load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "ACTION_NAMES")
load(
"@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl",
"feature",
"flag_group",
"flag_set",
"tool_path",
)
all_link_actions = [
ACTION_NAMES.cpp_link_executable,
ACTION_NAMES.cpp_link_dynamic_library,
ACTIO... | load('@bazel_tools//tools/build_defs/cc:action_names.bzl', 'ACTION_NAMES')
load('@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl', 'feature', 'flag_group', 'flag_set', 'tool_path')
all_link_actions = [ACTION_NAMES.cpp_link_executable, ACTION_NAMES.cpp_link_dynamic_library, ACTION_NAMES.cpp_link_nodeps_dynamic_libra... |
class Solution:
"""
@param nums: A list of integers
@return: A integer indicate the sum of max subarray
"""
def maxSubArray(self, nums):
n = len(nums)
prefixSum = [0 for _ in range(n + 1)]
minIdx = 0
largeSum = -sys.maxsize - 1
for i in range(1, n + 1):
... | class Solution:
"""
@param nums: A list of integers
@return: A integer indicate the sum of max subarray
"""
def max_sub_array(self, nums):
n = len(nums)
prefix_sum = [0 for _ in range(n + 1)]
min_idx = 0
large_sum = -sys.maxsize - 1
for i in range(1, n + 1):
... |
def predicate(h, n):
'''
Returns True if we can build a triangle of height h using n coins, else returns False
'''
return h*(h+1)//2 <= n
t = int(input())
for __ in range(t):
n = int(input())
# binary search for the greatest height which can be reached using n coins
lo = 0
hi = n
wh... | def predicate(h, n):
"""
Returns True if we can build a triangle of height h using n coins, else returns False
"""
return h * (h + 1) // 2 <= n
t = int(input())
for __ in range(t):
n = int(input())
lo = 0
hi = n
while lo < hi:
mid = lo + (hi - lo + 1) // 2
if predicate(mi... |
class Solution:
def hammingDistance(self, x: int, y: int) -> int:
count = 0
for i in range(30, -1, -1):
mask = 1 << i
digitX = x & mask
digitY = y & mask
if digitX != digitY:
count += 1
return count | class Solution:
def hamming_distance(self, x: int, y: int) -> int:
count = 0
for i in range(30, -1, -1):
mask = 1 << i
digit_x = x & mask
digit_y = y & mask
if digitX != digitY:
count += 1
return count |
# https://javl.github.io/image2cpp/
# 40x40
CALENDAR_40_40 = bytearray([
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x1c, 0x00, 0x00,
0x38, 0x00, 0x1c, 0x00, 0x00, 0x3c, 0x00, 0x1c, 0x00, 0x01, 0xff, 0xff, 0xff, 0x80, 0x03, 0xff,
0xff, 0xff, 0xc0, 0x07, 0xff, 0xff, 0xff,... | calendar_40_40 = bytearray([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 56, 0, 28, 0, 0, 56, 0, 28, 0, 0, 60, 0, 28, 0, 1, 255, 255, 255, 128, 3, 255, 255, 255, 192, 7, 255, 255, 255, 224, 7, 255, 255, 255, 224, 7, 255, 255, 255, 224, 7, 255, 255, 255, 224, 7, 255, 255, 255, 224, 7, 255, 255, 255, 224, 7, 128, 0, 1, 224, 7, 0, 0,... |
class Category:
"""
Categories of vehicles sold.
"""
NEW = "new"
DEMO = "demo"
USED = "preowned"
class VehicleType:
"""
Types of vehicles sold.
"""
CARGO_VAN = "CARGO VAN"
CAR = "Car"
SUV = "SUV"
TRUCK = "Truck"
VAN = "Van"
| class Category:
"""
Categories of vehicles sold.
"""
new = 'new'
demo = 'demo'
used = 'preowned'
class Vehicletype:
"""
Types of vehicles sold.
"""
cargo_van = 'CARGO VAN'
car = 'Car'
suv = 'SUV'
truck = 'Truck'
van = 'Van' |
class BaseObject(object):
"""
A base class to provide common features to all models.
"""
| class Baseobject(object):
"""
A base class to provide common features to all models.
""" |
expected_output = {
"interfaces": {
"GigabitEthernet1/0/17": {
"mac_address": {
"0024.9bff.0ac8": {
"acct_session_id": "0x0000008d",
"common_session_id": "0A8628020000007168945FE6",
"current_policy": "Test_DOT1X-DEFAULT_... | expected_output = {'interfaces': {'GigabitEthernet1/0/17': {'mac_address': {'0024.9bff.0ac8': {'acct_session_id': '0x0000008d', 'common_session_id': '0A8628020000007168945FE6', 'current_policy': 'Test_DOT1X-DEFAULT_V1', 'domain': 'DATA', 'handle': '0x86000067', 'iif_id': '0x1534B4E2', 'ipv4_address': 'Unknown', 'ipv6_a... |
def my_plot(df, case_type, case_thres=50000):
m = Basemap(projection='cyl')
m.fillcontinents(color='peru', alpha=0.3)
groupby_columns = ['Country/Region', 'Province/State', 'Lat', 'Long']
max_num_cases = df[case_type].max()
for k, g in df.groupby(groupby_columns):
country_region, provi... | def my_plot(df, case_type, case_thres=50000):
m = basemap(projection='cyl')
m.fillcontinents(color='peru', alpha=0.3)
groupby_columns = ['Country/Region', 'Province/State', 'Lat', 'Long']
max_num_cases = df[case_type].max()
for (k, g) in df.groupby(groupby_columns):
(country_region, province... |
class Review:
all_reviews = []
def __init__(self,news_id,title,name,author,description,url, urlToImage,publishedAt,content):
self.new_id = new_id
self.title = title
self.name= name
self.author=author
self.description=description
self.url=link
self. urlT... | class Review:
all_reviews = []
def __init__(self, news_id, title, name, author, description, url, urlToImage, publishedAt, content):
self.new_id = new_id
self.title = title
self.name = name
self.author = author
self.description = description
self.url = link
... |
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""HMC5883L: Surface-mount, multi-chip module designed for low-field magnetic sensing with a digital interface for applications such as lowcost compassing and magnetometry"""
__author__ = "ChISL"
__copyright__ = "TBD"
__credits__ = ["Honeywell"]
__license__ = "... | """HMC5883L: Surface-mount, multi-chip module designed for low-field magnetic sensing with a digital interface for applications such as lowcost compassing and magnetometry"""
__author__ = 'ChISL'
__copyright__ = 'TBD'
__credits__ = ['Honeywell']
__license__ = 'TBD'
__version__ = 'Version 0.1'
__maintainer__ = 'https://... |
class Solution:
def countBits(self, num: int) -> List[int]:
ans=[]
for i in range(num+1):
ans.append(bin(i).count('1'))
return ans
| class Solution:
def count_bits(self, num: int) -> List[int]:
ans = []
for i in range(num + 1):
ans.append(bin(i).count('1'))
return ans |
def change(img2_head_mask, img2, cv2, convexhull2, result):
(x, y, w, h) = cv2.boundingRect(convexhull2)
center_face2 = (int((x + x + w) / 2), int((y + y + h) / 2))
#can change it to Mix_clone
seamlessclone = cv2.seamlessClone(result, img2, img2_head_mask, center_face2, cv2.NORMAL_CLONE)
re... | def change(img2_head_mask, img2, cv2, convexhull2, result):
(x, y, w, h) = cv2.boundingRect(convexhull2)
center_face2 = (int((x + x + w) / 2), int((y + y + h) / 2))
seamlessclone = cv2.seamlessClone(result, img2, img2_head_mask, center_face2, cv2.NORMAL_CLONE)
return seamlessclone |
# Created by MechAviv
# Map ID :: 100000000
# NPC ID :: 9110000
# Perry
maps = [["Showa Town", 100000000], ["Ninja Castle", 100000000], ["Six Path Crossway", 100000000]]# TODO
sm.setSpeakerID(9110000)
selection = sm.sendNext("Welcome! Where to?\r\n#L0# To Showa Town#l\r\n#L1# To Ninja Castle#l\r\n#L2# To Six Path Cross... | maps = [['Showa Town', 100000000], ['Ninja Castle', 100000000], ['Six Path Crossway', 100000000]]
sm.setSpeakerID(9110000)
selection = sm.sendNext('Welcome! Where to?\r\n#L0# To Showa Town#l\r\n#L1# To Ninja Castle#l\r\n#L2# To Six Path Crossway#l')
sm.setSpeakerID(9110000)
if sm.sendAskYesNo(maps[selection][0] + '? Dr... |
'''input
98 56
Worse
12 34
Better
'''
# -*- coding: utf-8 -*-
# AtCoder Beginner Contest
# Problem A
if __name__ == '__main__':
x, y = list(map(int, input().split()))
if x < y:
print('Better')
else:
print('Worse')
| """input
98 56
Worse
12 34
Better
"""
if __name__ == '__main__':
(x, y) = list(map(int, input().split()))
if x < y:
print('Better')
else:
print('Worse') |
INVALID_ARGUMENT = 'invalid argument'
PERMISSION_DENIED = 'permission denied'
UNKNOWN = 'unknown'
NOT_FOUND = 'not found'
INTERNAL = 'internal error'
TOO_MANY_REQUESTS = 'too many requests'
SERVER_UNAVAILABLE = 'service unavailable'
BAD_REQUEST = 'bad request'
AUTH_ERROR = 'authorization error'
class TRError(Exceptio... | invalid_argument = 'invalid argument'
permission_denied = 'permission denied'
unknown = 'unknown'
not_found = 'not found'
internal = 'internal error'
too_many_requests = 'too many requests'
server_unavailable = 'service unavailable'
bad_request = 'bad request'
auth_error = 'authorization error'
class Trerror(Exception... |
"""This module contains rules for the startup c library."""
load("//lib/bazel:c_rules.bzl", "makani_c_library")
def _get_linkopts(ld_files):
return (["-Tavionics/firmware/startup/" + f for f in ld_files])
def startup_c_library(name, deps = [], ld_files = [], linkopts = [], **kwargs):
makani_c_library(
... | """This module contains rules for the startup c library."""
load('//lib/bazel:c_rules.bzl', 'makani_c_library')
def _get_linkopts(ld_files):
return ['-Tavionics/firmware/startup/' + f for f in ld_files]
def startup_c_library(name, deps=[], ld_files=[], linkopts=[], **kwargs):
makani_c_library(name=name, deps=... |
DATA = [
{"gender":"male","name":{"title":"mr","first":"brian","last":"watts"},"location":{"street":"8966 preston rd","city":"des moines","state":"virginia","postcode":15835},"dob":"1977-03-11 11:43:34","id":{"name":"SSN","value":"003-73-8821"},"picture":{"large":"https://randomuser.me/api/portraits/men/68.jpg","medium... | data = [{'gender': 'male', 'name': {'title': 'mr', 'first': 'brian', 'last': 'watts'}, 'location': {'street': '8966 preston rd', 'city': 'des moines', 'state': 'virginia', 'postcode': 15835}, 'dob': '1977-03-11 11:43:34', 'id': {'name': 'SSN', 'value': '003-73-8821'}, 'picture': {'large': 'https://randomuser.me/api/por... |
def init() -> None:
pass
def run(raw_data: list) -> list:
return [{"result": "Hello World"}]
| def init() -> None:
pass
def run(raw_data: list) -> list:
return [{'result': 'Hello World'}] |
def can_build(env, platform):
return platform=="android"
def configure(env):
if (env['platform'] == 'android'):
env.android_add_java_dir("android")
env.android_add_res_dir("res")
env.android_add_asset_dir("assets")
env.android_add_dependency("implementation files('../../../modules/oppo/android/libs/... | def can_build(env, platform):
return platform == 'android'
def configure(env):
if env['platform'] == 'android':
env.android_add_java_dir('android')
env.android_add_res_dir('res')
env.android_add_asset_dir('assets')
env.android_add_dependency("implementation files('../../../modul... |
# -*- coding: utf-8 -*-
def main():
r, c, d = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(r)]
ans = 0
# See:
# https://www.slideshare.net/chokudai/arc023
for y in range(r):
for x in range(c):
if (x + y <= d) and ((x + y) % 2 ==... | def main():
(r, c, d) = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(r)]
ans = 0
for y in range(r):
for x in range(c):
if x + y <= d and (x + y) % 2 == d % 2:
ans = max(ans, a[y][x])
print(ans)
if __name__ == '__main__':
main() |
""" LECTURE D'UN FICHIER TEXTE """
"""
QUESTION 1
"""
with open("texte1", "r+") as f:
print(f.read(11), end="\n\n")
"""
QUESTION 2
"""
with open("texte1", "r+") as f:
print(f.readline(), end="\n\n")
f.readline()
print(f.readline(), end="\n\n")
"""
QUESTION 3
"""
with open("texte1", "r+") ... | """ LECTURE D'UN FICHIER TEXTE """
'\n QUESTION 1\n'
with open('texte1', 'r+') as f:
print(f.read(11), end='\n\n')
'\n QUESTION 2\n'
with open('texte1', 'r+') as f:
print(f.readline(), end='\n\n')
f.readline()
print(f.readline(), end='\n\n')
'\n QUESTION 3\n'
with open('texte1', 'r+') as f:
... |
#https://leetcode.com/problems/largest-rectangle-in-histogram/
#(Asked in Amazon SDE1 interview)
class Solution:
def largestRectangleArea(self, heights: List[int]) -> int:
sta,finalL=[],[]
it=0
for i in heights: #code for next smallest left
it+=1
if st... | class Solution:
def largest_rectangle_area(self, heights: List[int]) -> int:
(sta, final_l) = ([], [])
it = 0
for i in heights:
it += 1
if sta:
while sta and i <= sta[-1][1]:
sta.pop()
if not sta:
... |
"""
A simple program to calculate a chaotic function.
This program will calculate the first ten values of a chaotic
function with the form k(x)(1-x) where k=3.9 and x is provided
by the user.
"""
def main():
"""
Calculate the values of the chaotic function.
"""
x = float(input("Enter a number between ... | """
A simple program to calculate a chaotic function.
This program will calculate the first ten values of a chaotic
function with the form k(x)(1-x) where k=3.9 and x is provided
by the user.
"""
def main():
"""
Calculate the values of the chaotic function.
"""
x = float(input('Enter a number between ... |
class AppSettings:
types = {
'url': str,
'requestIntegration': bool,
'authURL': str,
'usernameField': str,
'passwordField': str,
'buttonField': str,
'extraFieldSelector': str,
'extraFieldValue': str,
'optionalField1': str,
'optionalFie... | class Appsettings:
types = {'url': str, 'requestIntegration': bool, 'authURL': str, 'usernameField': str, 'passwordField': str, 'buttonField': str, 'extraFieldSelector': str, 'extraFieldValue': str, 'optionalField1': str, 'optionalField1Value': str, 'optionalField2': str, 'optionalField2Value': str, 'optionalField3... |
class WikiPage:
def __init__(self, title, uri=None, text=None, tags=None):
self.title = title
self.text = text or ""
self.tags = tags or {}
self.uri = uri or title
self.parents = []
self.children = []
def add_child(self, page):
self.children... | class Wikipage:
def __init__(self, title, uri=None, text=None, tags=None):
self.title = title
self.text = text or ''
self.tags = tags or {}
self.uri = uri or title
self.parents = []
self.children = []
def add_child(self, page):
self.children.append(page)... |
numbers = [12, 18, 128, 48, 2348, 21, 18, 3, 2, 42, 96, 11, 42, 12, 18]
print(numbers)
# Insert the number 5 to the beginning of the list.
numbers.insert(0, 5)
print(numbers)
# Remove the number 2348 based on its value (as opposed to a hard-coded index of 4) from the list.
numbers.remove(2348)
print(numbers)
# Creat... | numbers = [12, 18, 128, 48, 2348, 21, 18, 3, 2, 42, 96, 11, 42, 12, 18]
print(numbers)
numbers.insert(0, 5)
print(numbers)
numbers.remove(2348)
print(numbers)
more_numbers = [1, 2, 3, 4, 5]
numbers.extend(more_numbers)
print(numbers)
numbers.sort()
print(numbers)
numbers.sort(reverse=True)
print(numbers)
count = number... |
class pbox_description:
def __init__(self, pdb_id):
self.pdb_id = pdb_id
def get_pdb_id(self):
return self.pdb_id
| class Pbox_Description:
def __init__(self, pdb_id):
self.pdb_id = pdb_id
def get_pdb_id(self):
return self.pdb_id |
# Getting an input from the user
x = int(input("How tall do you want your pyramid to be? "))
while x < 0 or x > 23:
x = int(input("Provide a number greater than 0 and smaller than 23: "))
for i in range(x):
z = i+1 # counts the number of blocks in the pyramid in each iteration
y = x-i # counts the num... | x = int(input('How tall do you want your pyramid to be? '))
while x < 0 or x > 23:
x = int(input('Provide a number greater than 0 and smaller than 23: '))
for i in range(x):
z = i + 1
y = x - i
print(' ' * y + '#' * z + ' ' + '#' * z) |
class Solution:
def reverseOnlyLetters(self, s: str) -> str:
i = 0
j = len(s)-1
m = list(range(65, 91))+list(range(97, 123))
while i < j:
if ord(s[i]) not in m:
i += 1
continue
if ord(s[j]) not in m:
j -= 1
... | class Solution:
def reverse_only_letters(self, s: str) -> str:
i = 0
j = len(s) - 1
m = list(range(65, 91)) + list(range(97, 123))
while i < j:
if ord(s[i]) not in m:
i += 1
continue
if ord(s[j]) not in m:
j -= ... |
'''Returns unmodifiable sets of "uninteresting" (e.g., not drug like) ligands.
References
----------
- `D3R Project <https://github.com/drugdata/D3R/blob/master/d3r/filter/filtering_sets.py`_
'''
METAL_CONTAINING = set(['CP', 'NFU', 'NFR', 'NFE', 'NFV', 'FSO', 'WCC', 'TCN', 'FS2',
'PDV', 'CPT... | """Returns unmodifiable sets of "uninteresting" (e.g., not drug like) ligands.
References
----------
- `D3R Project <https://github.com/drugdata/D3R/blob/master/d3r/filter/filtering_sets.py`_
"""
metal_containing = set(['CP', 'NFU', 'NFR', 'NFE', 'NFV', 'FSO', 'WCC', 'TCN', 'FS2', 'PDV', 'CPT', 'OEC', 'XCC', 'NFS', '... |
#!/usr/bin/env python
# Copyright 2018 National Technology & Engineering Solutions of Sandia, LLC
# (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S.
# Government retains certain rights in this software.
class ResultsWriters:
def __init__(self):
""
self.writers = []
def... | class Resultswriters:
def __init__(self):
""""""
self.writers = []
def add_writer(self, writer):
""""""
self.writers.append(writer)
def prerun(self, atestlist, rtinfo, verbosity):
""""""
for wr in self.writers:
wr.prerun(atestlist, rtinfo, verbo... |
# -*- coding: utf-8 -*-
"""
Created on Tue Oct 30 00:36:25 2018
@author: Ja4rsPC
"""
x = int(input('Please input integer 1:' ))
y = int(input('Please input integer 2: '))
def maxVAlue(m,n):
if m>n or m==n:
return m
else:
return n
print(maxVAlue(x,y), ' Is greatest')
#Scoping
def f(x):
... | """
Created on Tue Oct 30 00:36:25 2018
@author: Ja4rsPC
"""
x = int(input('Please input integer 1:'))
y = int(input('Please input integer 2: '))
def max_v_alue(m, n):
if m > n or m == n:
return m
else:
return n
print(max_v_alue(x, y), ' Is greatest')
def f(x):
y = 1
x = x + y
pri... |
n = int(input())
s = []
for i in range(n):
s.append(input())
# [d1, d2, d3, ..., dN]
m = []
a = []
r = []
c = []
h = []
for i in s:
if i[0] == "M":
m.append(i)
elif i[0] == "A":
a.append(i)
elif i[0] == "R":
r.append(i)
elif i[0] == "C":
c.append(i)
elif i[0] == "... | n = int(input())
s = []
for i in range(n):
s.append(input())
m = []
a = []
r = []
c = []
h = []
for i in s:
if i[0] == 'M':
m.append(i)
elif i[0] == 'A':
a.append(i)
elif i[0] == 'R':
r.append(i)
elif i[0] == 'C':
c.append(i)
elif i[0] == 'H':
h.append(i)
... |
"""
Problem statement:
We are given with N coins having value val_1 ... val_n , where n is even.
We are playing a game with an opponent in alternating turns.
In each particular turm one player selects one or last coin.
We remove the coin from the row and get the value of the coin.
Find the max possinle amoint of m... | """
Problem statement:
We are given with N coins having value val_1 ... val_n , where n is even.
We are playing a game with an opponent in alternating turns.
In each particular turm one player selects one or last coin.
We remove the coin from the row and get the value of the coin.
Find the max possinle amoint of m... |
# Section 9.3.2 snippets
with open('accounts.txt', mode='r') as accounts:
print(f'{"Account":<10}{"Name":<10}{"Balance":>10}')
for record in accounts:
account, name, balance = record.split()
print(f'{account:<10}{name:<10}{balance:>10}')
#############################################... | with open('accounts.txt', mode='r') as accounts:
print(f"{'Account':<10}{'Name':<10}{'Balance':>10}")
for record in accounts:
(account, name, balance) = record.split()
print(f'{account:<10}{name:<10}{balance:>10}') |
"""Core module of the project."""
def add(x: int, y: int) -> int:
"""Add two int numbers."""
return x + y
| """Core module of the project."""
def add(x: int, y: int) -> int:
"""Add two int numbers."""
return x + y |
"""misc utils for training neural networks"""
class HyperParameterScheduler(object):
def __init__(self, initial_val, num_updates, final_val=None, func='linear', gamma=0.999):
""" Initialize HyperParameter Scheduler class
:param initial_val: initial value of the hyper-parameter
:pa... | """misc utils for training neural networks"""
class Hyperparameterscheduler(object):
def __init__(self, initial_val, num_updates, final_val=None, func='linear', gamma=0.999):
""" Initialize HyperParameter Scheduler class
:param initial_val: initial value of the hyper-parameter
:param num_... |
#Array of numbers
numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
#Prints out every number in array
for number in numbers:
print(number)
print('')
#Adds 1 to every number in array
for number in numbers:
number += 20
print(number) | numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
for number in numbers:
print(number)
print('')
for number in numbers:
number += 20
print(number) |
# Wrong answer 10%
name = input()
YESnames = []
NOnames = []
first = ""
biggestName = 0
habay = ""
while name != "FIM":
name, choice = name.split()
if choice == "YES":
if first == "":
first = name
l = len(name)
if biggestName < l:
biggestName = l
if ... | name = input()
ye_snames = []
n_onames = []
first = ''
biggest_name = 0
habay = ''
while name != 'FIM':
(name, choice) = name.split()
if choice == 'YES':
if first == '':
first = name
l = len(name)
if biggestName < l:
biggest_name = l
if name not in YESname... |
# -*- coding: utf-8 -*-
__author__ = 'Huang, Hua'
class CSV:
def __init__(self, csv_line, sep):
self.csv_line = csv_line
self.content_list = csv_line.split(sep) if csv_line and isinstance(csv_line, str) else None
def get_property(self, ind):
if self.content_list and len(self.content_l... | __author__ = 'Huang, Hua'
class Csv:
def __init__(self, csv_line, sep):
self.csv_line = csv_line
self.content_list = csv_line.split(sep) if csv_line and isinstance(csv_line, str) else None
def get_property(self, ind):
if self.content_list and len(self.content_list) > ind:
... |
pi = {
"00": {
"value": "00",
"description": "Base"
},
"02": {
"value": "02",
"description": "POS"
}
}
| pi = {'00': {'value': '00', 'description': 'Base'}, '02': {'value': '02', 'description': 'POS'}} |
class IntervalSchedulingInterval:
"""interval to schedule in interval scheduling"""
def __init__(self, name: str, start_time: int, end_time: int):
self.name = name
self.start_time = start_time
self.end_time = end_time
def __repr__(self) -> str:
return f"{self.name}({self.st... | class Intervalschedulinginterval:
"""interval to schedule in interval scheduling"""
def __init__(self, name: str, start_time: int, end_time: int):
self.name = name
self.start_time = start_time
self.end_time = end_time
def __repr__(self) -> str:
return f'{self.name}({self.st... |
#decorators for functions
def audio_record_thread(func):
def inner(s):
print("AudioCapture: Started Recording Audio")
func(s)
print("AudioCapture: Stopped Recording Audio")
return
return inner
def file_saving(func, filename):
def wrap(s, filename):
print("Saving... | def audio_record_thread(func):
def inner(s):
print('AudioCapture: Started Recording Audio')
func(s)
print('AudioCapture: Stopped Recording Audio')
return
return inner
def file_saving(func, filename):
def wrap(s, filename):
print('Saving file...')
func(s, fi... |
# -*- coding: utf-8 -*-
"""
----------Phenix Labs----------
Created on Sat Jan 23 23:47:00 2021
@author: Gyan Krishna
Topic:
"""
n = 6
#pattern 1
for i in range(n):
for j in range(n-i):
print("", end=" ")
for j in range(i):
print("*", end=" ")
print("")
print("\n\n")
#pattern 2
curr = ... | """
----------Phenix Labs----------
Created on Sat Jan 23 23:47:00 2021
@author: Gyan Krishna
Topic:
"""
n = 6
for i in range(n):
for j in range(n - i):
print('', end=' ')
for j in range(i):
print('*', end=' ')
print('')
print('\n\n')
curr = []
prev = [1]
for i in range(n):
print('', en... |
# In case of ASCII horror,
# need to get rid of this in the future.
def ascii_saver(s):
try:
s = s.encode('ascii', errors='ignore')
except:
print('ascii cannot save', s)
return s
| def ascii_saver(s):
try:
s = s.encode('ascii', errors='ignore')
except:
print('ascii cannot save', s)
return s |
'''
Python program to round a fl oating-point number to specifi ednumber decimal places
'''
#Sample Solution-1:
def setListOfIntegerOptionOne (order_amt):
print('\nThe total order amount comes to %f' % float(order_amt))
print('The total order amount comes to %.2f' % float(order_amt))
print()
def setLis... | """
Python program to round a fl oating-point number to specifi ednumber decimal places
"""
def set_list_of_integer_option_one(order_amt):
print('\nThe total order amount comes to %f' % float(order_amt))
print('The total order amount comes to %.2f' % float(order_amt))
print()
def set_list_of_integer_optio... |
# -*- coding: utf-8 -*-
"""
Created on Thu Jan 16 11:07:19 2020
@author: 766810
"""
x=int(input('Enter number 1: '))
y=int(input('Enter number 2: '))
sum1=0
sum2=0
for i in range(1,x):
if x%i==0:
sum1+=i
for j in range(1,y):
if y%j==0:
sum2+=j
if(sum1==y and sum2==x):
pri... | """
Created on Thu Jan 16 11:07:19 2020
@author: 766810
"""
x = int(input('Enter number 1: '))
y = int(input('Enter number 2: '))
sum1 = 0
sum2 = 0
for i in range(1, x):
if x % i == 0:
sum1 += i
for j in range(1, y):
if y % j == 0:
sum2 += j
if sum1 == y and sum2 == x:
print('Amicable!')
el... |
class Solution(object):
def lengthLongestPath(self, input):
"""
:type input: str
:rtype: int
"""
maxLen = 0
curLen = 0
stack = []
dfa = {"init": 0, "char": 1, "escapeCMD": 2, "file": 3}
state = 0
start = 0
level = 0
... | class Solution(object):
def length_longest_path(self, input):
"""
:type input: str
:rtype: int
"""
max_len = 0
cur_len = 0
stack = []
dfa = {'init': 0, 'char': 1, 'escapeCMD': 2, 'file': 3}
state = 0
start = 0
level = 0
... |
class PermissionsMixin:
@classmethod
def get_permissions(cls, info):
return [permission(info) for permission in cls._meta.permission_classes]
@classmethod
def check_permissions(cls, info):
for permission in cls.get_permissions(info):
if not permission.has_permission():
... | class Permissionsmixin:
@classmethod
def get_permissions(cls, info):
return [permission(info) for permission in cls._meta.permission_classes]
@classmethod
def check_permissions(cls, info):
for permission in cls.get_permissions(info):
if not permission.has_permission():
... |
"""
Project version and meta informations.
"""
__version__ = "0.3.6dev2"
__title__ = "msiempy"
__description__ = "msiempy - McAfee SIEM API Python wrapper"
__author__ = "andywalden, tristanlatr, mathieubeland, and other contributors. "
__author_email__ = ""
__license__ = "The MIT License"
__url__ = "https://github.com... | """
Project version and meta informations.
"""
__version__ = '0.3.6dev2'
__title__ = 'msiempy'
__description__ = 'msiempy - McAfee SIEM API Python wrapper'
__author__ = 'andywalden, tristanlatr, mathieubeland, and other contributors. '
__author_email__ = ''
__license__ = 'The MIT License'
__url__ = 'https://github.com/... |
def bs(arr,target,s,e):
if (s>e):
return -1
m= int((s+e)/2)
if arr[m]==target:
return m
elif target>arr[m]:
return bs(arr,target,m+1,e)
else:
return bs(arr,target,s,m-1)
if __name__ == "__main__":
l1=[1, 2, 3, 4, 55, 66, 78]
target = 67
print(bs(l1,... | def bs(arr, target, s, e):
if s > e:
return -1
m = int((s + e) / 2)
if arr[m] == target:
return m
elif target > arr[m]:
return bs(arr, target, m + 1, e)
else:
return bs(arr, target, s, m - 1)
if __name__ == '__main__':
l1 = [1, 2, 3, 4, 55, 66, 78]
target = 67... |
#!/usr/bin/env python
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
command += testshade("-g 16 16 -od uint8 -o Cout out0.tif wrcloud")
command += testshade("-g 16 16 -od uint8 -o Cout out0_tr... | command += testshade('-g 16 16 -od uint8 -o Cout out0.tif wrcloud')
command += testshade('-g 16 16 -od uint8 -o Cout out0_transpose.tif wrcloud_transpose')
command += testshade('-g 16 16 -od uint8 -o Cout out0_varying_filename.tif wrcloud_varying_filename')
command += testshade('-g 256 256 -param radius 0.01 -od uint8 ... |
PARAM_DESCR = {
'epochs': 'How many epochs to train.',
'learning rate': 'Optimizer learning rate.',
'batch size': 'The number of samples to use in one training batch.',
'decay': 'Learning rate decay.',
'early stopping': 'Early stopping delta and patience.',
'dropout': 'Dropout rate.',
'layer... | param_descr = {'epochs': 'How many epochs to train.', 'learning rate': 'Optimizer learning rate.', 'batch size': 'The number of samples to use in one training batch.', 'decay': 'Learning rate decay.', 'early stopping': 'Early stopping delta and patience.', 'dropout': 'Dropout rate.', 'layers': 'The number of hidden lay... |
"""Problem 2 - Paying Debt Off in a Year
Now write a program that calculates the minimum fixed monthly payment needed in order pay off a credit card balance within 12 months. By a fixed monthly payment, we mean a single number which does not change each month, but instead is a constant amount that will be paid each mon... | """Problem 2 - Paying Debt Off in a Year
Now write a program that calculates the minimum fixed monthly payment needed in order pay off a credit card balance within 12 months. By a fixed monthly payment, we mean a single number which does not change each month, but instead is a constant amount that will be paid each mon... |
def username_generator(first,last):
counter = 0
username = ""
for i in first:
if counter <= 2:
counter += 1
username += i
counter = 0
for j in last:
if counter <= 3:
counter += 1
username += j
return username
def password_generator(username="testin"):
password = ""
count... | def username_generator(first, last):
counter = 0
username = ''
for i in first:
if counter <= 2:
counter += 1
username += i
counter = 0
for j in last:
if counter <= 3:
counter += 1
username += j
return username
def password_generato... |
# -*- coding: utf-8 -*-
class Controller(object):
def __init__(self, router, view):
self.router = router
self.view = view
def show(self):
if self.view:
self.view.show()
else:
raise Exception("None view")
def hide(self):
if self.view:
... | class Controller(object):
def __init__(self, router, view):
self.router = router
self.view = view
def show(self):
if self.view:
self.view.show()
else:
raise exception('None view')
def hide(self):
if self.view:
self.view.hide()
... |
def geometric_eq(p,k):
return (1-p)**k*p
class GeometricDist:
def __init__(self,p):
self.p = p
self.mean = (1-p)/p
self.var = (1-p)/p**2
def __getitem__(self,k):
return geometric_eq(self.p,k) | def geometric_eq(p, k):
return (1 - p) ** k * p
class Geometricdist:
def __init__(self, p):
self.p = p
self.mean = (1 - p) / p
self.var = (1 - p) / p ** 2
def __getitem__(self, k):
return geometric_eq(self.p, k) |
class letterCombinations:
def letterCombinationsFn(self, digits: str) -> List[str]:
# If the input is empty, immediately return an empty answer array
if len(digits) == 0:
return []
# Map all the digits to their corresponding letters
letters = {"2": "abc", "3": "... | class Lettercombinations:
def letter_combinations_fn(self, digits: str) -> List[str]:
if len(digits) == 0:
return []
letters = {'2': 'abc', '3': 'def', '4': 'ghi', '5': 'jkl', '6': 'mno', '7': 'pqrs', '8': 'tuv', '9': 'wxyz'}
def backtrack(index, path):
if len(path)... |
class Solution:
def uniquePaths(self, m: int, n: int) -> int:
dp = [[0]*n for i in range(m)]
for i in range(m):
dp[i][n-1] = 1
for i in range(n):
dp[m-1][i] = 1
for i in range(m-2,-1,-1):
for j in range(n-2,-1,-1):
... | class Solution:
def unique_paths(self, m: int, n: int) -> int:
dp = [[0] * n for i in range(m)]
for i in range(m):
dp[i][n - 1] = 1
for i in range(n):
dp[m - 1][i] = 1
for i in range(m - 2, -1, -1):
for j in range(n - 2, -1, -1):
d... |
n,m = list(map(int,input().split(' ')))
coins = list(map(int,input().split(' ')))
dp =[ [-1 for x in range(m+1)] for y in range(n+1) ]
def getCount(amount,index):
if amount == 0:
return 1
if index == 1:
coin = coins[0]
if amount%coin == 0:
return 1
else:
r... | (n, m) = list(map(int, input().split(' ')))
coins = list(map(int, input().split(' ')))
dp = [[-1 for x in range(m + 1)] for y in range(n + 1)]
def get_count(amount, index):
if amount == 0:
return 1
if index == 1:
coin = coins[0]
if amount % coin == 0:
return 1
else:
... |
class TableNotFound:
def title(self):
return "Table Not Found"
def description(self):
return "You are trying to make a query on a table that cannot be found. Check that :table migration exists and that migrations have been ran with 'python craft migrate' command."
def regex(self):
... | class Tablenotfound:
def title(self):
return 'Table Not Found'
def description(self):
return "You are trying to make a query on a table that cannot be found. Check that :table migration exists and that migrations have been ran with 'python craft migrate' command."
def regex(self):
... |
c.NotebookApp.ip = '*'
c.NotebookApp.token = ''
c.NotebookApp.password = ''
c.NotebookApp.open_browser = False
c.NotebookApp.port = 8081
c.NotebookApp.allow_remote_access = True
c.NotebookApp.allow_origin_pat = '(^https://8081-dot-[0-9]+-dot-devshell\.appspot\.com$)|(^https://colab\.research\.google\.com$)'
| c.NotebookApp.ip = '*'
c.NotebookApp.token = ''
c.NotebookApp.password = ''
c.NotebookApp.open_browser = False
c.NotebookApp.port = 8081
c.NotebookApp.allow_remote_access = True
c.NotebookApp.allow_origin_pat = '(^https://8081-dot-[0-9]+-dot-devshell\\.appspot\\.com$)|(^https://colab\\.research\\.google\\.com$)' |
prova1 = float ( input())
prova2 = float ( input ())
prova3 = float (input ())
media = (((prova1 * 2.0) + (prova2 * 3.0) + (prova3 * 5.0)) / 10 )
print("MEDIA = %0.1F" % media )
| prova1 = float(input())
prova2 = float(input())
prova3 = float(input())
media = (prova1 * 2.0 + prova2 * 3.0 + prova3 * 5.0) / 10
print('MEDIA = %0.1F' % media) |
# https://www.codechef.com/problems/DEVUGRAP
for T in range(int(input())):
N,K=map(int,input().split())
n,ans=list(map(int,input().split())),0
for i in range(N):
if(n[i]>=K): ans+=min(n[i]%K,K-n[i]%K)
else: ans+=K-n[i]%K
print(ans) | for t in range(int(input())):
(n, k) = map(int, input().split())
(n, ans) = (list(map(int, input().split())), 0)
for i in range(N):
if n[i] >= K:
ans += min(n[i] % K, K - n[i] % K)
else:
ans += K - n[i] % K
print(ans) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.