content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
# -*- coding: utf-8 -*-
"""Copy of ArraysAndStrings.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1VTh-TFOWmq3uxbCvBrDfUnb6Zj5IGlG_
# Arrays and Strings
16Bits = 2Bytes
8Bit, 16Bit, 32Bit, 64Bit, 128Bit
```
[123, "hello" ]
A = ["Hello", 232, 1... | """Copy of ArraysAndStrings.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1VTh-TFOWmq3uxbCvBrDfUnb6Zj5IGlG_
# Arrays and Strings
16Bits = 2Bytes
8Bit, 16Bit, 32Bit, 64Bit, 128Bit
```
[123, "hello" ]
A = ["Hello", 232, 100]
A[0] -> @A + offest ... |
lines = ""
while True:
cur_inp = input()
lines += cur_inp + "\n"
if cur_inp == '0':
break
result = tuple(lines.split())
| lines = ''
while True:
cur_inp = input()
lines += cur_inp + '\n'
if cur_inp == '0':
break
result = tuple(lines.split()) |
s = input()
vowels = "AEIOU"
kevin, stuart = 0, 0
for i in range(len(s)):
if s[i] in vowels:
kevin += len(s) - i
else:
stuart += len(s) - i
if kevin > stuart:
print("Kevin " + str(kevin))
elif stuart > kevin:
print("Stuart " + str(stuart))
else:
print("Draw")
| s = input()
vowels = 'AEIOU'
(kevin, stuart) = (0, 0)
for i in range(len(s)):
if s[i] in vowels:
kevin += len(s) - i
else:
stuart += len(s) - i
if kevin > stuart:
print('Kevin ' + str(kevin))
elif stuart > kevin:
print('Stuart ' + str(stuart))
else:
print('Draw') |
x = 5
y = 10
z = 22
if x > y :
print ('x is greater than y')
elif x < z :
print (' x is lesser than z')
| x = 5
y = 10
z = 22
if x > y:
print('x is greater than y')
elif x < z:
print(' x is lesser than z') |
def fatorial(numero):
f = 1
for c in range(1, numero +1):
f *= c
return f | def fatorial(numero):
f = 1
for c in range(1, numero + 1):
f *= c
return f |
#!/usr/bin/python3
__author__ = 'kilroy'
# (c) 2014, WasHere Consulting, Inc.
# Written for Infinite Skills
# adding x here makes it in scope
x = 0
for i in range(1,25):
# x is in scope
x = i + x
# x is now out of scope
print(x)
| __author__ = 'kilroy'
x = 0
for i in range(1, 25):
x = i + x
print(x) |
# -*- coding: utf-8 -*-
class ResourceUnavailable(Exception):
"""Exception representing a failed request to a resource"""
def __init__(self, msg, http_response):
Exception.__init__(self)
self._msg = msg
self._status = http_response.status_code
def __str__(self):
return "%... | class Resourceunavailable(Exception):
"""Exception representing a failed request to a resource"""
def __init__(self, msg, http_response):
Exception.__init__(self)
self._msg = msg
self._status = http_response.status_code
def __str__(self):
return '%s (HTTP status: %s)' % (se... |
play = ["Rock", "Paper", "Scissors"]
computer = "Rock"
print("")
player = "Paper"
| play = ['Rock', 'Paper', 'Scissors']
computer = 'Rock'
print('')
player = 'Paper' |
# Solved manually after decompiling the input and analyzing it.
# There is already a great explanation out there, so I won't bother
# writing another one. Just have a look at the following well-
# documented code:
# https://github.com/dphilipson/advent-of-code-2021/blob/master/src/days/day24.rs
print(91699394894995)
p... | print(91699394894995)
print(51147191161261) |
"""
Application-level definitions for the zlib module.
NOT_RPYTHON
"""
class error(Exception):
"""
Raised by zlib operations.
"""
| """
Application-level definitions for the zlib module.
NOT_RPYTHON
"""
class Error(Exception):
"""
Raised by zlib operations.
""" |
_base_ = [
'../_base_/models/fcn_hr18.py', '../_base_/datasets/vaihingen.py',
'../_base_/default_runtime.py', '../_base_/schedules/schedule_40k.py'
]
evaluation = dict(interval=288, metric='mIoU', pre_eval=True, save_best='mIoU')
log_config = dict(
interval=50,
hooks=[
dict(type='TextLoggerHook'... | _base_ = ['../_base_/models/fcn_hr18.py', '../_base_/datasets/vaihingen.py', '../_base_/default_runtime.py', '../_base_/schedules/schedule_40k.py']
evaluation = dict(interval=288, metric='mIoU', pre_eval=True, save_best='mIoU')
log_config = dict(interval=50, hooks=[dict(type='TextLoggerHook', by_epoch=False), dict(type... |
"""
Python file where we store our custom exceptions for the app
"""
class InvalidPrajitura(Exception):
def __init__(self , msg):
super().__init__(msg)
class MultiplePrajitura(Exception):
def __init__(self , msg):
super().__init__(msg)
class InvalidCommand(Exception):
def __init__(self , ... | """
Python file where we store our custom exceptions for the app
"""
class Invalidprajitura(Exception):
def __init__(self, msg):
super().__init__(msg)
class Multipleprajitura(Exception):
def __init__(self, msg):
super().__init__(msg)
class Invalidcommand(Exception):
def __init__(self, ... |
"""Constant values needed for string parsing"""
intervals = {
"intervalToTuple": {
"1": (1,0),
"2": (2,2),
"b3": (3,3),
"3": (3,4),
"4": (4,5),
"b5": (5,6),
"5": (5,7),
"#5": (5,8),
"6": (6,9),
"bb7": (7,9),
"b7": (7,10),
... | """Constant values needed for string parsing"""
intervals = {'intervalToTuple': {'1': (1, 0), '2': (2, 2), 'b3': (3, 3), '3': (3, 4), '4': (4, 5), 'b5': (5, 6), '5': (5, 7), '#5': (5, 8), '6': (6, 9), 'bb7': (7, 9), 'b7': (7, 10), '7': (7, 11), '9': (9, 14), 'b9': (9, 13), '#9': (9, 15), '11': (11, 17), '#11': (11, 18)... |
def is_bouncy(number):
list_of_digits = [int(digit) for digit in str(number)]
digits_len = len(list_of_digits)
last_digit = list_of_digits[0]
increasing_count = 0
decreasing_count = 0
for digit in list_of_digits:
if digit >= last_digit:
increasing_count += 1
if digit... | def is_bouncy(number):
list_of_digits = [int(digit) for digit in str(number)]
digits_len = len(list_of_digits)
last_digit = list_of_digits[0]
increasing_count = 0
decreasing_count = 0
for digit in list_of_digits:
if digit >= last_digit:
increasing_count += 1
if digit ... |
"""**DEPRECATED** - Instead, use `@rules_rust//crate_universe:repositories.bzl"""
load(":repositories.bzl", "crate_universe_dependencies")
def crate_deps_repository(**kwargs):
# buildifier: disable=print
print("`crate_deps_repository` is deprecated. See setup instructions for how to update: https://bazelbuild... | """**DEPRECATED** - Instead, use `@rules_rust//crate_universe:repositories.bzl"""
load(':repositories.bzl', 'crate_universe_dependencies')
def crate_deps_repository(**kwargs):
print('`crate_deps_repository` is deprecated. See setup instructions for how to update: https://bazelbuild.github.io/rules_rust/crate_unive... |
"""
collection of parsers,
each module in this filetypes package is named after the extension of the file it can parse e.g. 'PAR'
"""
| """
collection of parsers,
each module in this filetypes package is named after the extension of the file it can parse e.g. 'PAR'
""" |
class Solution:
def searchMatrix(self, matrix: List[List[int]], target: int) -> bool:
Y = len(matrix)
if Y == 0: return False
X = len(matrix[0])
if X == 0: return False
lo, height = 0, Y*X-1
#binary
while lo <= height:
... | class Solution:
def search_matrix(self, matrix: List[List[int]], target: int) -> bool:
y = len(matrix)
if Y == 0:
return False
x = len(matrix[0])
if X == 0:
return False
(lo, height) = (0, Y * X - 1)
while lo <= height:
pos = (lo +... |
# 496. Next Greater Element I
# Runtime: 48 ms, faster than 71.69% of Python3 online submissions for Next Greater Element I.
# Memory Usage: 14.7 MB, less than 14.37% of Python3 online submissions for Next Greater Element I.
class Solution:
# Brute Force
def nextGreaterElement(self, nums1: list[int], nums2:... | class Solution:
def next_greater_element(self, nums1: list[int], nums2: list[int]) -> list[int]:
idx = {nums2[i]: i for i in range(len(nums2))}
res = []
for n in nums1:
found = False
for i in range(idx[n] + 1, len(nums2)):
if nums2[i] > n:
... |
# Write a program to read through a file and print the contents of the file (line by line) all
# in upper case. Executing the program will look as follows
file_handle = open('/home/sunil/OpenSource/Learning/computer-science/intro-to-programming/python-for-everyone/8-files/mbox-short.txt')
for line in file_handle:
... | file_handle = open('/home/sunil/OpenSource/Learning/computer-science/intro-to-programming/python-for-everyone/8-files/mbox-short.txt')
for line in file_handle:
print(line.upper(), end='') |
EXTRACTED = '86 90 81 87 a3 49 99 43 97 97 41 92 49 7b 41 97 7b 44 92 7b 44 96 98 a5'
flag = ''.join([chr(int(i,12)) for i in EXTRACTED.split()])
print(flag)
| extracted = '86 90 81 87 a3 49 99 43 97 97 41 92 49 7b 41 97 7b 44 92 7b 44 96 98 a5'
flag = ''.join([chr(int(i, 12)) for i in EXTRACTED.split()])
print(flag) |
text = input().lower()
searched_word = input().lower()
counter = 0
for i in range(len(text)):
if text[i:i + len(searched_word)] == searched_word:
counter += 1
print(counter)
| text = input().lower()
searched_word = input().lower()
counter = 0
for i in range(len(text)):
if text[i:i + len(searched_word)] == searched_word:
counter += 1
print(counter) |
{'application':{'type':'Application',
'name':'Minimal',
'backgrounds': [
{'type':'Background',
'name':'bgMin',
'title':'Kunden Datenbank',
'size':(502, 467),
'components': [
{'type':'RadioGroup',
'name':'sortBy',
'position':(8, 67),
'size':(134, -... | {'application': {'type': 'Application', 'name': 'Minimal', 'backgrounds': [{'type': 'Background', 'name': 'bgMin', 'title': 'Kunden Datenbank', 'size': (502, 467), 'components': [{'type': 'RadioGroup', 'name': 'sortBy', 'position': (8, 67), 'size': (134, -1), 'items': ['Name', 'Firma'], 'label': 'Sortiere nach:', 'layo... |
def foo(a=None):
if a is not None:
print('got a: ', a)
print('foo /tmp/a/b/c, 1844')
main = foo
| def foo(a=None):
if a is not None:
print('got a: ', a)
print('foo /tmp/a/b/c, 1844')
main = foo |
# Solution to Mega Contest 1 Problem: DJ WALE BABU
string = input()
while "WUBWUB" in string: string = string.replace("WUBWUB", "WUB")
string = string.replace("WUB", " ")
print(string.strip()) | string = input()
while 'WUBWUB' in string:
string = string.replace('WUBWUB', 'WUB')
string = string.replace('WUB', ' ')
print(string.strip()) |
valid_location_qualifiers = [{'text': 'oval'},
{'text': 'town centre',
'penalty_following_locality': 10},
{'text': 'recreation reserve',
'penalty_following_locality': 10},
... | valid_location_qualifiers = [{'text': 'oval'}, {'text': 'town centre', 'penalty_following_locality': 10}, {'text': 'recreation reserve', 'penalty_following_locality': 10}, {'text': 'estate'}, {'text': 's/centre'}, {'text': 'arcade'}, {'text': 'centre'}, {'text': 'pavilion'}, {'text': 'center'}, {'text': 'headquarters'}... |
try:
age = int(input('please enter age: '))
risk = 100/age
print('you are {age} years old na dhave a risk profile of {risk}')
except ValueError:
print('age cannot be non numerical')
except ZeroDivisionError:
print('division by zero is invalid') | try:
age = int(input('please enter age: '))
risk = 100 / age
print('you are {age} years old na dhave a risk profile of {risk}')
except ValueError:
print('age cannot be non numerical')
except ZeroDivisionError:
print('division by zero is invalid') |
#
# PySNMP MIB module Wellfleet-5000-CHASSIS-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/Wellfleet-5000-CHASSIS-MIB
# Produced by pysmi-0.3.4 at Wed May 1 15:39:18 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version ... | (object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, constraints_intersection, value_range_constraint, value_size_constraint, constraints_union) ... |
#
# PySNMP MIB module ENTERASYS-VRRP-EXT-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ENTERASYS-VRRP-EXT-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 18:50:36 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (d... | (object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constraint, constraints_union, single_value_constraint, value_size_constraint, constraints_intersection) ... |
def counter(endCount):
f = open("test.txt","w")
# ***User Code Below*** #
for __ in range(______):
# Non User Code
f.write(str(____)+"\n")
# User Code
print(_____)
# ***End User Code*** #
f.close | def counter(endCount):
f = open('test.txt', 'w')
for __ in range(______):
f.write(str(____) + '\n')
print(_____)
f.close |
""" File name: dfa.py
Author: Jeff Yuanbo Han (u6617017)
Date: 6 March 2018
Description: This file defines a function which reads in
a DFA described in a file and builds an appropriate datastructure.
There is also another function which takes this DFA and a w... | """ File name: dfa.py
Author: Jeff Yuanbo Han (u6617017)
Date: 6 March 2018
Description: This file defines a function which reads in
a DFA described in a file and builds an appropriate datastructure.
There is also another function which takes this DFA and a w... |
def linear_sum(S, n):
if n == 0:
return 0
return linear_sum(S, n - 1) + S[n - 1]
S = [1, 5, 8, 9, 4, 9, 3]
print(linear_sum(S, len(S)))
| def linear_sum(S, n):
if n == 0:
return 0
return linear_sum(S, n - 1) + S[n - 1]
s = [1, 5, 8, 9, 4, 9, 3]
print(linear_sum(S, len(S))) |
#Debangshu Roy
# XII - B
# 40
#WAP to display only those sentences which that start with
#"The" from the text file hello.txt
#function to add data to the file
def addData(br):
F = open("hello.txt", 'a+')
F.writelines(br)
F.close()
#function to display all the required data given in the question
def... | def add_data(br):
f = open('hello.txt', 'a+')
F.writelines(br)
F.close()
def display_data():
f = open('hello.txt', 'r+')
try:
while F:
y = F.readlines()
for i in y:
j = i.split()
for h in j:
if h == 'The':
... |
count=0
a=[7,2,9,4,5,2,5,8,3,1,9]
n=0
while(n<len(a)):
i=n
if a[i]<a[i+1] or a[i]<a[i+2]:
if a[i+1]<a[i+2]:
i=i+1
elif a[i]<a[i+2]:
i=i+2
count +=1
print(max(count)) | count = 0
a = [7, 2, 9, 4, 5, 2, 5, 8, 3, 1, 9]
n = 0
while n < len(a):
i = n
if a[i] < a[i + 1] or a[i] < a[i + 2]:
if a[i + 1] < a[i + 2]:
i = i + 1
elif a[i] < a[i + 2]:
i = i + 2
count += 1
print(max(count)) |
api_id = 3538476
api_hash = "b8889e6cb9db9df68b700da878321b90"
bot_token = "5094027680:AAETKP-L61BSdlDcvNudimlVqlw3Z9Ax7yQ"
redis_ip = "localhost"
redis_port = 6379
| api_id = 3538476
api_hash = 'b8889e6cb9db9df68b700da878321b90'
bot_token = '5094027680:AAETKP-L61BSdlDcvNudimlVqlw3Z9Ax7yQ'
redis_ip = 'localhost'
redis_port = 6379 |
# SPDX-FileCopyrightText: 2018 Scott Shawcroft for Adafruit Industries
#
# SPDX-License-Identifier: MIT
"""
Check for negative height on the BMP.
Seperated into it's own file to support builds
without longint.
"""
def negative_height_check(height):
"""Check the height return modified if negative."""
if heigh... | """
Check for negative height on the BMP.
Seperated into it's own file to support builds
without longint.
"""
def negative_height_check(height):
"""Check the height return modified if negative."""
if height > 2147483647:
return height - 4294967296
return height |
class Hook:
def __init__(self, t, location, cls, method, payload_apk_path, payload_dec_path):
"""
Create a new hook for the currently handled application.
This object contains all relevant information necessary to place the hook at the user defined location.
:param t: Ty... | class Hook:
def __init__(self, t, location, cls, method, payload_apk_path, payload_dec_path):
"""
Create a new hook for the currently handled application.
This object contains all relevant information necessary to place the hook at the user defined location.
:param t: T... |
AMQP = {"default": {"url": "amqp://localhost:5672"}}
"""
Named sets of connection arguments for AIO-Pika AMQP connection.
Use either a URL or broken out connection eg::
AMQP = {"default": {
"url": "amqp://localhost:5672",
}}
# or
AMQP = {"default": {
"host": 'localhost',
"por... | amqp = {'default': {'url': 'amqp://localhost:5672'}}
'\nNamed sets of connection arguments for AIO-Pika AMQP connection.\n\nUse either a URL or broken out connection eg::\n\n AMQP = {"default": {\n "url": "amqp://localhost:5672",\n }}\n\n # or\n\n AMQP = {"default": {\n "host": \'localhost\',\... |
n = int(input())
s = input()
d = {'4': '322', '6': '53', '8': '7222', '9': '7332'}
ans = ''
for i in s:
if i=='1' or i=='0':
continue
a = i
if i in d:
a = d[i]
ans += a
ans = list(ans)
ans = sorted(ans)[::-1]
print(''.join(ans)) | n = int(input())
s = input()
d = {'4': '322', '6': '53', '8': '7222', '9': '7332'}
ans = ''
for i in s:
if i == '1' or i == '0':
continue
a = i
if i in d:
a = d[i]
ans += a
ans = list(ans)
ans = sorted(ans)[::-1]
print(''.join(ans)) |
def get_int(val, default=None):
assert default is None or type(default) is int
try:
return int(val)
except ValueError:
return default
except TypeError:
# When val is None, list, tuple, set, dict, etc.
return default
| def get_int(val, default=None):
assert default is None or type(default) is int
try:
return int(val)
except ValueError:
return default
except TypeError:
return default |
# Python - 3.6.0
Test.expect(square_sum([1, 2]), 'squareSum did not return a value')
Test.assert_equals(square_sum([1, 2]), 5)
Test.assert_equals(square_sum([0, 3, 4, 5]), 50)
| Test.expect(square_sum([1, 2]), 'squareSum did not return a value')
Test.assert_equals(square_sum([1, 2]), 5)
Test.assert_equals(square_sum([0, 3, 4, 5]), 50) |
if __name__ == '__main__':
with open('group_members.txt', encoding='utf-8') as f:
all_members = f.read().splitlines()
with open('members_free_journal.txt', encoding='utf-8') as f:
minus_members = f.read().splitlines()
all_members_minus = [x for x in all_members if x not in minus_members]
... | if __name__ == '__main__':
with open('group_members.txt', encoding='utf-8') as f:
all_members = f.read().splitlines()
with open('members_free_journal.txt', encoding='utf-8') as f:
minus_members = f.read().splitlines()
all_members_minus = [x for x in all_members if x not in minus_members]
... |
def add_model_specific_args(parser, root_dir):
parser.add_argument(
"--train_data_file",
default=None,
type=str,
required=True,
help="The input training data file (a text file).",
)
parser.add_argument(
"--output_dir",
type=str,
required=True,
... | def add_model_specific_args(parser, root_dir):
parser.add_argument('--train_data_file', default=None, type=str, required=True, help='The input training data file (a text file).')
parser.add_argument('--output_dir', type=str, required=True, help='The output directory where the model predictions and checkpoints w... |
"""
Violation:
Except with pass
"""
class MyException(Exception):
pass
def somefunc():
try:
a = 1
except MyException:
pass # This is specific, so it should be fine
except Exception:
pass # This is broad, that's weird
def someotherfunc():
try:
a = 1
except... | """
Violation:
Except with pass
"""
class Myexception(Exception):
pass
def somefunc():
try:
a = 1
except MyException:
pass
except Exception:
pass
def someotherfunc():
try:
a = 1
except MyException:
...
except Exception:
...
class Someclass... |
op = op # pylint:disable=invalid-name,used-before-assignment
root = root # pylint:disable=invalid-name,used-before-assignment
class PreShowExtension():
def __init__(self, my_op):
self.Me = my_op
# test
self.name = my_op.name
print('name: ', self.name )
self.onStop = { 'op... | op = op
root = root
class Preshowextension:
def __init__(self, my_op):
self.Me = my_op
self.name = my_op.name
print('name: ', self.name)
self.onStop = {'operator': None, 'method': None}
self.onStart = {'operator': None, 'method': None}
self.States = ['Starting', 'St... |
class Graph():
def __init__(self):
self.numnodes = 0
self.adjacentList = {}
def addVertex(self, data): # lets us peek at the top of element without removing it from the stack
if data not in self.adjacentList:
self.adjacentList[data] = [] # add key [data] to the empty obje... | class Graph:
def __init__(self):
self.numnodes = 0
self.adjacentList = {}
def add_vertex(self, data):
if data not in self.adjacentList:
self.adjacentList[data] = []
self.numnodes += 1
return
def add_edge(self, node1, node2):
if node2 not... |
def f(a,b,cc):
if cc == '+':
return a+b
if cc == '-':
return a-b
if cc == '*':
return a*b
n=int(input())
L=[]
for i in range(n):
a=input()
L.append(a.split())
D = [[-987654321]*(n) for i in range(n)]
D2 = [[987654321]*(n) for i in range(n)]
for i in range(n):
if i%2 ... | def f(a, b, cc):
if cc == '+':
return a + b
if cc == '-':
return a - b
if cc == '*':
return a * b
n = int(input())
l = []
for i in range(n):
a = input()
L.append(a.split())
d = [[-987654321] * n for i in range(n)]
d2 = [[987654321] * n for i in range(n)]
for i in range(n):
... |
''' Used to access the methods stored in the main module. '''
main_module = {}
def _update(main_globals):
''' Gets the current state of the main module. '''
global main_module
main_module = main_globals
def get_instance():
''' Gets the current instance of minecraft, or none if there is not an instan... | """ Used to access the methods stored in the main module. """
main_module = {}
def _update(main_globals):
""" Gets the current state of the main module. """
global main_module
main_module = main_globals
def get_instance():
""" Gets the current instance of minecraft, or none if there is not an instance... |
class Model():
LR='logistic_regression'
CNN='cnn'
SVM='svm'
GENDERWORD='gender_word'
THRESHOLDCLASSIFIER='threshold_classifier'
class Dataset():
BENEVOLENT='benevolent'
HOSTILE='hostile'
OTHER='other'
CALLME='callme'
SCALES='scales'
class Domain():
BHO={'modified': ... | class Model:
lr = 'logistic_regression'
cnn = 'cnn'
svm = 'svm'
genderword = 'gender_word'
thresholdclassifier = 'threshold_classifier'
class Dataset:
benevolent = 'benevolent'
hostile = 'hostile'
other = 'other'
callme = 'callme'
scales = 'scales'
class Domain:
bho = {'mod... |
class Solution(object):
def findDuplicate(self, nums):
count={}
for i in nums:
if i not in count:
count[i]=1
else:
count[i]+=1
for i in range(0,len(nums)):
if count[nums[i]]>1:
return nums[i... | class Solution(object):
def find_duplicate(self, nums):
count = {}
for i in nums:
if i not in count:
count[i] = 1
else:
count[i] += 1
for i in range(0, len(nums)):
if count[nums[i]] > 1:
return nums[i]
... |
#!/usr/bin/python
class Node:
"""Klasa reprezentujaca wezel drzewa binarnego."""
def __init__(self, data=None, left=None, right=None):
self.data = data
self.left = left
self.right = right
def __str__(self):
return str(self.data)
def bst_max(top):
if top is None:
... | class Node:
"""Klasa reprezentujaca wezel drzewa binarnego."""
def __init__(self, data=None, left=None, right=None):
self.data = data
self.left = left
self.right = right
def __str__(self):
return str(self.data)
def bst_max(top):
if top is None:
raise value_erro... |
class BytecodeBase:
autoincrement = True # For jump
num_args = 0 # for error checking
def __init__(self):
# Eventually might want to add subclassed bytecodes here
# Though __subclasses__ works quite well
pass
def execute(self, machine):
pass
class Push(BytecodeBas... | class Bytecodebase:
autoincrement = True
num_args = 0
def __init__(self):
pass
def execute(self, machine):
pass
class Push(BytecodeBase):
num_args = 1
def __init__(self, data):
self.data = data
def execute(self, machine):
machine.push(self.data)
class Po... |
# https://leetcode.com/problems/reshape-the-matrix/
class Solution:
def matrixReshape(self, nums: [[int]], r: int, c: int) -> [[int]]:
if r * c != len(nums) * len(nums[0]):
return nums
# return self.solution1(nums, r, c)
# return self.solution2(nums, r, c)
... | class Solution:
def matrix_reshape(self, nums: [[int]], r: int, c: int) -> [[int]]:
if r * c != len(nums) * len(nums[0]):
return nums
return self.solution4(nums, r, c)
def solution1(self, nums, r, c):
q = []
for row in nums:
for item in row:
... |
num = int(input("Digite um numero inteiro: "))
base_conversao = int(input("Digite o numero para conversao ( 1 = BINARIO | 2 = OCTAL | 3 = HEXADECIMAL ): "))
if base_conversao == 1:
divisao_inteira = num
resto_divisao = num
binario = ""
while divisao_inteira != 0:
resto_divisao = divisao_intei... | num = int(input('Digite um numero inteiro: '))
base_conversao = int(input('Digite o numero para conversao ( 1 = BINARIO | 2 = OCTAL | 3 = HEXADECIMAL ): '))
if base_conversao == 1:
divisao_inteira = num
resto_divisao = num
binario = ''
while divisao_inteira != 0:
resto_divisao = divisao_inteira
... |
with open("infile.txt") as f1:
with open("outfile.txt", "w") as f2:
for line in f1:
f2.write(line)
| with open('infile.txt') as f1:
with open('outfile.txt', 'w') as f2:
for line in f1:
f2.write(line) |
'''
Build a card from list input
'''
class Card():
values = {'2':2, '3':3, '4':4, '5':5, '6':6, '7':7, '8':8,'9':9, '10':10, 'J':10, 'Q':10, 'K':10, 'A':11}
def __init__(self,suit,rank):
self.suit = suit
self.rank = rank
self.value = Card.values[rank]
def __str__(self):
return self.rank + '... | """
Build a card from list input
"""
class Card:
values = {'2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, '10': 10, 'J': 10, 'Q': 10, 'K': 10, 'A': 11}
def __init__(self, suit, rank):
self.suit = suit
self.rank = rank
self.value = Card.values[rank]
def __str__(sel... |
@app.route('/floorplan/')
def floorplan():
MIDDLE = """
<h1><u>Floorplan</u></h1>
<img src="/static/floorplan.jpg">
<br>
"""
return TOP + MIDDLE + BOTTOM
if __name__ == "__main__":
app.run(debug=False,host='0.0.0.0', port=int(os.getenv('PORT', '5000')))
| @app.route('/floorplan/')
def floorplan():
middle = '\n <h1><u>Floorplan</u></h1>\n <img src="/static/floorplan.jpg">\n <br>\n '
return TOP + MIDDLE + BOTTOM
if __name__ == '__main__':
app.run(debug=False, host='0.0.0.0', port=int(os.getenv('PORT', '5000'))) |
class UF:
def __init__(self, n: int):
self.id = list(range(n))
def union(self, u: int, v: int) -> None:
self.id[self.find(u)] = self.find(v)
def find(self, u: int) -> int:
if self.id[u] != u:
self.id[u] = self.find(self.id[u])
return self.id[u]
class Solution:
def smallestStringWithSwa... | class Uf:
def __init__(self, n: int):
self.id = list(range(n))
def union(self, u: int, v: int) -> None:
self.id[self.find(u)] = self.find(v)
def find(self, u: int) -> int:
if self.id[u] != u:
self.id[u] = self.find(self.id[u])
return self.id[u]
class Solution:... |
# These are lists that acts as dbs for storing users, recipes and recipe categories
users_db = []
recipe_db = []
recipe_category_db = []
# catching errors
class UserNotFoundException(Exception):
pass
class NullUserError(Exception):
pass
class RecipeNotFoundError(Exception):
pass
# this is a class for... | users_db = []
recipe_db = []
recipe_category_db = []
class Usernotfoundexception(Exception):
pass
class Nullusererror(Exception):
pass
class Recipenotfounderror(Exception):
pass
class Users:
def __init__(self):
self.users = users_db
def add_user(self, user):
if user:
... |
# -*- coding: utf-8 -*-
def test_schema_sqlite(sqlite_db):
"""Test init_schema creates empty tables"""
yo_db = sqlite_db
m = MetaData()
m.create_all(bind=yo_db.engine)
for table in m.tables.values():
with yo_db.acquire_conn() as conn:
query = table.select().where(True)
... | def test_schema_sqlite(sqlite_db):
"""Test init_schema creates empty tables"""
yo_db = sqlite_db
m = meta_data()
m.create_all(bind=yo_db.engine)
for table in m.tables.values():
with yo_db.acquire_conn() as conn:
query = table.select().where(True)
response = conn.execu... |
class Logger:
def info(self, message: str) -> None:
raise NotImplementedError()
def success(self, message: str) -> None:
raise NotImplementedError()
def warning(self, message: str) -> None:
raise NotImplementedError()
def error(self, message: str) -> None:
raise NotImp... | class Logger:
def info(self, message: str) -> None:
raise not_implemented_error()
def success(self, message: str) -> None:
raise not_implemented_error()
def warning(self, message: str) -> None:
raise not_implemented_error()
def error(self, message: str) -> None:
raise... |
ODSS_FACTORY_CONTEXT = "__ODSS_FACTORY_CONTEXT__"
HANDLER_PROVIDES = "odss.providers"
HANDLER_REQUIRES = "odss.requires"
HANDLER_VALIDATE = "odss.validate"
HANDLER_BIND = "odss.bind"
PROP_HANDLER_NAME = "odss.handler.id"
METHOD_CALLBACK = "odss.method.callback"
CALLBACK_VALIDATE = "odss.callback.validate"
CALLBACK_... | odss_factory_context = '__ODSS_FACTORY_CONTEXT__'
handler_provides = 'odss.providers'
handler_requires = 'odss.requires'
handler_validate = 'odss.validate'
handler_bind = 'odss.bind'
prop_handler_name = 'odss.handler.id'
method_callback = 'odss.method.callback'
callback_validate = 'odss.callback.validate'
callback_inva... |
"""
This Bubble Sort implementation uses a flag to terminate iterations early if
the list is already sorted, and uses a while loop instad of a for loop for
the outer iterations.
Because we don't know the outer iteration number, we need to iterate the
whole list (both unsorted and unsorted portions) on each inner loop.... | """
This Bubble Sort implementation uses a flag to terminate iterations early if
the list is already sorted, and uses a while loop instad of a for loop for
the outer iterations.
Because we don't know the outer iteration number, we need to iterate the
whole list (both unsorted and unsorted portions) on each inner loop.... |
# Copyright (c) 2019 Intel Corporation.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, ... | """Custom exceptions used in the Python module
"""
class Receivetimeout(Exception):
"""Exception raised when a timeout has occurred while attempting to
receive a message.
"""
pass
class Messagebuserror(Exception):
"""Generic exception used when an issue occurs in a message bus method
"""
p... |
class Voice:
def __init__(
self,
channel_id,
user_id,
session_id,
deaf,
mute,
self_deaf,
self_mute,
self_video,
suppress
):
self.channel_id = channel_id
self.user_id = user_id
self.session_id = session_id
... | class Voice:
def __init__(self, channel_id, user_id, session_id, deaf, mute, self_deaf, self_mute, self_video, suppress):
self.channel_id = channel_id
self.user_id = user_id
self.session_id = session_id
self.deaf = deaf
self.mute = mute
self.self_deaf = self_deaf
... |
class Version(object):
def __init__(self, major, minor, tool):
self.major = major
self.minor = minor
self.tool = tool
@staticmethod
def create(dic):
return Version(int(dic["major"]),int(dic["minor"]),dic["tool"])
def is10(self):
if self.major == 1 and self.minor... | class Version(object):
def __init__(self, major, minor, tool):
self.major = major
self.minor = minor
self.tool = tool
@staticmethod
def create(dic):
return version(int(dic['major']), int(dic['minor']), dic['tool'])
def is10(self):
if self.major == 1 and self.mi... |
#!/usr/bin/python3
# -*- coding: utf-8 -*-
##===-----------------------------------------------------------------------------*- Python -*-===##
##
## S E R I A L B O X
##
## This file is distributed under terms of BSD license.
## See LICENSE.txt for more information.
##
##===----------... | class Testlistener(object):
def __init__(self):
self.__count = 0
def increment_count(self):
self.__count += 1
@property
def count(self):
return self.__count |
set_name(0x80079AEC, "GetTpY__FUs", SN_NOWARN)
set_name(0x80079B08, "GetTpX__FUs", SN_NOWARN)
set_name(0x80079B14, "Remove96__Fv", SN_NOWARN)
set_name(0x80079B4C, "AppMain", SN_NOWARN)
set_name(0x80079BF4, "MAIN_RestartGameTask__Fv", SN_NOWARN)
set_name(0x80079C20, "GameTask__FP4TASK", SN_NOWARN)
set_name(0x80079CB8, "... | set_name(2147982060, 'GetTpY__FUs', SN_NOWARN)
set_name(2147982088, 'GetTpX__FUs', SN_NOWARN)
set_name(2147982100, 'Remove96__Fv', SN_NOWARN)
set_name(2147982156, 'AppMain', SN_NOWARN)
set_name(2147982324, 'MAIN_RestartGameTask__Fv', SN_NOWARN)
set_name(2147982368, 'GameTask__FP4TASK', SN_NOWARN)
set_name(2147982520, '... |
# Gigawhat Website JSON models file.
# Copyright 2022 Gigawhat Programming Team
# Written by Samyar Sadat Akhavi, 2022.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 o... | """JSON models for the Gigawhat website.
"""
class Quizplayerinfo:
username: str
with_account: bool
right_answ: int
wrong_answ: int
def __init__(self, username: str, with_account: bool, right_answ: int, wrong_answ: int):
self.username = username
self.with_account = with_account
... |
class Dog:
def __init__(self, name, age):
self.name = name
self.age = age
def get_name(self):
return self.name
def set_name(self, name):
self.name = name
def bark(self):
print(self.name, "is barking..")
if __name__ == '__main__':
dog = Dog("Tim")
dog... | class Dog:
def __init__(self, name, age):
self.name = name
self.age = age
def get_name(self):
return self.name
def set_name(self, name):
self.name = name
def bark(self):
print(self.name, 'is barking..')
if __name__ == '__main__':
dog = dog('Tim')
dog.b... |
home_page_location = "/"
gdp_page_location = "/gdp"
iris_page_location = "/iris"
TIMEOUT = 60 | home_page_location = '/'
gdp_page_location = '/gdp'
iris_page_location = '/iris'
timeout = 60 |
"""
Classes for exposing a number of different output data formats.
Most notably, the exporter module implements the correct output of the
transaction stream into TARIC XML envelopes and handles the process by which
these envelopes are marshalled to CDS.
This module also makes available the objects in the system as a... | """
Classes for exposing a number of different output data formats.
Most notably, the exporter module implements the correct output of the
transaction stream into TARIC XML envelopes and handles the process by which
these envelopes are marshalled to CDS.
This module also makes available the objects in the system as a... |
__author__ = 'surya'
def createProtein2Path(proteinList,file):
prot2path={}
for line in open(file):
splits=line.strip().split("\t")
reactomeId=splits[0].strip()
proteins=splits[1:len(splits)]
for each in proteins:
if each in proteinList:
if each not i... | __author__ = 'surya'
def create_protein2_path(proteinList, file):
prot2path = {}
for line in open(file):
splits = line.strip().split('\t')
reactome_id = splits[0].strip()
proteins = splits[1:len(splits)]
for each in proteins:
if each in proteinList:
i... |
#
# PySNMP MIB module GNOME-PRODUCT-ZEBRA-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/GNOME-PRODUCT-ZEBRA-MIB
# Produced by pysmi-0.3.4 at Wed May 1 13:19:46 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 ... | (octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, constraints_union, constraints_intersection, value_size_constraint, value_range_constraint) ... |
class Plugin(object):
"""Base class for plugins.
The __init__ method of derived classes should accept two arguments:
document - an instance of InselectDocument
parent - a QMainWindow
Derived classes should contain
NAME - a string
DESCRIPTION - a string
Derived classes ... | class Plugin(object):
"""Base class for plugins.
The __init__ method of derived classes should accept two arguments:
document - an instance of InselectDocument
parent - a QMainWindow
Derived classes should contain
NAME - a string
DESCRIPTION - a string
Derived classes ... |
##Config file for lifetime_spyrelet.py in spyre/spyre/spyrelet/
# Device List
devices = {
'fungen':[
'lantz.drivers.keysight.Keysight_33622A.Keysight_33622A',
['USB0::0x0957::0x5707::MY53801461::INSTR'],
{}
],
'wm':[
'lantz.drivers.bristol.bristol771.Bristol_771',
[6... | devices = {'fungen': ['lantz.drivers.keysight.Keysight_33622A.Keysight_33622A', ['USB0::0x0957::0x5707::MY53801461::INSTR'], {}], 'wm': ['lantz.drivers.bristol.bristol771.Bristol_771', [6535], {}]}
spyrelets = {'contour': ['spyre.spyrelets.contour_spyrelet.Contour', {'fungen': 'fungen', 'wm': 'wm'}, {}]} |
class Solution:
def twoSum(self, nums, target):
"""
:type nums: List[int]
:type target: int
:rtype: List[int]
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
Given nums = [2, 7, 11, 15], target = 9,
Be... | class Solution:
def two_sum(self, nums, target):
"""
:type nums: List[int]
:type target: int
:rtype: List[int]
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
Given nums = [2, 7, 11, 15], target = 9,
... |
#!/usr/bin/python
# Published March 2015
# Author : Greg Fabre - http://www.iero.org
# Based on Noah Blon's work : http://codepen.io/noahblon/details/lxukH
# Public domain source code
def getHome() :
return '<g transform="matrix(6.070005,0,0,5.653153,292.99285,506.46284)"><path d="M 42,48 C 29.995672,48.017555 18.0... | def get_home():
return '<g transform="matrix(6.070005,0,0,5.653153,292.99285,506.46284)"><path d="M 42,48 C 29.995672,48.017555 18.003366,48 6,48 L 6,27 c 0,-0.552 0.447,-1 1,-1 0.553,0 1,0.448 1,1 l 0,19 c 32.142331,0.03306 13.954169,0 32,0 l 0,-18 c 0,-0.552 0.447,-1 1,-1 0.553,0 1,0.448 1,1 z"/><path d="m 47,27 ... |
# -*- coding: utf-8 -*-
"""
Created on Wed Dec 22 09:58:13 2021
@author: Diva Mehta
"""
class Player:
# Constructor always called when the class is created
def __init__(self):
self.name = ""
self.wins = 0
self.losses = 0
# -1 = no chocie, 1 = scissors, 2 = rock, 3 = paper
... | """
Created on Wed Dec 22 09:58:13 2021
@author: Diva Mehta
"""
class Player:
def __init__(self):
self.name = ''
self.wins = 0
self.losses = 0
self.hand = -1
def __str__(self):
print('Name: ' + self.name)
print('Wins: ' + str(self.wins))
print('Losses:... |
class ShortPath:
def __init__(self):
self.paths = []
self.distance = 0
| class Shortpath:
def __init__(self):
self.paths = []
self.distance = 0 |
n = int(input())
l, r = 0, 0
for _ in range(n):
x, y = map(int, input().split())
if x < 0:
l += 1
else:
r += 1
if l <= 1 or r <= 1:
print('Yes')
else:
print('No')
| n = int(input())
(l, r) = (0, 0)
for _ in range(n):
(x, y) = map(int, input().split())
if x < 0:
l += 1
else:
r += 1
if l <= 1 or r <= 1:
print('Yes')
else:
print('No') |
RS_ID = 0x12345678
RS_VERSION = 7
RBSP_ID = 0x35849298
RBSP_VERSION = 2
R_PAT_ID = 0x09784348
R_PAT_VERSION = 0
R_LM_ID = 0x30671804
R_LM_VERSION = 3
R_COL_ID = ... | rs_id = 305419896
rs_version = 7
rbsp_id = 897880728
rbsp_version = 2
r_pat_id = 158876488
r_pat_version = 0
r_lm_id = 812062724
r_lm_version = 3
r_col_id = 1347426191
r_col_version = 0
r_nav_id = 2290649231
r_nav_version = 2
rm_flag_additive = 1
rm_flag_useopacity = 2
rm_flag_twosided = 4
rm_flag_notwalkable = 8
rm_fl... |
class SearchUI:
'''SearchUI provides a means of easily assembling a search interface
for either Elasticsearch or LunrJS powered search services'''
def __init__(self, cfg):
self.cfg = {}
for key in cfg.keys():
self.cfg[key] = cfg.get(key, None)
if not ('id' in self.cfg):... | class Searchui:
"""SearchUI provides a means of easily assembling a search interface
for either Elasticsearch or LunrJS powered search services"""
def __init__(self, cfg):
self.cfg = {}
for key in cfg.keys():
self.cfg[key] = cfg.get(key, None)
if not 'id' in self.cfg:
... |
a=float(input())
b=float(input())
intdiv=int(a/b)
floatdiv=float(a/b)
print(intdiv,floatdiv, sep='\n')
| a = float(input())
b = float(input())
intdiv = int(a / b)
floatdiv = float(a / b)
print(intdiv, floatdiv, sep='\n') |
s = list(input())
t = list(input())
n = len(s)
answer = "No"
for i in range(n):
for j in range(n-1):
s[n-1-j], s[n-2-j] = s[n-2-j], s[n-1-j]
if s == t:
answer = "Yes"
print(answer) | s = list(input())
t = list(input())
n = len(s)
answer = 'No'
for i in range(n):
for j in range(n - 1):
(s[n - 1 - j], s[n - 2 - j]) = (s[n - 2 - j], s[n - 1 - j])
if s == t:
answer = 'Yes'
print(answer) |
# use classifier and test_datagen from before
# classifier is just a Sequential object
x = test_datagen.flow_from_directory('dataset/image_folder',
target_size = (64, 64),
class_mode = 'binary')
print("It is a %s!" % ("dog" if classifier.predict(... | x = test_datagen.flow_from_directory('dataset/image_folder', target_size=(64, 64), class_mode='binary')
print('It is a %s!' % ('dog' if classifier.predict(x) else 'cat')) |
# Posts number per page for pagination.
POSTS_PER_PAGE = 10
# Time period in seconds for a page in cache.
CACHED_TIME_INDEX = 3
| posts_per_page = 10
cached_time_index = 3 |
"""
#convert base>10 to decimal(base 10)
num=str(input())
print(int(num,16))
"""
def toDigits(n, b):
#Convert a positive number n to its digit representation in base b.
digits = []
while n > 0:
digits.insert(0, n % b)
n = n // b
return digits
def fromDigits(digits, b):
#Compute th... | """
#convert base>10 to decimal(base 10)
num=str(input())
print(int(num,16))
"""
def to_digits(n, b):
digits = []
while n > 0:
digits.insert(0, n % b)
n = n // b
return digits
def from_digits(digits, b):
n = 0
for d in digits:
n = b * n + d
return n
def convert_base(di... |
_base_ = [
'../_base_/datasets/textvqa_dataset.py',
'../_base_/models/m4c_config.py',
'../_base_/schedules/schedule_textvqa.py',
'../_base_/textvqa_default_runtime.py'
] # yapf:disable
| _base_ = ['../_base_/datasets/textvqa_dataset.py', '../_base_/models/m4c_config.py', '../_base_/schedules/schedule_textvqa.py', '../_base_/textvqa_default_runtime.py'] |
TAIGA_USER = 'e1312060@urhen.com'
TAIGA_PASSWORD = 'test_taiga_user'
PROJECT_SLUG = 'test_taiga_user-fake-project-1'
DONE_SLUG = 'Done'
| taiga_user = 'e1312060@urhen.com'
taiga_password = 'test_taiga_user'
project_slug = 'test_taiga_user-fake-project-1'
done_slug = 'Done' |
"""
Given an array nums of n integers and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of the three integers. You may assume that each input would have exactly one solution.
Example:
Given array nums = [-1, 2, 1, -4], and target = 1.
The sum that is closest to... | """
Given an array nums of n integers and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of the three integers. You may assume that each input would have exactly one solution.
Example:
Given array nums = [-1, 2, 1, -4], and target = 1.
The sum that is closest to... |
__version__ = "0.0.1"
def func(a: int, b: int = 0, c: int = 0) -> int:
"""Test function.
Args:
a (int): Parameter A.
b (int, optional): Parameter B.
c (int, optional): Parameter C.
Returns:
sum: The sum of A, B, and C.
"""
return a + b + c
| __version__ = '0.0.1'
def func(a: int, b: int=0, c: int=0) -> int:
"""Test function.
Args:
a (int): Parameter A.
b (int, optional): Parameter B.
c (int, optional): Parameter C.
Returns:
sum: The sum of A, B, and C.
"""
return a + b + c |
class UserInputError( Exception):
pass | class Userinputerror(Exception):
pass |
real_number = int(input())
numbers = []
names = []
def find_closer():
diferences = []
closers = []
global numbers
global real_number
for i in numbers:
diference = real_number - i
if diference < 0:
diferences.append(-diference)
else:
diferences.append(... | real_number = int(input())
numbers = []
names = []
def find_closer():
diferences = []
closers = []
global numbers
global real_number
for i in numbers:
diference = real_number - i
if diference < 0:
diferences.append(-diference)
else:
diferences.append(... |
NODE_LEFT = "LEFT"
NODE_RIGHT = "RIGHT"
NODE_ROOT = "ROOT"
class BinarySearchTree:
def __init__(self, value):
self.value = value
self.left = None
self.right = None
self.parent = None
self.type = None
def insert(self, tree):
current = self
while 1:
... | node_left = 'LEFT'
node_right = 'RIGHT'
node_root = 'ROOT'
class Binarysearchtree:
def __init__(self, value):
self.value = value
self.left = None
self.right = None
self.parent = None
self.type = None
def insert(self, tree):
current = self
while 1:
... |
load("//apple:string_dict_select_values.bzl", "string_dict_select_values")
def _impl(ctx):
substitutions = {}
for key, value in ctx.attr.items():
substitutions["${" + key + "}"] = value
substitutions["$(" + key + ")"] = value
output = ctx.outputs.out
ctx.actions.expand_template(
... | load('//apple:string_dict_select_values.bzl', 'string_dict_select_values')
def _impl(ctx):
substitutions = {}
for (key, value) in ctx.attr.items():
substitutions['${' + key + '}'] = value
substitutions['$(' + key + ')'] = value
output = ctx.outputs.out
ctx.actions.expand_template(templa... |
class Circle:
pi = 3.14
def __init__(self, diameter):
print("Creating circle with diameter {d}".format(d=diameter))
# Add assignment for self.radius here:
self.radius = diameter / 2
def circumference(self):
return 2 * self.pi * self.radius
medium_pizza = Circle(12)
teaching_table = Circle(36... | class Circle:
pi = 3.14
def __init__(self, diameter):
print('Creating circle with diameter {d}'.format(d=diameter))
self.radius = diameter / 2
def circumference(self):
return 2 * self.pi * self.radius
medium_pizza = circle(12)
teaching_table = circle(36)
round_room = circle... |
# coding = utf-8
"""
create on : 2019/04/06
project name : AtCoder
file name : 01_ABC086A
problem : https://atcoder.jp/contests/abs/tasks/abc086_a
"""
def main():
a, b = [int(x) for x in input().split(" ")]
ab = a * b
ans = "Odd" if ab % 2 else "Even"
print(ans)
if __name__ == "__main__":
main... | """
create on : 2019/04/06
project name : AtCoder
file name : 01_ABC086A
problem : https://atcoder.jp/contests/abs/tasks/abc086_a
"""
def main():
(a, b) = [int(x) for x in input().split(' ')]
ab = a * b
ans = 'Odd' if ab % 2 else 'Even'
print(ans)
if __name__ == '__main__':
main() |
# -*- coding: utf-8 -*-
def comp_periodicity(self, p=None):
"""Compute the periodicity factor of the lamination
Parameters
----------
self : LamSlotMulti
A LamSlotMulti object
Returns
-------
per_a : int
Number of spatial periodicities of the lamination
is_antiper_a :... | def comp_periodicity(self, p=None):
"""Compute the periodicity factor of the lamination
Parameters
----------
self : LamSlotMulti
A LamSlotMulti object
Returns
-------
per_a : int
Number of spatial periodicities of the lamination
is_antiper_a : bool
True if an s... |
# anagram_palindrome
#
# Write a function which accepts an input word and returns true or false
# if there exists an anagram of that input word that is a palindrome.
# We are going to try solve this question with a time complexcity of:
# O(n) => linear
# palindrome : is a string that read the same from front to back... | def anagram_palindrome(word):
return word == word[::-1]
print(anagram_palindrome('noon'))
print(anagram_palindrome('carrace'))
print(anagram_palindrome('cutoo'))
print(anagram_palindrome('a'))
print(anagram_palindrome('aotoa'))
print(anagram_palindrome('ddaaa')) |
def to_bool(value):
value = str(value)
if value == "True" or value == "TRUE" or value == "true":
return True
else:
return False
| def to_bool(value):
value = str(value)
if value == 'True' or value == 'TRUE' or value == 'true':
return True
else:
return False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.