content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
class FourCal:
def setdata(self, first, second):
self.first = first
self.second = second
def sum(self):
result = self.first + self.second
return result
def sub(self):
result = self.first - self.second
return result
def mul(self):
re... | class Fourcal:
def setdata(self, first, second):
self.first = first
self.second = second
def sum(self):
result = self.first + self.second
return result
def sub(self):
result = self.first - self.second
return result
def mul(self):
result = self.... |
# Copyright 2016 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
{
'targets': [
# {
# 'target_name': 'files_icon_button',
# 'includes': ['../../../compile_js2.gypi'],
# },
# {
# 'target_name': 'fil... | {'targets': []} |
"""
[issue2]
$ echo TEST1
. # doctest: +ELLIPSIS
T...ST1
$ echo TEST2
. # doctest: +ELLIPSIS
...EST2
"""
| """
[issue2]
$ echo TEST1
. # doctest: +ELLIPSIS
T...ST1
$ echo TEST2
. # doctest: +ELLIPSIS
...EST2
""" |
# sample function to get a prediction from the model
def getPrediction(text):
if type(text) is str:
return len(text)
else:
return -1
| def get_prediction(text):
if type(text) is str:
return len(text)
else:
return -1 |
"""
Find the contiguous subarray within an array (containing at least one number) which has the largest sum.
For example, given the array [-2,1,-3,4,-1,2,1,-5,4],
the contiguous subarray [4,-1,2,1] has the largest sum = 6.
click to show more practice.
More practice:
If you have figured out the O(n) solution, try cod... | """
Find the contiguous subarray within an array (containing at least one number) which has the largest sum.
For example, given the array [-2,1,-3,4,-1,2,1,-5,4],
the contiguous subarray [4,-1,2,1] has the largest sum = 6.
click to show more practice.
More practice:
If you have figured out the O(n) solution, try cod... |
# -*- coding: utf-8 -*-
"""
559. Maximum Depth of N-ary Tree
Given a n-ary tree, find its maximum depth.
The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.
Nary-Tree input serialization is represented in their level order traversal,
each group of childr... | """
559. Maximum Depth of N-ary Tree
Given a n-ary tree, find its maximum depth.
The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.
Nary-Tree input serialization is represented in their level order traversal,
each group of children is separated by the n... |
notas = [[['A', 'E', 'I', 'O', 'U', 'L', 'N', 'R', 'S', 'T'], 1],
[['D', 'G'], 2],
[['B', 'C', 'M', 'P'], 3],
[['F', 'H', 'V', 'W', 'Y'], 4],
[['K'], 5],
[['J', 'X'], 8],
[['Q', 'Z'], 10]]
def score(word):
total = 0
word = word.upper()
for letra in wo... | notas = [[['A', 'E', 'I', 'O', 'U', 'L', 'N', 'R', 'S', 'T'], 1], [['D', 'G'], 2], [['B', 'C', 'M', 'P'], 3], [['F', 'H', 'V', 'W', 'Y'], 4], [['K'], 5], [['J', 'X'], 8], [['Q', 'Z'], 10]]
def score(word):
total = 0
word = word.upper()
for letra in word:
for n in notas:
if letra in n[0]... |
"""Commands for chooks.py."""
__all__ = [
'add',
'disable',
'execute',
'install',
'list',
'remove',
]
| """Commands for chooks.py."""
__all__ = ['add', 'disable', 'execute', 'install', 'list', 'remove'] |
def splitDate(date):
splitup = date.split('.')
return splitup[1], splitup[0], splitup[2]
| def split_date(date):
splitup = date.split('.')
return (splitup[1], splitup[0], splitup[2]) |
class StyleSelector(object):
"""
Provides a way to apply styles based on custom logic.
StyleSelector()
"""
def SelectStyle(self,item,container):
"""
SelectStyle(self: StyleSelector,item: object,container: DependencyObject) -> Style
When overridden in a derived class,returns a System.W... | class Styleselector(object):
"""
Provides a way to apply styles based on custom logic.
StyleSelector()
"""
def select_style(self, item, container):
"""
SelectStyle(self: StyleSelector,item: object,container: DependencyObject) -> Style
When overridden in a derived class,returns a System... |
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the... | includes = '\n#include <openssl/bn.h>\n'
types = "\ntypedef ... BIGNUM;\n/*\n * TODO: This typedef is wrong.\n *\n * This is due to limitations of cffi.\n * See https://bitbucket.org/cffi/cffi/issue/69\n *\n * For another possible work-around (not used here because it involves more\n * complicated use of the cffi API w... |
class Solution:
def searchInsert(self, nums: List[int], target: int) -> int:
for x in range(len(nums)):
if nums[x] >= target:
return x
return (len(nums)) | class Solution:
def search_insert(self, nums: List[int], target: int) -> int:
for x in range(len(nums)):
if nums[x] >= target:
return x
return len(nums) |
#!/usr/bin/python
class TOSSerialReceptionError:
def __init__(self, chaine = "Vide"):
self.ch = chaine;
def __str__(self):
return self.ch;
class TOSSerialPacket:
"""Data structure that defines the content of a serial packet"""
def __init__(self):
messageType = 0;
dest = 0;
src = 0;
len = 0;
group ... | class Tosserialreceptionerror:
def __init__(self, chaine='Vide'):
self.ch = chaine
def __str__(self):
return self.ch
class Tosserialpacket:
"""Data structure that defines the content of a serial packet"""
def __init__(self):
message_type = 0
dest = 0
src = 0
... |
# -*- coding: utf-8 -*-
__author__ = "venkat"
__author_email__ = "venkatram0273@gmail.com"
# def comments_and_doc_strings() -> None:
# """
# These are multi-line comments.
# Used to document specific information about the function.
# These are called docstrings as well and can be accessed through func... | __author__ = 'venkat'
__author_email__ = 'venkatram0273@gmail.com' |
"""
List of 3rd party test dependencies. Generated by bazel-deps.
"""
def list_dependencies():
return [
{
"bind_args": {
"actual": "@com_typesafe_play_twirl_api_2_11",
"name": "jar/com/typesafe/play/twirl_api_2_11"
},
"import_args": {
... | """
List of 3rd party test dependencies. Generated by bazel-deps.
"""
def list_dependencies():
return [{'bind_args': {'actual': '@com_typesafe_play_twirl_api_2_11', 'name': 'jar/com/typesafe/play/twirl_api_2_11'}, 'import_args': {'default_visibility': ['//visibility:public'], 'exports': ['@org_scala_lang_modules_s... |
# -*- coding: utf-8 -*-
'''
File name: code\nontransitive_sets_of_dice\sol_376.py
Author: Vaidic Joshi
Date created: Oct 20, 2018
Python Version: 3.x
'''
# Solution to Project Euler Problem #376 :: Nontransitive sets of dice
#
# For more information see:
# https://projecteuler.net/problem=376
# Prob... | """
File name: code
ontransitive_sets_of_dice\\sol_376.py
Author: Vaidic Joshi
Date created: Oct 20, 2018
Python Version: 3.x
"""
'\nConsider the following set of dice with nonstandard pips:\n\n\n\nDie A: 1 4 4 4 4 4\nDie B: 2 2 2 5 5 5\nDie C: 3 3 3 3 3 6\n\n\nA game is played by two players picking a ... |
def gcd(m,n):
while n>0:
t=m%n
m=n
n=t
return m
input();A=list(map(int,input().split()))
input();B=list(map(int,input().split()))
AA=1; BB=1
for i in A: AA*=i
for i in B: BB*=i
result=gcd(AA,BB)
if result >= 10**9: print("%09d" % (result%(10**9)))
else: print(result) | def gcd(m, n):
while n > 0:
t = m % n
m = n
n = t
return m
input()
a = list(map(int, input().split()))
input()
b = list(map(int, input().split()))
aa = 1
bb = 1
for i in A:
aa *= i
for i in B:
bb *= i
result = gcd(AA, BB)
if result >= 10 ** 9:
print('%09d' % (result % 10 ** 9... |
"""
Scenarios:
Parameters (some/all/None) -> reduce
Result (1, 2) -> reduce
Combinations of above -> reduce
Filter[parameter],Filter[result],Filter[parameter+result],None
= (3 + 2 + 6) * 4 = 44 tests
test: data recovered (shape,dtype, values), description recovered, tasks marked as complete, locations in index, subse... | """
Scenarios:
Parameters (some/all/None) -> reduce
Result (1, 2) -> reduce
Combinations of above -> reduce
Filter[parameter],Filter[result],Filter[parameter+result],None
= (3 + 2 + 6) * 4 = 44 tests
test: data recovered (shape,dtype, values), description recovered, tasks marked as complete, locations in index, subset... |
def title_card(code_name):
print('\n~~~~~~~~~~~~~~~~~~~~~~~')
print(code_name)
print('~~~~~~~~~~~~~~~~~~~~~~~ \n')
| def title_card(code_name):
print('\n~~~~~~~~~~~~~~~~~~~~~~~')
print(code_name)
print('~~~~~~~~~~~~~~~~~~~~~~~ \n') |
# 155. Min Stack
# ttungl@gmail.com
class MinStack(object):
# using list array
# runtime: 72 ms
def __init__(self):
self.stack = []
def push(self, x):
if not self.stack:
self.stack.append((x, x))
else:
self.stack.append((x, min(x, self.stack[-1][1]))) # keep track o... | class Minstack(object):
def __init__(self):
self.stack = []
def push(self, x):
if not self.stack:
self.stack.append((x, x))
else:
self.stack.append((x, min(x, self.stack[-1][1])))
def pop(self):
if self.stack:
self.stack.pop()
def t... |
def check_similar_sequences(sequences):
"""
takes a dictionary of sequences, removes the gaps and checks which sequences are similar
return a dictionary of a group number as key and the similar sequence id as a list as vlaue
:param sequences: a dictionary of sequences
:return groups: a dictionary o... | def check_similar_sequences(sequences):
"""
takes a dictionary of sequences, removes the gaps and checks which sequences are similar
return a dictionary of a group number as key and the similar sequence id as a list as vlaue
:param sequences: a dictionary of sequences
:return groups: a dictionary o... |
# -*- coding: utf-8 -*-
# Copyright 2013 Lyft
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to... | """General information about Amazon Web Services, such as region-to-endpoint
mappings.
"""
ec2_instance_type_to_compute_units = {'c1.medium': 5, 'c1.xlarge': 20, 'c3.2xlarge': 28, 'c3.4xlarge': 55, 'c3.8xlarge': 108, 'c3.large': 7, 'c3.xlarge': 14, 'c4.2xlarge': 31, 'c4.4xlarge': 62, 'c4.8xlarge': 132, 'c4.large': 8, '... |
class Solution(object):
def pivotIndex(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
if not nums: return -1
N = len(nums)
sums = [0] * (N + 1)
for i in range(N):
sums[i + 1] = sums[i] + nums[i]
for i in range(N):
... | class Solution(object):
def pivot_index(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
if not nums:
return -1
n = len(nums)
sums = [0] * (N + 1)
for i in range(N):
sums[i + 1] = sums[i] + nums[i]
for i in range(... |
# This file contains defaults that this module uses
# Max allowed for assumed safe request, any higher than this
# Will raise a RateLimitReached Exception
# If the rate limiter cant assume a safe request
# Due to the assumption being to risky at this point
max_safe_requests = 40
# quater of safe requests
max_ongoing... | max_safe_requests = 40
max_ongoing_requests = 10
ratelimit_max = 40
ratelimit_within = 30
ratelimit_maxsleeps = 90
ratelimit_sleep_time = 0.5 |
x = 10
def foo(x):
y = x * 2
return bar(y)
def bar(y):
y = x / 2
return y
z = foo(x)
| x = 10
def foo(x):
y = x * 2
return bar(y)
def bar(y):
y = x / 2
return y
z = foo(x) |
# Copyright (c) 2020 Vishnu J. Seesahai
# Use of this source code is governed by an MIT
# license that can be found in the LICENSE file.
MIN_CONF = '6'
MAX_CONF = '9999999'
| min_conf = '6'
max_conf = '9999999' |
class Solution(object):
def generatePalindromes(self, s):
"""
:type s: str
:rtype: List[str]
"""
dic = {}
half = []
res = []
for c in s:
dic[c] = dic.get(c, 0) + 1
odd, even = 0, 0
for c in dic:
if dic[c] % 2 == ... | class Solution(object):
def generate_palindromes(self, s):
"""
:type s: str
:rtype: List[str]
"""
dic = {}
half = []
res = []
for c in s:
dic[c] = dic.get(c, 0) + 1
(odd, even) = (0, 0)
for c in dic:
if dic[c] %... |
class Node:
def __init__(self, item, next):
self.item = item
self.next = next
class Stack:
def __init__(self):
self.last = None
def push(self, item):
self.last = Node(item, self.last)
def pop(self):
item = self.last.item
self.last = self.last.next
... | class Node:
def __init__(self, item, next):
self.item = item
self.next = next
class Stack:
def __init__(self):
self.last = None
def push(self, item):
self.last = node(item, self.last)
def pop(self):
item = self.last.item
self.last = self.last.next
... |
class Solution:
def findPeakElement(self, nums: List[int]) -> int:
# dfs solution to solve this problem
nums = [-float('inf')] + nums + [-float('inf')]
lo, hi = 0, len(nums)-1
while lo < hi:
mid = (lo+hi)//2
if nums[mid] > nums[mid-1] and nums[mid] > ... | class Solution:
def find_peak_element(self, nums: List[int]) -> int:
nums = [-float('inf')] + nums + [-float('inf')]
(lo, hi) = (0, len(nums) - 1)
while lo < hi:
mid = (lo + hi) // 2
if nums[mid] > nums[mid - 1] and nums[mid] > nums[mid + 1]:
return m... |
"""
Unit Tests for lfs library
"""
__author__ = 'Stephen Brown (Little Fish Solutions LTD)'
| """
Unit Tests for lfs library
"""
__author__ = 'Stephen Brown (Little Fish Solutions LTD)' |
# __init__.py
# Copyright 2011 Roger Marsh
# Licence: See LICENCE (BSD licence)
"""results berkelelydb interface.
"""
| """results berkelelydb interface.
""" |
a = 2 < 3
b = 2 + 4
c = (1 <= 2 ) and (1 <= 3)
x = 1 + 2 * 3
y = 1 * 2 + 3
x = 2+3 < 2+1 or 2 < 3 and not not True
y = not True and False | a = 2 < 3
b = 2 + 4
c = 1 <= 2 and 1 <= 3
x = 1 + 2 * 3
y = 1 * 2 + 3
x = 2 + 3 < 2 + 1 or (2 < 3 and (not not True))
y = not True and False |
class deque:
def __init__(self):
self.items=[]
def isEmpty(self):
return self.item==[]
def addRear(self,item):
self.items.append(item)
def addFront(self,item):
self.items.insert(0,item)
def removeFront(self):
return self.pop()
def removeRear(self):
... | class Deque:
def __init__(self):
self.items = []
def is_empty(self):
return self.item == []
def add_rear(self, item):
self.items.append(item)
def add_front(self, item):
self.items.insert(0, item)
def remove_front(self):
return self.pop()
def remove_r... |
class Solution:
def smallerNumbersThanCurrent(self, nums: List[int]) -> List[int]:
x=[]
for i in nums:
x.append(sum([1 for y in nums if y<i]))
return x
| class Solution:
def smaller_numbers_than_current(self, nums: List[int]) -> List[int]:
x = []
for i in nums:
x.append(sum([1 for y in nums if y < i]))
return x |
def score_submission(submission):
# first remove existing leaderboard entries
# read in scores dictionary, ex:
# scoring_program_output = {
# "RESULTS": [
# ("Score", 1),
# ],
# "ALTERNATE_RESULTS": [
# ("Score", 2),
# (... | def score_submission(submission):
pass |
'''
Write a function, gooseFilter / goose-filter / goose_filter / GooseFilter, that
takes an array of strings as an argument and returns a filtered array
containing the same elements but with the 'geese' removed.
The geese are any strings in the following array, which is pre-populated in
your solution:
geese = ["Afri... | """
Write a function, gooseFilter / goose-filter / goose_filter / GooseFilter, that
takes an array of strings as an argument and returns a filtered array
containing the same elements but with the 'geese' removed.
The geese are any strings in the following array, which is pre-populated in
your solution:
geese = ["Afri... |
# -*- coding: utf-8 -*-
"""Top-level package for deploy_ova."""
__author__ = """Michael Palmer"""
__email__ = 'palmertime@gmail.com'
__version__ = '0.1.0'
| """Top-level package for deploy_ova."""
__author__ = 'Michael Palmer'
__email__ = 'palmertime@gmail.com'
__version__ = '0.1.0' |
# Copyright 2018 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, s... | def gen_box(image_width, image_height, size, step, zoom_step, skip=1):
zoom = 1.0
cnt = 0
boxes = []
while zoom <= min(image_width, image_height):
s = size * zoom
x = 0.0
while x + s <= image_width:
y = 0.0
while y + s <= image_height:
if c... |
# Variables can be used to hold information.
# Integer-type
initial_amount = 100
# Float-type
interest_rate = 5.0
# Integer-type
num_of_years = 7
# The type of "final_amount" must be deduced from the number-types in the expression.
# The type of "final_amount" will be the least precise type that's involved in the c... | initial_amount = 100
interest_rate = 5.0
num_of_years = 7
final_amount = initial_amount * (1 + interest_rate / 100) ** num_of_years
print(f'After {num_of_years} years, {initial_amount} has grown to {final_amount:.2f}.') |
#
# Author VinhLH <vinh.le@zalora.com>
# Copyright Mar 2016
#
# Configs
host = ''
port = 8888
workDir = '/Users/vinhlh/Works/test'
log = 'server.log' | host = ''
port = 8888
work_dir = '/Users/vinhlh/Works/test'
log = 'server.log' |
def register(mf):
mf.register_defaults({
"fuzzy": __file__,
"fuzzychild_nonunique": __file__
})
| def register(mf):
mf.register_defaults({'fuzzy': __file__, 'fuzzychild_nonunique': __file__}) |
"""Integration tests for the pyWriter project.
Test helper module.
For further information see https://github.com/peter88213/PyWriter
Published under the MIT License (https://opensource.org/licenses/mit-license.php)
"""
def read_file(inputFile):
try:
with open(inputFile, 'r', encoding='utf-8'... | """Integration tests for the pyWriter project.
Test helper module.
For further information see https://github.com/peter88213/PyWriter
Published under the MIT License (https://opensource.org/licenses/mit-license.php)
"""
def read_file(inputFile):
try:
with open(inputFile, 'r', encoding='utf-8') as f:
... |
# !/usr/bin/env python3
# Author: C.K
# Email: theck17@163.com
# DateTime:2021-09-14 21:20:08
# Description:
class Solution:
def fractionToDecimal(self, numerator: int, denominator: int) -> str:
if numerator % denominator == 0:
return str(numerator // denominator)
sign = '' if numerator ... | class Solution:
def fraction_to_decimal(self, numerator: int, denominator: int) -> str:
if numerator % denominator == 0:
return str(numerator // denominator)
sign = '' if numerator * denominator >= 0 else '-'
(numerator, denominator) = (abs(numerator), abs(denominator))
... |
valor = int(input())
print('{}'.format(valor))
numero100 = valor//100
print('{} nota(s) de R$ 100,00'.format(numero100))
valor -= numero100*100 #valor - valor (menos ele mesmo)
numero50 = valor//50
print('{} nota(s) de R$ 50,00'.format(numero50))
valor -= numero50*50
numero20 = valor//20
print('{} nota(s) de R$ 20,... | valor = int(input())
print('{}'.format(valor))
numero100 = valor // 100
print('{} nota(s) de R$ 100,00'.format(numero100))
valor -= numero100 * 100
numero50 = valor // 50
print('{} nota(s) de R$ 50,00'.format(numero50))
valor -= numero50 * 50
numero20 = valor // 20
print('{} nota(s) de R$ 20,00'.format(numero20))
valor... |
def func_read_in_pattern_file(pattern_file_path):
pattern_dict = {}
with open(pattern_file_path, 'r') as file:
for line in file:
line_lst = line.strip().split(",")
pattern_dict[line_lst[0]] = [line_lst[1], line_lst[2], line_lst[3], line_lst[4]]
return pattern_dict | def func_read_in_pattern_file(pattern_file_path):
pattern_dict = {}
with open(pattern_file_path, 'r') as file:
for line in file:
line_lst = line.strip().split(',')
pattern_dict[line_lst[0]] = [line_lst[1], line_lst[2], line_lst[3], line_lst[4]]
return pattern_dict |
# Copyright (c) 2015 Google Inc. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
{
'targets': [
{
'target_name': 'test_default',
'type': 'executable',
'sources': ['hello.cc'],
},
{
'target_name'... | {'targets': [{'target_name': 'test_default', 'type': 'executable', 'sources': ['hello.cc']}, {'target_name': 'test_set_reserved_size', 'type': 'executable', 'sources': ['hello.cc'], 'msvs_settings': {'VCLinkerTool': {'StackReserveSize': 2097152}}}, {'target_name': 'test_set_commit_size', 'type': 'executable', 'sources'... |
test_input_1 = """\
8 8
WBWBWBWB
BWBWBWBW
WBWBWBWB
BWBBBWBW
WBWBWBWB
BWBWBWBW
WBWBWBWB
BWBWBWBW
"""
test_input_2 = """\
10 13
BBBBBBBBWBWBW
BBBBBBBBBWBWB
BBBBBBBBWBWBW
BBBBBBBBBWBWB
BBBBBBBBWBWBW
BBBBBBBBBWBWB
BBBBBBBBWBWBW
BBBBBBBBBWBWB
WWWWWWWWWWBWB
WWWWWWWWWWBWB
"""
test_input_3 = """\
8 8
BWBWBWBW
WBWBWBWB
BWBWBW... | test_input_1 = '8 8\nWBWBWBWB\nBWBWBWBW\nWBWBWBWB\nBWBBBWBW\nWBWBWBWB\nBWBWBWBW\nWBWBWBWB\nBWBWBWBW\n'
test_input_2 = '10 13\nBBBBBBBBWBWBW\nBBBBBBBBBWBWB\nBBBBBBBBWBWBW\nBBBBBBBBBWBWB\nBBBBBBBBWBWBW\nBBBBBBBBBWBWB\nBBBBBBBBWBWBW\nBBBBBBBBBWBWB\nWWWWWWWWWWBWB\nWWWWWWWWWWBWB\n'
test_input_3 = '8 8\nBWBWBWBW\nWBWBWBWB\nB... |
# Write a small program to ask for a name and an age.
# When both values have been entered, check if the person
# is the right age to go on an 18-30 holiday (they must be
# over 18 and under 31).
# If they are, welcome them to the holiday, otherwise print
# a (polite) message refusing them entry.
name = input("Please e... | name = input('Please enter your name: ')
age = int(input('How old are you, {0}? '.format(name)))
if age >= 18 and age < 31:
print('Welcome to club 18-30 holidays, {0}'.format(name))
else:
print("I'm sorry, our holidays are only for seriously cool people") |
class Phone:
def __init__(self, str):
str = ''.join([x for x in str if x in '0123456789'])
if len(str) == 10:
self.number = str
elif len(str) == 11 and str[0] == '1':
self.number = str[1:]
else:
raise ValueError('bad format')
self.... | class Phone:
def __init__(self, str):
str = ''.join([x for x in str if x in '0123456789'])
if len(str) == 10:
self.number = str
elif len(str) == 11 and str[0] == '1':
self.number = str[1:]
else:
raise value_error('bad format')
self.area_co... |
ABI_ENDPOINT = "https://api.etherscan.io/api?module=contract&action=getabi&address="
POLYGON_ABI_ENDPOINT = (
"https://api.polygonscan.com/api?module=contract&action=getabi&address="
)
ENDPOINT = ""
POLYGON_ENDPOINT = ""
ATTRIBUTES_FOLDER = "raw_attributes"
IMPLEMENTATION_SLOT = (
"0x360894a13ba1a3210667c828492... | abi_endpoint = 'https://api.etherscan.io/api?module=contract&action=getabi&address='
polygon_abi_endpoint = 'https://api.polygonscan.com/api?module=contract&action=getabi&address='
endpoint = ''
polygon_endpoint = ''
attributes_folder = 'raw_attributes'
implementation_slot = '0x360894a13ba1a3210667c828492db98dca3e2076c... |
studentdata = {}
alldata = []
studentdata['Name'] = str(input("Type the Student's name: "))
studentdata['AVGRADE'] = float(input("Type the Average Grade of the Student: "))
if studentdata['AVGRADE'] < 5:
studentdata['Situation'] = ("Reproved")
elif studentdata['AVGRADE'] > 5 and studentdata['AVGRADE'] < 7:
stud... | studentdata = {}
alldata = []
studentdata['Name'] = str(input("Type the Student's name: "))
studentdata['AVGRADE'] = float(input('Type the Average Grade of the Student: '))
if studentdata['AVGRADE'] < 5:
studentdata['Situation'] = 'Reproved'
elif studentdata['AVGRADE'] > 5 and studentdata['AVGRADE'] < 7:
studen... |
# -*- coding: utf-8 -*-
f = open(filename)
char = f.read(1)
while char:
process(char)
char = f.read(1)
f.close()
| f = open(filename)
char = f.read(1)
while char:
process(char)
char = f.read(1)
f.close() |
b = str(input()).split()
d = int(b[0])
c= int(b[1])
e = '.|.'
for i in range(1,d,2):
print((e*i).center(c,'-'))
print(('WELCOME').center(c,'-'))
for i in range(d-2,-1,-2):
print((e * i).center(c, '-'))
| b = str(input()).split()
d = int(b[0])
c = int(b[1])
e = '.|.'
for i in range(1, d, 2):
print((e * i).center(c, '-'))
print('WELCOME'.center(c, '-'))
for i in range(d - 2, -1, -2):
print((e * i).center(c, '-')) |
LANGUAGE_CODE = 'ru-RU'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
| language_code = 'ru-RU'
time_zone = 'UTC'
use_i18_n = True
use_l10_n = True
use_tz = True |
fila1="abcdefghi"
fila2="jklmnopqr"
fila3="stuvwxyz"
n=int(input())
for i in range(0,n):
flag=True
palabras=input()
palabras=palabras.strip().split()
if (len(palabras[0])==len(palabras[1])):
if (palabras[0]==palabras[1]):
print("1")
pass
else:
... | fila1 = 'abcdefghi'
fila2 = 'jklmnopqr'
fila3 = 'stuvwxyz'
n = int(input())
for i in range(0, n):
flag = True
palabras = input()
palabras = palabras.strip().split()
if len(palabras[0]) == len(palabras[1]):
if palabras[0] == palabras[1]:
print('1')
pass
else:
... |
# Which of the following expressions return the infinity values?
# Suppose, the variables inf and nan have been defined.
nan = float("nan")
inf = float("inf")
print(0.0 / inf) # nan
print(inf / 2 - inf) # inf
print(100 * inf + nan) # inf
print(inf - 10 ** 300) # nan
print(-inf * inf) ... | nan = float('nan')
inf = float('inf')
print(0.0 / inf)
print(inf / 2 - inf)
print(100 * inf + nan)
print(inf - 10 ** 300)
print(-inf * inf) |
lines = open('input.txt', 'r').readlines()
# create graph
node_hash_list = dict()
node_hash_list["start"] = set()
for line in lines:
p1, p2 = line.strip().split("-")
if p2 not in node_hash_list:
node_hash_list[p2] = set()
if p1 not in node_hash_list:
node_hash_list[p1] = set()
if not... | lines = open('input.txt', 'r').readlines()
node_hash_list = dict()
node_hash_list['start'] = set()
for line in lines:
(p1, p2) = line.strip().split('-')
if p2 not in node_hash_list:
node_hash_list[p2] = set()
if p1 not in node_hash_list:
node_hash_list[p1] = set()
if not p1 == 'end' and ... |
KEY_TO_SYM = {
"ArrowLeft": "Left",
"ArrowRight": "Right",
"ArrowUp": "Up",
"ArrowDown": "Down",
"BackSpace": "BackSpace",
"Tab": "Tab",
"Enter": "Return",
# 'Shift': 'Shift_L',
# 'Control': 'Control_L',
# 'Alt': 'Alt_L',
"CapsLock": "Caps_Lock",
"Escape": "Escape",
"... | key_to_sym = {'ArrowLeft': 'Left', 'ArrowRight': 'Right', 'ArrowUp': 'Up', 'ArrowDown': 'Down', 'BackSpace': 'BackSpace', 'Tab': 'Tab', 'Enter': 'Return', 'CapsLock': 'Caps_Lock', 'Escape': 'Escape', ' ': 'space', 'PageUp': 'Prior', 'PageDown': 'Next', 'Home': 'Home', 'End': 'End', 'Delete': 'Delete', 'Insert': 'Insert... |
#!/usr/bin/env python
#coding: utf-8
# Definition for a binary tree node
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
# @param root, a tree node
# @return a list of integers
def postorderTraversal(self, root):
i... | class Treenode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def postorder_traversal(self, root):
if not root:
return []
left_l = self.postorderTraversal(root.left)
right_l = self.postorderTraversal(root.rig... |
{
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"append: 0.09872150200000007\n",
"concat: 0.10876064500000027\n",
"unpack: 0.14667600099999945\n"
]
}
],
"sourc... | {'cells': [{'cell_type': 'code', 'execution_count': 2, 'metadata': {}, 'outputs': [{'name': 'stdout', 'output_type': 'stream', 'text': ['append: 0.09872150200000007\n', 'concat: 0.10876064500000027\n', 'unpack: 0.14667600099999945\n']}], 'source': ['from timeit import timeit\n', '\n', 'append = """\n', 'array1 = [0, 1,... |
"""
CM, your case/content management system for the internet.
Copyright Alex Li 2003.
Package structure:
cm/
html/ (UI subpackages...)
htmllib/ (HTML frontend shared library)
model/ (Business Domain subpackages)
... (framework modules...such as database access,
security/permission checking, sessio... | """
CM, your case/content management system for the internet.
Copyright Alex Li 2003.
Package structure:
cm/
html/ (UI subpackages...)
htmllib/ (HTML frontend shared library)
model/ (Business Domain subpackages)
... (framework modules...such as database access,
security/permission checking, sessio... |
def method1():
a = [1, 2, 3, 4, 5]
for _ in range(1):
f = a[0]
for j in range(0, len(a) - 1):
a[j] = a[j + 1]
a[len(a) - 1] = f
return a
if __name__ == "__main__":
"""
from timeit import timeit
print(timeit(lambda: method1(), number=10000)) 0.008410404003370... | def method1():
a = [1, 2, 3, 4, 5]
for _ in range(1):
f = a[0]
for j in range(0, len(a) - 1):
a[j] = a[j + 1]
a[len(a) - 1] = f
return a
if __name__ == '__main__':
'\n from timeit import timeit\n print(timeit(lambda: method1(), number=10000)) 0.00841040400337078... |
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution:
def nodesBetweenCriticalPoints(self, head: Optional[ListNode]) -> List[int]:
# init
if head:
p1 = head
p2 = ... | class Solution:
def nodes_between_critical_points(self, head: Optional[ListNode]) -> List[int]:
if head:
p1 = head
p2 = p1.next
else:
return [-1, -1]
if p2:
p3 = p2.next
else:
return [-1, -1]
if not p3:
... |
def maak_fizzbuzz(n):
"""Zie ook: https://en.wikipedia.org/wiki/Fizz_buzz"""
for getal in range(1, n+1):
if getal % 3 == 0 and getal % 5 == 0:
print("FizzBuzz")
elif getal % 3 == 0:
print("Fizz")
elif getal % 5 == 0:
print("Buzz")
else:
... | def maak_fizzbuzz(n):
"""Zie ook: https://en.wikipedia.org/wiki/Fizz_buzz"""
for getal in range(1, n + 1):
if getal % 3 == 0 and getal % 5 == 0:
print('FizzBuzz')
elif getal % 3 == 0:
print('Fizz')
elif getal % 5 == 0:
print('Buzz')
else:
... |
# posts model
# create an empty list
posts=[]
def posts_db():
return posts | posts = []
def posts_db():
return posts |
while True:
try:
n, inSeq = int(input()), input().split()
inSeq = ''.join(inSeq)
stack = ''
def outSeq(inSeq, stack):
if len(inSeq) == 0:
return [''.join(reversed(stack))]
if len(stack) == 0:
outLater = outSeq(inSeq[1:... | while True:
try:
(n, in_seq) = (int(input()), input().split())
in_seq = ''.join(inSeq)
stack = ''
def out_seq(inSeq, stack):
if len(inSeq) == 0:
return [''.join(reversed(stack))]
if len(stack) == 0:
out_later = out_seq(inSeq[1:... |
GET_USERS = "SELECT users FROM all_users WHERE user_id = '{}'"
CREATE_MAIN_TABLE = "CREATE TABLE all_users(user_id text NOT NULL, users text NOT NULL);"
ADD_USER = "UPDATE all_users SET users = '{}' WHERE user_id = '{}'"
CREATE_USER = "INSERT INTO all_users (user_id, users) VALUES ('{}', ' ')"
GET_ALL_IDS = "SELECT... | get_users = "SELECT users FROM all_users WHERE user_id = '{}'"
create_main_table = 'CREATE TABLE all_users(user_id text NOT NULL, users text NOT NULL);'
add_user = "UPDATE all_users SET users = '{}' WHERE user_id = '{}'"
create_user = "INSERT INTO all_users (user_id, users) VALUES ('{}', ' ')"
get_all_ids = 'SELECT use... |
class Extractor:
def __str__(self):
return self.__class__.__name__
class ExtractByCommand(Extractor):
def feed(self, command):
if not hasattr(self, command['type']):
return
getattr(self, command['type'])(command)
| class Extractor:
def __str__(self):
return self.__class__.__name__
class Extractbycommand(Extractor):
def feed(self, command):
if not hasattr(self, command['type']):
return
getattr(self, command['type'])(command) |
REGISTERED_METHODS = [
"ACL",
"BASELINE-CONTROL",
"BIND",
"CHECKIN",
"CHECKOUT",
"CONNECT",
"COPY",
"DELETE",
"GET",
"HEAD",
"LABEL",
"LINK",
"LOCK",
"MERGE",
"MKACTIVITY",
"MKCALENDAR",
"MKREDIRECTREF",
"MKWORKSPACE",
"MOVE",
"OPTIONS",
... | registered_methods = ['ACL', 'BASELINE-CONTROL', 'BIND', 'CHECKIN', 'CHECKOUT', 'CONNECT', 'COPY', 'DELETE', 'GET', 'HEAD', 'LABEL', 'LINK', 'LOCK', 'MERGE', 'MKACTIVITY', 'MKCALENDAR', 'MKREDIRECTREF', 'MKWORKSPACE', 'MOVE', 'OPTIONS', 'ORDERPATCH', 'PATCH', 'POST', 'PRI', 'PROPFIND', 'PUT', 'QUERY', 'REBIND', 'REPORT... |
"""Linked list module."""
class Node:
"""Node of a linked list."""
def __init__(self, value, next = None):
self.value = value
self.next = next
class LinkedList:
"""Linked List data structure."""
def __init__(self, head = None):
self.head = head
def __iter__(self):
... | """Linked list module."""
class Node:
"""Node of a linked list."""
def __init__(self, value, next=None):
self.value = value
self.next = next
class Linkedlist:
"""Linked List data structure."""
def __init__(self, head=None):
self.head = head
def __iter__(self):
""... |
# coding=utf-8
"""Self organizing list (transpose method) Python implementation."""
class Node:
def __init__(self, key, val):
self.key = key
self.val = val
self.next = None
class SelfOrganizingList:
def __init__(self):
self.first = None
def add_node(self, key, val):
... | """Self organizing list (transpose method) Python implementation."""
class Node:
def __init__(self, key, val):
self.key = key
self.val = val
self.next = None
class Selforganizinglist:
def __init__(self):
self.first = None
def add_node(self, key, val):
if self.fir... |
def open_file():
'''Remember to put a docstring here'''
while True:
file_name = input("Input a file name: ")
try:
fp = open(file_name)
break
except FileNotFoundError:
print("Unable to open file. Please try again.")
continue
return fp
... | def open_file():
"""Remember to put a docstring here"""
while True:
file_name = input('Input a file name: ')
try:
fp = open(file_name)
break
except FileNotFoundError:
print('Unable to open file. Please try again.')
continue
return fp
d... |
class C(object):
"""Silly example!!!"""
def __init__(self):
"""XXXX"""
self._x = None
def getx(self):
return self._x
def setx(self, value):
self._x = value
def delx(self):
del self._x
x = property(getx, setx, delx, "I'm the 'x' property.")
# clas... | class C(object):
"""Silly example!!!"""
def __init__(self):
"""XXXX"""
self._x = None
def getx(self):
return self._x
def setx(self, value):
self._x = value
def delx(self):
del self._x
x = property(getx, setx, delx, "I'm the 'x' property.")
c = c()
c.x ... |
#
# https://projecteuler.net/problem=4
#
# Largest palindrome product
# Problem 4
#
# A palindromic number reads the same both ways.
# The largest palindrome made from the product of two 2-digits numers is 9009 = 91 x 99.
# Find the largest palindrome made from the product of two 3-digit numbers.
# Solution
def rever... | def reverse(a_string):
new_string = ''
index = len(a_string)
while index:
index -= 1
new_string += a_string[index]
return new_string
def is_palindrome(value):
s = str(value)
return s == reverse(s)
def problem(limit):
max_palindrome = 0
for x in range(limit):
for... |
class Player:
"""
Defines all character related attributes. Used by scripts.py.
"""
day = 0
timeofday = 6
stats = {
'name': 'Player',
'health': 100,
'speed': 1,
'intelligence': 1,
'rads': 0,
}
inventory = {
... | class Player:
"""
Defines all character related attributes. Used by scripts.py.
"""
day = 0
timeofday = 6
stats = {'name': 'Player', 'health': 100, 'speed': 1, 'intelligence': 1, 'rads': 0}
inventory = {'money': 0, 'food': 10, 'water': 10}
skills = {}
buildings = {'shelter': 0, 'shed... |
class ItemModel:
def __init__(self):
self.vowels = ['A', 'E', 'I', 'O', 'U']
self.rare_letters = ['X', 'J']
self.other_letters = ['B', 'C', 'D', 'F', 'G', 'H',
'K', 'L', 'M', 'N', 'P', 'Q',
'R', 'S', 'T', 'V', 'W', 'Y', 'Z']
... | class Itemmodel:
def __init__(self):
self.vowels = ['A', 'E', 'I', 'O', 'U']
self.rare_letters = ['X', 'J']
self.other_letters = ['B', 'C', 'D', 'F', 'G', 'H', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'V', 'W', 'Y', 'Z']
self.items = [{'id': 1, 'name': 'A', 'costs': {'amount': 1... |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Python for AHDA.
Part 4, Example 1.
Please rename:
'sample_thomas_moore_download.txt'
to:
'Moore.txt'
"""
# Cut a subset of a file
F_IN = 'Moore.txt'
F_106 = 'Moore_106.txt'
F_4170 = 'Moore_4170.txt'
# by slicing a string
with open(F_IN, 'r', encoding='utf-8',... | """Python for AHDA.
Part 4, Example 1.
Please rename:
'sample_thomas_moore_download.txt'
to:
'Moore.txt'
"""
f_in = 'Moore.txt'
f_106 = 'Moore_106.txt'
f_4170 = 'Moore_4170.txt'
with open(F_IN, 'r', encoding='utf-8', newline='\n') as f_in:
raw_text = f_in.read()
with open(F_4170, 'w', encoding='utf-8', newlin... |
#-*-coding:utf-8-*-
def bmi(w, h):
bmi = (w/(h**2))*10000.0
if bmi<15.0 :
str = "VSU"
elif bmi<16.0:
str = "SUN"
elif bmi<18.5:
str = "UND"
elif bmi<25.0:
str = "NOR"
elif bmi<30.0:
str = "OVE"
elif bmi<35.0:
str = "MOV"
elif bmi<40.0:
... | def bmi(w, h):
bmi = w / h ** 2 * 10000.0
if bmi < 15.0:
str = 'VSU'
elif bmi < 16.0:
str = 'SUN'
elif bmi < 18.5:
str = 'UND'
elif bmi < 25.0:
str = 'NOR'
elif bmi < 30.0:
str = 'OVE'
elif bmi < 35.0:
str = 'MOV'
elif bmi < 40.0:
s... |
"""
Add riverwalls to the domain
Gareth Davies, Geoscience Australia 2014+
"""
def setup_riverwalls(domain, project):
# #########################################################################
#
# Add Riverwalls [ must happen after distribute(domain) in parallel ]
#
# #####################... | """
Add riverwalls to the domain
Gareth Davies, Geoscience Australia 2014+
"""
def setup_riverwalls(domain, project):
if not project.riverwalls == {}:
domain.riverwallData.create_riverwalls(project.riverwalls, project.riverwall_par)
domain.riverwallData.export_riverwalls_to_text(output_dir=proje... |
class Block:
"""Minecraft PI block description. Can be sent to Minecraft.setBlock/s"""
def __init__(self, id, data=0):
self.id = id
self.data = data
def __cmp__(self, rhs):
return hash(self) - hash(rhs)
def __eq__(self, rhs):
return self.id == rhs.id and self.data == rh... | class Block:
"""Minecraft PI block description. Can be sent to Minecraft.setBlock/s"""
def __init__(self, id, data=0):
self.id = id
self.data = data
def __cmp__(self, rhs):
return hash(self) - hash(rhs)
def __eq__(self, rhs):
return self.id == rhs.id and self.data == r... |
"""depsgen.bzl
"""
load("@build_stack_rules_proto//rules:providers.bzl", "ProtoDependencyInfo")
def _depsgen_impl(ctx):
config_json = ctx.outputs.json
output_deps = ctx.outputs.deps
config = struct(
out = output_deps.path,
name = ctx.label.name,
deps = [dep[ProtoDependencyInfo] fo... | """depsgen.bzl
"""
load('@build_stack_rules_proto//rules:providers.bzl', 'ProtoDependencyInfo')
def _depsgen_impl(ctx):
config_json = ctx.outputs.json
output_deps = ctx.outputs.deps
config = struct(out=output_deps.path, name=ctx.label.name, deps=[dep[ProtoDependencyInfo] for dep in ctx.attr.deps])
ctx.... |
class P:
def __init__( self, name, alias ):
self.name = name # public
self.__alias = alias # private
def who(self):
print('name : ', self.name)
print('alias : ', self.__alias)
class X:
def __init__( self, x ):
self.set_x( x )
def get_x( self ):
return se... | class P:
def __init__(self, name, alias):
self.name = name
self.__alias = alias
def who(self):
print('name : ', self.name)
print('alias : ', self.__alias)
class X:
def __init__(self, x):
self.set_x(x)
def get_x(self):
return self.__x
def set_x(s... |
class search:
def __init__():
pass
def ParseSearch(request):
tab = {}
if request.len > 0:
pass
pass
def search(request):
pass
| class Search:
def __init__():
pass
def parse_search(request):
tab = {}
if request.len > 0:
pass
pass
def search(request):
pass |
a = int(input())
b = int(input())
c = int(input())
mul = str(a * b * c)
for i in range(0, 10):
count = 0
for j in mul:
if i == int(j):
count += 1
print(count)
| a = int(input())
b = int(input())
c = int(input())
mul = str(a * b * c)
for i in range(0, 10):
count = 0
for j in mul:
if i == int(j):
count += 1
print(count) |
#User function Template for python3
# https://gitlab.com/pranav/my-sprints/-/snippets/2215721
'''
Input:
a = 5, b = 5, x = 11, # dest = (5, 5), x = 11
Output:
0
|
- R -
|
(-1) * x1 + 1 * x2 = a
(-1) * y1 + 1 * y2 = b
x1 + x2 + y1 + y2 = x
TC: O(1)
SC: O(1)
---
Exponential TC algo... | """
Input:
a = 5, b = 5, x = 11, # dest = (5, 5), x = 11
Output:
0
|
- R -
|
(-1) * x1 + 1 * x2 = a
(-1) * y1 + 1 * y2 = b
x1 + x2 + y1 + y2 = x
TC: O(1)
SC: O(1)
---
Exponential TC algorithm: O(1 + 4 + 4^2 + ... + 4^x), SC: O(4^x)
1. Start from 0, 0
2. For each direction pos... |
#!/usr/bin/python3
n = int(input())
_ = input()
for i in range(n):
a = int(input())
print(a*(i+1))
| n = int(input())
_ = input()
for i in range(n):
a = int(input())
print(a * (i + 1)) |
class NanometerPixelConverter:
def __init__(self, pitch_nm: float):
self._pitch_nm = pitch_nm
def to_pixel(self, value_nm: float) -> int:
return int(value_nm / self._pitch_nm)
def to_nm(self, value_pixel: int) -> float:
return value_pixel * self._pitch_nm
| class Nanometerpixelconverter:
def __init__(self, pitch_nm: float):
self._pitch_nm = pitch_nm
def to_pixel(self, value_nm: float) -> int:
return int(value_nm / self._pitch_nm)
def to_nm(self, value_pixel: int) -> float:
return value_pixel * self._pitch_nm |
#!/usr/bin/env python
# Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
#
# Use of this source code is governed by a BSD-style license
# that can be found in the LICENSE file in the root of the source
# tree. An additional intellectual property rights grant can be found
# in the file PATENTS. ... | __author__ = 'kjellander@webrtc.org (Henrik Kjellander)'
class Datahelper(object):
"""
Helper class for managing table data.
This class does not verify the consistency of the data tables sent into it.
"""
def __init__(self, data_list, table_description, names_list, messages):
""" Initializes the... |
# 399-evaluate-division.py
#
# Copyright (C) 2019 Sang-Kil Park <likejazz@gmail.com>
# All rights reserved.
#
# This software may be modified and distributed under the terms
# of the BSD license. See the LICENSE file for details.
class Solution:
def calcEquation(self, equations: List[List[str]], values: List[float... | class Solution:
def calc_equation(self, equations: List[List[str]], values: List[float], queries: List[List[str]]) -> List[float]:
graph = {e[0]: [] for e in equations}
graph.update({e[1]: [] for e in equations})
for (k, v) in enumerate(equations):
graph[v[0]].append({v[1]: valu... |
def a_kv(n):
return n*n*(-1)**n
def sumkv(n):
return sum(map(a_kv, range(1, n+1)))
def mysum(n):
if (n % 2) == 0:
k = n / 2
print(2*k*k+k)
else:
k = (n+1) / 2
print(-2*k*k+k)
print(sumkv(1))
print(sumkv(2))
print(sumkv(3))
print(sumkv(4))
mysum(1)
mysum(2)
mysum(3)
mys... | def a_kv(n):
return n * n * (-1) ** n
def sumkv(n):
return sum(map(a_kv, range(1, n + 1)))
def mysum(n):
if n % 2 == 0:
k = n / 2
print(2 * k * k + k)
else:
k = (n + 1) / 2
print(-2 * k * k + k)
print(sumkv(1))
print(sumkv(2))
print(sumkv(3))
print(sumkv(4))
mysum(1)
my... |
"Utilities for generating starlark source code"
def _to_list_attr(list, indent_count = 0, indent_size = 4, quote_value = True):
if not list:
return "[]"
tab = " " * indent_size
indent = tab * indent_count
result = "["
for v in list:
val = "\"{}\"".format(v) if quote_value else v
... | """Utilities for generating starlark source code"""
def _to_list_attr(list, indent_count=0, indent_size=4, quote_value=True):
if not list:
return '[]'
tab = ' ' * indent_size
indent = tab * indent_count
result = '['
for v in list:
val = '"{}"'.format(v) if quote_value else v
... |
"""
File: largest_digit.py
Name: Sharlene Chen
----------------------------------
This file recursively prints the biggest digit in
5 different integers, 12345, 281, 6, -111, -9453
If your implementation is correct, you should see
5, 8, 6, 1, 9 on Console.
"""
def main():
print(find_largest_digit(12345)) # 5
p... | """
File: largest_digit.py
Name: Sharlene Chen
----------------------------------
This file recursively prints the biggest digit in
5 different integers, 12345, 281, 6, -111, -9453
If your implementation is correct, you should see
5, 8, 6, 1, 9 on Console.
"""
def main():
print(find_largest_digit(12345))
print... |
"""
Project:
Author:
"""
def is_object_has_method(obj, method_name):
assert isinstance(method_name, str)
maybe_method = getattr(obj, method_name, None)
return callable(maybe_method)
__all__ = ['is_object_has_method']
| """
Project:
Author:
"""
def is_object_has_method(obj, method_name):
assert isinstance(method_name, str)
maybe_method = getattr(obj, method_name, None)
return callable(maybe_method)
__all__ = ['is_object_has_method'] |
def init():
global originlist, ellipselist, adjmatrix, adjcoordinates, valcount,num,dim,iterate, primA
adjmatrix = [] # the adjmatrix is the list of edges that being created
adjcoordinates = []; # the adjval gives the dimension coordinates (for plotting for the nth point)
valcount = -1; # valcount keeps the nu... | def init():
global originlist, ellipselist, adjmatrix, adjcoordinates, valcount, num, dim, iterate, primA
adjmatrix = []
adjcoordinates = []
valcount = -1
prim_a = []
iterate = 100
num = 0
dim = 0 |
def add_numbers(numbers):
result = 0
for i in numbers:
result += i
#print("number =", i)
return result
result = add_numbers([1, 2, 30, 4, 5, 9])
print(result)
| def add_numbers(numbers):
result = 0
for i in numbers:
result += i
return result
result = add_numbers([1, 2, 30, 4, 5, 9])
print(result) |
target_number = 0
increment = 0
while target_number == 0:
sum1 = 0
increment += 1
for j in range(1, increment):
sum1 += j
factors = 0
for k in range(1, int(sum1**.5)+1):
if sum1 % k == 0:
factors += 1
factors = factors * 2
if factors > 500:
target_number... | target_number = 0
increment = 0
while target_number == 0:
sum1 = 0
increment += 1
for j in range(1, increment):
sum1 += j
factors = 0
for k in range(1, int(sum1 ** 0.5) + 1):
if sum1 % k == 0:
factors += 1
factors = factors * 2
if factors > 500:
target_num... |
# Jun - Dangerous Hide-and-Seek : Neglected Rocky Mountain (931000001)
if "exp1=1" not in sm.getQRValue(23007):
sm.sendNext("Eep! You found me.")
sm.sendSay("Eh, I wanted to go further into the wagon, but my head wouldn't fit.")
sm.sendSay("Did you find Ulrika and Von yet? Von is really, really good at hidi... | if 'exp1=1' not in sm.getQRValue(23007):
sm.sendNext('Eep! You found me.')
sm.sendSay("Eh, I wanted to go further into the wagon, but my head wouldn't fit.")
sm.sendSay('Did you find Ulrika and Von yet? Von is really, really good at hiding.\r\n\r\n\r\n\r\n#fUI/UIWindow2.img/QuestIcon/8/0# 5 exp')
sm.giv... |
# Create a program that asks the user to enter their name and their age.
# Print out a message addressed to them that tells them the year that they will turn 100 years old.
print("Insert your name")
name = input()
print("Insert yor age")
age_str = input()
age_int = int(age_str)
print(f"{name}, you will be {age_int+100}... | print('Insert your name')
name = input()
print('Insert yor age')
age_str = input()
age_int = int(age_str)
print(f'{name}, you will be {age_int + 100} years old in 100 years') |
""" Dependencies that are needed for jinja rules """
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
load("//tools:defs.bzl", "clean_dep")
def jinja_deps():
maybe(
http_archive,
name = "markupsafe_archive",
... | """ Dependencies that are needed for jinja rules """
load('@bazel_tools//tools/build_defs/repo:http.bzl', 'http_archive')
load('@bazel_tools//tools/build_defs/repo:utils.bzl', 'maybe')
load('//tools:defs.bzl', 'clean_dep')
def jinja_deps():
maybe(http_archive, name='markupsafe_archive', urls=['https://files.python... |
def find_player(matrix):
for r in range(len(matrix)):
for c in range(len(matrix)):
if matrix[r][c] == 'P':
return r, c
def check_valid_cell(size, r, c):
return 0 <= r < size and 0 <= c < size
string = input()
size = int(input())
field = [list(input()) for _ in range(size)... | def find_player(matrix):
for r in range(len(matrix)):
for c in range(len(matrix)):
if matrix[r][c] == 'P':
return (r, c)
def check_valid_cell(size, r, c):
return 0 <= r < size and 0 <= c < size
string = input()
size = int(input())
field = [list(input()) for _ in range(size)]... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.