content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
def getIntersectionNode(self, headA: ListNode, headB: ListNode) -> ListNode:
if not headA or not headB:
return None
# compute th... | class Solution:
def get_intersection_node(self, headA: ListNode, headB: ListNode) -> ListNode:
if not headA or not headB:
return None
len_a = len_b = 1
node_a = headA
while nodeA.next:
node_a = nodeA.next
len_a += 1
node_b = headB
... |
# Autogenerated file for HID Mouse
# Add missing from ... import const
_JD_SERVICE_CLASS_HID_MOUSE = const(0x1885dc1c)
_JD_HID_MOUSE_BUTTON_LEFT = const(0x1)
_JD_HID_MOUSE_BUTTON_RIGHT = const(0x2)
_JD_HID_MOUSE_BUTTON_MIDDLE = const(0x4)
_JD_HID_MOUSE_BUTTON_EVENT_UP = const(0x1)
_JD_HID_MOUSE_BUTTON_EVENT_DOWN = cons... | _jd_service_class_hid_mouse = const(411425820)
_jd_hid_mouse_button_left = const(1)
_jd_hid_mouse_button_right = const(2)
_jd_hid_mouse_button_middle = const(4)
_jd_hid_mouse_button_event_up = const(1)
_jd_hid_mouse_button_event_down = const(2)
_jd_hid_mouse_button_event_click = const(3)
_jd_hid_mouse_button_event_doub... |
def is_substitution_cipher(s1, s2):
dict1={}
dict2={}
for i,j in zip(s1, s2):
dict1[i]=dict1.get(i, 0)+1
dict2[j]=dict2.get(j, 0)+1
if len(dict1)!=len(dict2):
return False
return True | def is_substitution_cipher(s1, s2):
dict1 = {}
dict2 = {}
for (i, j) in zip(s1, s2):
dict1[i] = dict1.get(i, 0) + 1
dict2[j] = dict2.get(j, 0) + 1
if len(dict1) != len(dict2):
return False
return True |
# A program to rearrange array in alternating positive & negative items with O(1) extra space
class ArrayRearrange:
def __init__(self, arr, n):
self.arr = arr
self.n = n
def rearrange_array(self):
arr = self.arr.copy()
out_of_place = -1
for i in range(self.n):
... | class Arrayrearrange:
def __init__(self, arr, n):
self.arr = arr
self.n = n
def rearrange_array(self):
arr = self.arr.copy()
out_of_place = -1
for i in range(self.n):
if out_of_place == -1:
if arr[i] >= 0 and i % 2 == 0 or (arr[i] < 0 and i %... |
expected_output = {
'pid': 'WS-C4507R',
'os': 'ios',
'platform': 'cat4k',
'version': '12.2(18)EW5',
}
| expected_output = {'pid': 'WS-C4507R', 'os': 'ios', 'platform': 'cat4k', 'version': '12.2(18)EW5'} |
_MAJOR = 0
_MINOR = 6
_PATCH = 4
__version__ = str(_MAJOR) + '.' + str(_MINOR) + '.' + str(_PATCH)
def version():
'''
Returns a string representation of the version
'''
return __version__
def version_tuple():
'''
Returns a 3-tuple of ints that represent the version
'''
return (_MAJO... | _major = 0
_minor = 6
_patch = 4
__version__ = str(_MAJOR) + '.' + str(_MINOR) + '.' + str(_PATCH)
def version():
"""
Returns a string representation of the version
"""
return __version__
def version_tuple():
"""
Returns a 3-tuple of ints that represent the version
"""
return (_MAJOR, ... |
#!/usr/bin/env python3
# https://www.hackerrank.com/challenges/python-lists/
if __name__ == '__main__':
N = int(input())
lst = []
for i in range(N):
cmd = input().rstrip().split()
if(cmd[0] == 'insert'):
lst.insert(int(cmd[1]), int(cmd[2]))
elif(cmd[0] == 'print'): ... | if __name__ == '__main__':
n = int(input())
lst = []
for i in range(N):
cmd = input().rstrip().split()
if cmd[0] == 'insert':
lst.insert(int(cmd[1]), int(cmd[2]))
elif cmd[0] == 'print':
print(lst)
elif cmd[0] == 'remove':
lst.remove(int(cm... |
class Solution:
def minSwap(self, A: List[int], B: List[int]) -> int:
n1, s1 = 0, 1
for i in range(1, len(A)):
n2 = s2 = float("inf")
if A[i - 1] < A[i] and B[i - 1] < B[i]:
n2 = min(n2, n1)
s2 = min(s2, s1 + 1)
if A[i - 1] < B[i] a... | class Solution:
def min_swap(self, A: List[int], B: List[int]) -> int:
(n1, s1) = (0, 1)
for i in range(1, len(A)):
n2 = s2 = float('inf')
if A[i - 1] < A[i] and B[i - 1] < B[i]:
n2 = min(n2, n1)
s2 = min(s2, s1 + 1)
if A[i - 1] < ... |
__author__ = 'xelhark'
class ErrorWithList(ValueError):
def __init__(self, message, errors_list=None):
self.errors_list = errors_list
super(ErrorWithList, self).__init__(message)
class ModelValidationError(ErrorWithList):
pass
class InstanceValidationError(ErrorWithList):
pass
| __author__ = 'xelhark'
class Errorwithlist(ValueError):
def __init__(self, message, errors_list=None):
self.errors_list = errors_list
super(ErrorWithList, self).__init__(message)
class Modelvalidationerror(ErrorWithList):
pass
class Instancevalidationerror(ErrorWithList):
pass |
config = {
"username": "",
"password": "",
"phonename": "iPhone",
"sms_csv": ""
} | config = {'username': '', 'password': '', 'phonename': 'iPhone', 'sms_csv': ''} |
#This program takes in a postive integer and applies a calculation to it.
# It then outputs a sequence that ends in 1
#creates a list called L
mylist=[]
#take the input for the user
value = int(input("Please enter a positive integer: "))
# Adds the input to the list.
# The append wouldnt work unless I made i an int ... | mylist = []
value = int(input('Please enter a positive integer: '))
mylist.append(int(value))
while value != 1:
if value % 2 == 0:
value /= 2
mylist.append(int(value))
else:
value = value * 3 + 1
mylist.append(int(value))
print(mylist) |
class Aritmatika:
@staticmethod
def tambah(a, b):
return a + b
@staticmethod
def kurang(a, b):
return a - b
@staticmethod
def bagi(a, b):
return a / b
@staticmethod
def bagi_int(a, b):
return a // b
@staticmethod
def pangkat(a, b):
ret... | class Aritmatika:
@staticmethod
def tambah(a, b):
return a + b
@staticmethod
def kurang(a, b):
return a - b
@staticmethod
def bagi(a, b):
return a / b
@staticmethod
def bagi_int(a, b):
return a // b
@staticmethod
def pangkat(a, b):
ret... |
def calculate_similarity(my, theirs, tags):
similarity = {}
for group in ('personal', 'hobbies'):
all_names = {tag.code for tag in tags if tag.group == group}
my_names = all_names & my
their_names = all_names & theirs
both = my_names | their_names
same = my_names & their_... | def calculate_similarity(my, theirs, tags):
similarity = {}
for group in ('personal', 'hobbies'):
all_names = {tag.code for tag in tags if tag.group == group}
my_names = all_names & my
their_names = all_names & theirs
both = my_names | their_names
same = my_names & their_... |
# Method 1: using index find the max first, and then process
def validMountainArray(self, A):
if len(A) < 3: return False
index = A.index(max(A))
if index == 0 or index == len(A) -1: return False
for i in range(1, len(A)):
if i <= index:
if A[i] <= A[i - 1]: return False
els... | def valid_mountain_array(self, A):
if len(A) < 3:
return False
index = A.index(max(A))
if index == 0 or index == len(A) - 1:
return False
for i in range(1, len(A)):
if i <= index:
if A[i] <= A[i - 1]:
return False
elif A[i] >= A[i - 1]:
... |
# 69. Sqrt(x) Easy
# Implement int sqrt(int x).
#
# Compute and return the square root of x, where x is guaranteed to be a non-negative integer.
#
# Since the return type is an integer, the decimal digits are truncated and only the integer part of the result is returned.
#
# Example 1:
#
# Input: 4
# Output: 2
# Exampl... | def my_sqrt(self, x: int) -> int:
"""
Runtime: 56 ms, faster than 54.11% of Python3 online submissions for Sqrt(x).
Memory Usage: 13.1 MB, less than 79.16% of Python3 online submissions for Sqrt(x).
"""
if x == 1 or x == 0:
return x
max_range = max(1, x)
min_range = 0
result = 0
... |
class UncleEngineer:
'''
test = UncleEngineer()
test.art()
'''
def __init__(self):
self.name = 'Uncle Engineer'
def art(self):
asciiart = '''
Z
Z
.,., z
... | class Uncleengineer:
"""
test = UncleEngineer()
test.art()
"""
def __init__(self):
self.name = 'Uncle Engineer'
def art(self):
asciiart = '\n Z \n Z \n .,., z \n (((((()... |
class Vscode():
def execute(self):
print("code is compiling and code is running")
class Pycharm():
def execute(self):
print("code is compiling and code is running")
class python():
def execute(self):
print("python is using")
class CPP():
def execute(self):
print("C++ is usi... | class Vscode:
def execute(self):
print('code is compiling and code is running')
class Pycharm:
def execute(self):
print('code is compiling and code is running')
class Python:
def execute(self):
print('python is using')
class Cpp:
def execute(self):
print('C++ is us... |
nums = [2, 3, 4, 5, 7, 10, 12]
for n in nums:
print(n, end=", ")
class CartItem:
def __init__(self, name, price) -> None:
self.price = price
self.name = name
def __repr__(self) -> str:
return "({0}, ${1})".format(self.name, self.price)
class ShoppingCart:
def __init__(self) -> None:
se... | nums = [2, 3, 4, 5, 7, 10, 12]
for n in nums:
print(n, end=', ')
class Cartitem:
def __init__(self, name, price) -> None:
self.price = price
self.name = name
def __repr__(self) -> str:
return '({0}, ${1})'.format(self.name, self.price)
class Shoppingcart:
def __init__(self) ... |
highest_seat_id = 0
with open("input.txt", "r") as f:
lines = [line.rstrip() for line in f.readlines()]
for line in lines:
rows = [0, 127]
row = None
columns = [0, 7]
column = None
for command in list(line):
if command == "F":
rows = [rows[0]... | highest_seat_id = 0
with open('input.txt', 'r') as f:
lines = [line.rstrip() for line in f.readlines()]
for line in lines:
rows = [0, 127]
row = None
columns = [0, 7]
column = None
for command in list(line):
if command == 'F':
rows = [rows[0], ... |
class Vertex:
def __init__(self, label: str = None, weight: int = float("inf"), key: int = None):
self.label: str = label
self.weight: int = weight
self.key: int = key
| class Vertex:
def __init__(self, label: str=None, weight: int=float('inf'), key: int=None):
self.label: str = label
self.weight: int = weight
self.key: int = key |
class Solution:
def dfs(self, s:str, n:int, pos:int, sub_res:list, total_res:list, left:int):
if left == 0 and pos >= n:
total_res.append(sub_res[:])
return
if left == 0 and pos < n:
return
if pos < n and s[pos] == '0':
sub_res.append(s[pos])
... | class Solution:
def dfs(self, s: str, n: int, pos: int, sub_res: list, total_res: list, left: int):
if left == 0 and pos >= n:
total_res.append(sub_res[:])
return
if left == 0 and pos < n:
return
if pos < n and s[pos] == '0':
sub_res.append(s[... |
collection = ["gold", "silver", "bronze"]
# list comprehension
new_list = [item.upper for item in collection]
# generator expression
# it is similar to list comprehension, but use () round brackets
my_gen = (item.upper for item in collection) | collection = ['gold', 'silver', 'bronze']
new_list = [item.upper for item in collection]
my_gen = (item.upper for item in collection) |
# This is where all of our model classes are defined
class PhysicalAttributes:
def __init__(self, width=None, height=None, depth=None, dimensions=None, mass=None):
self.width = width
self.height = height
self.depth = depth
self.dimensions = dimensions
self.mass = mass
... | class Physicalattributes:
def __init__(self, width=None, height=None, depth=None, dimensions=None, mass=None):
self.width = width
self.height = height
self.depth = depth
self.dimensions = dimensions
self.mass = mass
def serialize(self):
return {'width': self.wid... |
class Identifier(object):
def __init__(self, name, value, declared=False, id_type=None, constant=False):
self.name = name
self.value = value
self.declared = declared
self.type = id_type
self.constant = constant
def __str__(self):
return self.name | class Identifier(object):
def __init__(self, name, value, declared=False, id_type=None, constant=False):
self.name = name
self.value = value
self.declared = declared
self.type = id_type
self.constant = constant
def __str__(self):
return self.name |
def mostra_adicionais(*args):
telaProduto = args[0]
cursor = args[1]
QtWidgets = args[2]
telaProduto.frame_adc.show()
listaAdc = []
sql1 = ("select * from adcBroto")
cursor.execute(sql1)
dados1 = cursor.fetchall()
sql2 = ("select * from adcSeis ")
cursor.execute(sql2)
dados... | def mostra_adicionais(*args):
tela_produto = args[0]
cursor = args[1]
qt_widgets = args[2]
telaProduto.frame_adc.show()
lista_adc = []
sql1 = 'select * from adcBroto'
cursor.execute(sql1)
dados1 = cursor.fetchall()
sql2 = 'select * from adcSeis '
cursor.execute(sql2)
dados2 =... |
#!/usr/bin/env pyrate
foo_obj = object_file('foo_obj', ['foo.cpp'], compiler_opts = '-O3')
executable('example07.bin', ['test.cpp', foo_obj])
| foo_obj = object_file('foo_obj', ['foo.cpp'], compiler_opts='-O3')
executable('example07.bin', ['test.cpp', foo_obj]) |
#! /usr/bin/python
Ada, C, GUI, SIMULINK, VHDL, OG, RTDS, SYSTEM_C, SCADE6, VDM, CPP = range(11)
thread, passive, unknown = range(3)
PI, RI = range(2)
synch, asynch = range(2)
param_in, param_out = range(2)
UPER, NATIVE, ACN = range(3)
cyclic, sporadic, variator, protected, unprotected = range(5)
enumerated, sequenceo... | (ada, c, gui, simulink, vhdl, og, rtds, system_c, scade6, vdm, cpp) = range(11)
(thread, passive, unknown) = range(3)
(pi, ri) = range(2)
(synch, asynch) = range(2)
(param_in, param_out) = range(2)
(uper, native, acn) = range(3)
(cyclic, sporadic, variator, protected, unprotected) = range(5)
(enumerated, sequenceof, se... |
# Copyright 2019 The LUCI Authors. All rights reserved.
# Use of this source code is governed under the Apache License, Version 2.0
# that can be found in the LICENSE file.
PYTHON_VERSION_COMPATIBILITY = 'PY2+3'
DEPS = [
'futures',
'step',
]
def RunSteps(api):
futures = []
for i in range(10):
def _runne... | python_version_compatibility = 'PY2+3'
deps = ['futures', 'step']
def run_steps(api):
futures = []
for i in range(10):
def _runner(i):
api.step('sleep loop [%d]' % (i + 1), ['python3', '-u', api.resource('sleep_loop.py'), i], cost=api.step.ResourceCost())
return i + 1
f... |
'''Defines the `google_java_format_toolchain` rule.
'''
GoogleJavaFormatToolchainInfo = provider(
fields = {
"google_java_format_deploy_jar": "A JAR `File` containing Google Java Format and all of its run-time dependencies.",
"colordiff_executable": "A `File` pointing to `colordiff` executable (in ... | """Defines the `google_java_format_toolchain` rule.
"""
google_java_format_toolchain_info = provider(fields={'google_java_format_deploy_jar': 'A JAR `File` containing Google Java Format and all of its run-time dependencies.', 'colordiff_executable': 'A `File` pointing to `colordiff` executable (in the host configuratio... |
def getScore(savings, monthly, bills, cost, payDay):
score = 0
if cost > savings:
score = 0
elif savings < 1000:
score = savings/pow(cost,1.1)
else:
a = savings/(cost*1.1)
score += (1300*(monthly-bills))/(max(1,a)*pow(cost,1.1)*pow(payDay,0.8)) + (30*savings)/(p... | def get_score(savings, monthly, bills, cost, payDay):
score = 0
if cost > savings:
score = 0
elif savings < 1000:
score = savings / pow(cost, 1.1)
else:
a = savings / (cost * 1.1)
score += 1300 * (monthly - bills) / (max(1, a) * pow(cost, 1.1) * pow(payDay, 0.8)) + 30 * s... |
#!/usr/bin/env python
# Copyright 2017 The Forseti Security Authors. All rights reserved.
#
# 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
#
#... | """Test instances data."""
fake_api_response1 = [{'kind': 'compute#instance', 'id': '6440513679799924564', 'creationTimestamp': '2017-05-26T22:08:11.094-07:00', 'name': 'iap-ig-79bj', 'tags': {'items': ['iap-tag'], 'fingerprint': 'gilEhx3hEXk='}, 'machineType': 'https://www.googleapis.com/compute/v1/projects/project1/z... |
s=input("Enter string: ")
word=s.split()
word=list(reversed(word))
print("OUTPUT: ",end="")
print(" ".join(word)) | s = input('Enter string: ')
word = s.split()
word = list(reversed(word))
print('OUTPUT: ', end='')
print(' '.join(word)) |
# encoding: utf-8
__author__ = "Patrick Lampe"
__email__ = "uni at lampep.de"
class Point:
def __init__(self, id, location):
self.id = id
self.location = location
def getId(self):
return self.id
def get_distance_in_m(self, snd_node):
return self.get_distance_in_km(snd_n... | __author__ = 'Patrick Lampe'
__email__ = 'uni at lampep.de'
class Point:
def __init__(self, id, location):
self.id = id
self.location = location
def get_id(self):
return self.id
def get_distance_in_m(self, snd_node):
return self.get_distance_in_km(snd_node) * 1000
de... |
# Given a linked list, remove the n-th node from the end of list and return its head.
class ListNode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
class Solution:
def removeNthFromEnd(self, head: ListNode, n: int):
# maintaining dummy to resolve edge cases
... | class Listnode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
class Solution:
def remove_nth_from_end(self, head: ListNode, n: int):
dummy = list_node(0)
dummy.next = head
(prev_ptr, next_ptr) = (dummy, dummy)
for i in range(n + 1):
... |
def bmi_calculator(weight, height):
'''
Function calculates bmi according to passed arguments
weight (int or float) = weight of the person; ex: 61 or 61.0 kg
height (float) = height of the person, in meter; ex: 1.7 m
'''
bmi = weight / (height**2)
return bmi | def bmi_calculator(weight, height):
"""
Function calculates bmi according to passed arguments
weight (int or float) = weight of the person; ex: 61 or 61.0 kg
height (float) = height of the person, in meter; ex: 1.7 m
"""
bmi = weight / height ** 2
return bmi |
class VertexWeightProximityModifier:
falloff_type = None
mask_constant = None
mask_tex_map_object = None
mask_tex_mapping = None
mask_tex_use_channel = None
mask_tex_uv_layer = None
mask_texture = None
mask_vertex_group = None
max_dist = None
min_dist = None
proximity_geometr... | class Vertexweightproximitymodifier:
falloff_type = None
mask_constant = None
mask_tex_map_object = None
mask_tex_mapping = None
mask_tex_use_channel = None
mask_tex_uv_layer = None
mask_texture = None
mask_vertex_group = None
max_dist = None
min_dist = None
proximity_geometr... |
class Solution:
def trimMean(self, arr: List[int]) -> float:
count = int(len(arr) * 0.05)
arr = sorted(arr)[count:-count]
return sum(arr) / len(arr)
| class Solution:
def trim_mean(self, arr: List[int]) -> float:
count = int(len(arr) * 0.05)
arr = sorted(arr)[count:-count]
return sum(arr) / len(arr) |
class Solution:
# @return a list of integers
def getRow(self, rowIndex):
row = []
for i in range(rowIndex+1):
n = i+1
tmp = [1]*n
for j in range(1, n-1):
tmp[j] = row[j-1] + row[j]
row = tmp
return row
| class Solution:
def get_row(self, rowIndex):
row = []
for i in range(rowIndex + 1):
n = i + 1
tmp = [1] * n
for j in range(1, n - 1):
tmp[j] = row[j - 1] + row[j]
row = tmp
return row |
def get_twos_sum(result, arr):
i, k = 0, len(arr) - 1
while i < k:
a, b = arr[i], arr[k]
res = a + b
if res == result:
return (a, b)
elif res < result:
i += 1
else:
k -= 1
def get_threes_sum(result, arr):
arr.sort()
for i in r... | def get_twos_sum(result, arr):
(i, k) = (0, len(arr) - 1)
while i < k:
(a, b) = (arr[i], arr[k])
res = a + b
if res == result:
return (a, b)
elif res < result:
i += 1
else:
k -= 1
def get_threes_sum(result, arr):
arr.sort()
for... |
# Skill: Bitwise XOR
#Given an array of integers, arr, where all numbers occur twice except one number which occurs once, find the number. Your solution should ideally be O(n) time and use constant extra space.
#Example:
#Input: arr = [7, 3, 5, 5, 4, 3, 4, 8, 8]
#Output: 7
#Analysis
# Exploit the question of all numbe... | class Solution(object):
def find_single(self, nums):
tmp = 0
for n in nums:
tmp = tmp ^ n
return tmp
if __name__ == '__main__':
nums = [1, 1, 3, 4, 4, 5, 6, 5, 6]
print(solution().findSingle(nums)) |
email = input("What is your email id ").strip()
user_name = email[:email.index('@')]
domain_name = email[email.index('@')+1:]
result = "Your username is '{}' and your domain is '{}'".format(user_name, domain_name)
print(result)
| email = input('What is your email id ').strip()
user_name = email[:email.index('@')]
domain_name = email[email.index('@') + 1:]
result = "Your username is '{}' and your domain is '{}'".format(user_name, domain_name)
print(result) |
def step(part, instruction, pos, dir):
c, n = instruction
if c in "FNEWS":
change = {"N": 1j, "E": 1, "W": -1, "S": -1j, "F": dir}[c] * n
if c == "F" or part == 1:
return pos + change, dir
else:
return pos, dir + change
else:
return pos, dir * (1j - 2j... | def step(part, instruction, pos, dir):
(c, n) = instruction
if c in 'FNEWS':
change = {'N': 1j, 'E': 1, 'W': -1, 'S': -1j, 'F': dir}[c] * n
if c == 'F' or part == 1:
return (pos + change, dir)
else:
return (pos, dir + change)
else:
return (pos, dir * (... |
#!/usr/bin/env python
# coding: utf-8
def mi_funcion():
print("una funcion")
class MiClase:
def __init__(self):
print ("una clase")
print ("un modulo") | def mi_funcion():
print('una funcion')
class Miclase:
def __init__(self):
print('una clase')
print('un modulo') |
NON_RELATION_TAG = "NonRel"
BRAT_REL_TEMPLATE = "R{}\t{} Arg1:{} Arg2:{}"
EN1_START = "[s1]"
EN1_END = "[e1]"
EN2_START = "[s2]"
EN2_END = "[e2]"
SPEC_TAGS = [EN1_START, EN1_END, EN2_START, EN2_END] | non_relation_tag = 'NonRel'
brat_rel_template = 'R{}\t{} Arg1:{} Arg2:{}'
en1_start = '[s1]'
en1_end = '[e1]'
en2_start = '[s2]'
en2_end = '[e2]'
spec_tags = [EN1_START, EN1_END, EN2_START, EN2_END] |
class InvalidEpubException(Exception):
'''Exception class to hold errors that occur during processing of an ePub file'''
archive = None
def __init__(self, *args, **kwargs):
if 'archive' in kwargs:
self.archive = kwargs['archive']
super(InvalidEpubException, self... | class Invalidepubexception(Exception):
"""Exception class to hold errors that occur during processing of an ePub file"""
archive = None
def __init__(self, *args, **kwargs):
if 'archive' in kwargs:
self.archive = kwargs['archive']
super(InvalidEpubException, self).__init__(*args) |
S = input()
if S == 'RRR':
print(3)
elif S.find('RR') != -1:
print(2)
elif S == 'SSS':
print(0)
else:
print(1) | s = input()
if S == 'RRR':
print(3)
elif S.find('RR') != -1:
print(2)
elif S == 'SSS':
print(0)
else:
print(1) |
# These are the compilation flags that will be used in case there's no
# compilation database set.
flags = [
'-Wall',
'-Wextra',
'-std=c++14',
'-stdlib=libc++',
'-x', 'c++',
'-I', '.',
'-I', 'include',
'-isystem', '/usr/include/c++/v1',
'-isystem', '/usr/include'
]
def FlagsForFile... | flags = ['-Wall', '-Wextra', '-std=c++14', '-stdlib=libc++', '-x', 'c++', '-I', '.', '-I', 'include', '-isystem', '/usr/include/c++/v1', '-isystem', '/usr/include']
def flags_for_file(filename):
return {'flags': flags, 'do_cache': True} |
# Link to the problem: http://www.spoj.com/problems/ANARC09A/
def main():
n = input()
count = 1
while n[0] != '-':
o, c, ans = 0, 0, 0
for i in n:
if i == '{':
o += 1
elif i == '}':
if o > 0:
o -= 1
... | def main():
n = input()
count = 1
while n[0] != '-':
(o, c, ans) = (0, 0, 0)
for i in n:
if i == '{':
o += 1
elif i == '}':
if o > 0:
o -= 1
else:
c += 1
ans += o // 2 + c ... |
# Credits:
# 1) https://gist.github.com/evansneath/4650991
# 2) https://www.tutorialspoint.com/How-to-convert-string-to-binary-in-Python
def crc(msg, div, code='000'):
# Append the code to the message. If no code is given, default to '000'
msg = msg + code
# Convert msg and div into list form for easier ... | def crc(msg, div, code='000'):
msg = msg + code
msg = list(msg)
div = list(div)
for i in range(len(msg) - len(code)):
if msg[i] == '1':
for j in range(len(div)):
msg[i + j] = str(int(msg[i + j]) ^ int(div[j]))
return ''.join(msg[-len(code):])
print("Sender's side.... |
class HDateException(Exception):
pass
class HMoneyException(Exception):
pass
class Dict_Exception(Exception):
pass
| class Hdateexception(Exception):
pass
class Hmoneyexception(Exception):
pass
class Dict_Exception(Exception):
pass |
# -*- coding: utf-8 -*-
__author__ = 'PCPC'
sumList = [n for n in range(1000) if n%3==0 or n%5==0]
print(sum(sumList)) | __author__ = 'PCPC'
sum_list = [n for n in range(1000) if n % 3 == 0 or n % 5 == 0]
print(sum(sumList)) |
def factory(x):
def fn():
return x
return fn
a1 = factory("foo")
a2 = factory("bar")
print(a1())
print(a2())
| def factory(x):
def fn():
return x
return fn
a1 = factory('foo')
a2 = factory('bar')
print(a1())
print(a2()) |
def find_pivot(arr, low, high):
if high < low:
return -1
if high == low:
return low
mid = int((low + high)/2)
if mid < high and arr[mid] > arr[mid + 1]:
return mid
if mid > low and arr[mid] < arr[mid - 1]:
return mid-1
if arr[low] >= arr[mid]:
return fin... | def find_pivot(arr, low, high):
if high < low:
return -1
if high == low:
return low
mid = int((low + high) / 2)
if mid < high and arr[mid] > arr[mid + 1]:
return mid
if mid > low and arr[mid] < arr[mid - 1]:
return mid - 1
if arr[low] >= arr[mid]:
return f... |
_base_ = './pascal_voc12.py'
# dataset settings
data = dict(
train=dict(
ann_dir='SegmentationClassAug',
split=[
'ImageSets/Segmentation/train.txt',
'ImageSets/Segmentation/aug.txt'
]
),
val=dict(
ann_dir='SegmentationClassAug',
),
test=dict(
... | _base_ = './pascal_voc12.py'
data = dict(train=dict(ann_dir='SegmentationClassAug', split=['ImageSets/Segmentation/train.txt', 'ImageSets/Segmentation/aug.txt']), val=dict(ann_dir='SegmentationClassAug'), test=dict(ann_dir='SegmentationClassAug')) |
def out(status, message, padding=0, custom=None):
if status == '?':
return input(
' ' * padding
+ '\033[1;36m'
+ '[?]'
+ '\033[0;0m'
+ ' ' + message
+ ': '
)
elif status == 'I':
print(
' ' * padding
... | def out(status, message, padding=0, custom=None):
if status == '?':
return input(' ' * padding + '\x1b[1;36m' + '[?]' + '\x1b[0;0m' + ' ' + message + ': ')
elif status == 'I':
print(' ' * padding + '\x1b[1;32m[' + (str(custom) if custom != None else 'I') + ']\x1b[0;0m' + ' ' + message)
elif ... |
description = ''
pages = ['header']
def setup(data):
pass
def test(data):
navigate('http://store.demoqa.com/')
header.verify_product_categories('Accessories, iMacs, iPads, iPhones, iPods, MacBooks')
capture('Verify product categories')
def teardown(data):
pass
| description = ''
pages = ['header']
def setup(data):
pass
def test(data):
navigate('http://store.demoqa.com/')
header.verify_product_categories('Accessories, iMacs, iPads, iPhones, iPods, MacBooks')
capture('Verify product categories')
def teardown(data):
pass |
while True:
e = str(input()).split()
a = int(e[0])
b = int(e[1])
if a == 0 == b: break
print(2 * a - b)
| while True:
e = str(input()).split()
a = int(e[0])
b = int(e[1])
if a == 0 == b:
break
print(2 * a - b) |
#
# PySNMP MIB module CISCO-LWAPP-LINKTEST-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-LWAPP-LINKTEST-MIB
# Produced by pysmi-0.3.4 at Wed May 1 12:05:43 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.... | (octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, value_range_constraint, constraints_intersection, value_size_constraint, constraints_union) ... |
# Test that returning of NotImplemented from binary op methods leads to
# TypeError.
try:
NotImplemented
except NameError:
print("SKIP")
raise SystemExit
class C:
def __init__(self, value):
self.value = value
def __str__(self):
return "C({})".format(self.value)
def __add__(sel... | try:
NotImplemented
except NameError:
print('SKIP')
raise SystemExit
class C:
def __init__(self, value):
self.value = value
def __str__(self):
return 'C({})'.format(self.value)
def __add__(self, rhs):
print(self, '+', rhs)
return NotImplemented
def __sub_... |
# POWER OF THREE LEETCODE SOLUTION:
# creating a class.
class Solution(object):
# creating a function to solve the problem.
def isPowerOfThree(self, n):
# creating a variable to track the exponent.
i = 0
# creating a while-loop to iterate until the desired number.
... | class Solution(object):
def is_power_of_three(self, n):
i = 0
while 3 ** i <= n:
if 3 ** i == n:
return True
i += 1
return False |
if False:
print("Really, really false.")
elif False:
print("nested")
else:
if "seems rediculous":
print("it is.")
| if False:
print('Really, really false.')
elif False:
print('nested')
elif 'seems rediculous':
print('it is.') |
nome = str(input('Qual e o seu nome?'))
if nome =='Gustavo':
print('Que nome lindo voce tem!')
else:
print('Seu nome e tao normal!')
print('Bom dia {}!'.format(nome))
| nome = str(input('Qual e o seu nome?'))
if nome == 'Gustavo':
print('Que nome lindo voce tem!')
else:
print('Seu nome e tao normal!')
print('Bom dia {}!'.format(nome)) |
class DescriptorTypesEnum():
_ECFP = "ecfp"
_ECFP_COUNTS = "ecfp_counts"
_MACCS_KEYS = "maccs_keys"
_AVALON = "avalon"
@property
def ECFP(self):
return self._ECFP
@ECFP.setter
def ECFP(self, value):
raise ValueError("Do not assign value to a DescriptorTypesEnum field")
... | class Descriptortypesenum:
_ecfp = 'ecfp'
_ecfp_counts = 'ecfp_counts'
_maccs_keys = 'maccs_keys'
_avalon = 'avalon'
@property
def ecfp(self):
return self._ECFP
@ECFP.setter
def ecfp(self, value):
raise value_error('Do not assign value to a DescriptorTypesEnum field')
... |
day_events_list = input().split("|")
MAX_ENERGY = 100
ORDER_ENERGY = 30
REST_ENERGY = 50
energy = 100
coins = 100
is_not_bankrupt = True
for event in day_events_list:
single_events_list = event.split("-")
name = single_events_list[0]
value = int(single_events_list[1])
if name == "rest":
gaine... | day_events_list = input().split('|')
max_energy = 100
order_energy = 30
rest_energy = 50
energy = 100
coins = 100
is_not_bankrupt = True
for event in day_events_list:
single_events_list = event.split('-')
name = single_events_list[0]
value = int(single_events_list[1])
if name == 'rest':
gained_e... |
def main(j, args, params, tags, tasklet):
params.merge(args)
doc = params.doc
# tags = params.tags
actor=j.apps.actorsloader.getActor("system","gridmanager")
organization = args.getTag("organization")
name = args.getTag("jsname")
out = ''
missing = False
for k,v in {'organizatio... | def main(j, args, params, tags, tasklet):
params.merge(args)
doc = params.doc
actor = j.apps.actorsloader.getActor('system', 'gridmanager')
organization = args.getTag('organization')
name = args.getTag('jsname')
out = ''
missing = False
for (k, v) in {'organization': organization, 'name'... |
class color:
black = "\033[30m"
red = "\033[31m"
green = "\033[32m"
yellow = "\033[33m"
blue = "\033[34m"
magenta = "\033[35m"
cyan = "\033[36m"
white = "\033[37m"
class bright:
black_1 = "\033[1;30m"
red_1 = "\033[1;31m"
green_1 = "\033[1;32m"
yellow_1 = "\033[1;33m"
blue_1 = "\033[1;34m"
... | class Color:
black = '\x1b[30m'
red = '\x1b[31m'
green = '\x1b[32m'
yellow = '\x1b[33m'
blue = '\x1b[34m'
magenta = '\x1b[35m'
cyan = '\x1b[36m'
white = '\x1b[37m'
class Bright:
black_1 = '\x1b[1;30m'
red_1 = '\x1b[1;31m'
green_1 = '\x1b[1;32m'
yellow_1 = '\x1b[1;33m'
... |
##This does nothing yet...
class Broker(object):
def __init__(self):
self.name = 'ETrade'
self.tradeFee = 4.95
| class Broker(object):
def __init__(self):
self.name = 'ETrade'
self.tradeFee = 4.95 |
class Neuron(object):
def __init__(self, *args, **kwargs):
super(Neuron, self).__init__() | class Neuron(object):
def __init__(self, *args, **kwargs):
super(Neuron, self).__init__() |
num = int(input('Digite uma numero:'))
b = bin(num)
o = oct(num)
h = hex(num)
print('''Escolha
[1] binario
[2] octal
[3] hex ''')
opcao = int(input('sua Opcao: '))
if opcao == 1:
print('{} convertido {}'.format(num,b[2:]))
elif opcao == 2:
print('{} convertido {}'.format(num,o[2:]))
elif opcao == 3:
print('... | num = int(input('Digite uma numero:'))
b = bin(num)
o = oct(num)
h = hex(num)
print('Escolha\n[1] binario\n[2] octal\n[3] hex ')
opcao = int(input('sua Opcao: '))
if opcao == 1:
print('{} convertido {}'.format(num, b[2:]))
elif opcao == 2:
print('{} convertido {}'.format(num, o[2:]))
elif opcao == 3:
print(... |
############################################################################
#
# Copyright (C) 2016 The Qt Company Ltd.
# Contact: https://www.qt.io/licensing/
#
# This file is part of Qt Creator.
#
# Commercial License Usage
# Licensees holding valid commercial Qt licenses may use this file in
# accordance with the co... | source('../../shared/qtcreator.py')
qml_editor = ':Qt Creator_QmlJSEditor::QmlJSTextEditorWidget'
outline = ':Qt Creator_QmlJSEditor::Internal::QmlJSOutlineTreeView'
treebase = 'keyinteraction.Resources.keyinteraction\\.qrc./keyinteraction.focus.'
def main():
source_example = os.path.join(Qt5Path.examplesPath(Targ... |
def extra_end(str):
if len(str) <= 2:
return (str * 3)
return (str[-2:]*3)
| def extra_end(str):
if len(str) <= 2:
return str * 3
return str[-2:] * 3 |
class Obstacle(object):
def __init__(self, position):
self.position = position
self.positionHistory = [position]
self.ObstaclePotentialForces = [] | class Obstacle(object):
def __init__(self, position):
self.position = position
self.positionHistory = [position]
self.ObstaclePotentialForces = [] |
#
# PySNMP MIB module CISCO-UNIFIED-COMPUTING-LLDP-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-UNIFIED-COMPUTING-LLDP-MIB
# Produced by pysmi-0.3.4 at Wed May 1 12:16:33 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Pyt... | (object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_union, single_value_constraint, constraints_intersection, value_range_constraint, value_size_constraint) ... |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# input
input_data = []
with open('input.txt', 'r') as f:
lines = f.readlines()
input_data = [l.strip().split(')') for l in lines]
# structures
orbits_down = dict(zip([inp[1] for inp in input_data], [inp[0] for inp in input_data]))
# task 1
to... | input_data = []
with open('input.txt', 'r') as f:
lines = f.readlines()
input_data = [l.strip().split(')') for l in lines]
orbits_down = dict(zip([inp[1] for inp in input_data], [inp[0] for inp in input_data]))
total = 0
all_centers = orbits_down.values()
for (center, satellite) in orbits_down.items():
curr... |
def Num14681():
x = int(input())
y = int(input())
result = 0
if x > 0:
if y > 0:
result = 1
else:
result = 4
else:
if y < 0:
result = 3
else:
result = 2
print(str(result))
Num14681() | def num14681():
x = int(input())
y = int(input())
result = 0
if x > 0:
if y > 0:
result = 1
else:
result = 4
elif y < 0:
result = 3
else:
result = 2
print(str(result))
num14681() |
#Given an array of integers, find the one that appears an odd number of times.
#There will always be only one integer that appears an odd number of times.
def find_it(arr):
res = 0
for element in arr:
res = res ^ element
return res
| def find_it(arr):
res = 0
for element in arr:
res = res ^ element
return res |
__author__ = 'samantha'
def checkio(words):
#l = list()
#for word in words.split():
# l.append(word.isalpha())
print(words)
res = False
l = [wd.isalpha() for wd in words.split()]
#r = [l[i:i+3] for i in range(0,len(l)-3) ]
#print ('r=',r)
print ('l=',l)
if len(l)>3:
p... | __author__ = 'samantha'
def checkio(words):
print(words)
res = False
l = [wd.isalpha() for wd in words.split()]
print('l=', l)
if len(l) > 3:
print('len(l)=', len(l))
print('range', range(0, len(l) - 2))
for i in range(0, len(l) - 2):
print('i=', i)
l... |
class FrontendPortTotalThroughput(object):
def read_get(self, name, idx_name, unity_client):
return unity_client.get_frontend_port_total_iops(idx_name)
class FrontendPortTotalThroughputColumn(object):
def get_idx(self, name, idx, unity_client):
return unity_client.get_frontend_ports()
| class Frontendporttotalthroughput(object):
def read_get(self, name, idx_name, unity_client):
return unity_client.get_frontend_port_total_iops(idx_name)
class Frontendporttotalthroughputcolumn(object):
def get_idx(self, name, idx, unity_client):
return unity_client.get_frontend_ports() |
DEBUG = True
MOLLIE_API_KEY = ''
REDIS_HOST = 'localhost'
COOKIE_NAME = 'Paywall-Voucher'
CSRF_SECRET_KEY = 'NeVeR WoUnD a SnAke KiLl It'
| debug = True
mollie_api_key = ''
redis_host = 'localhost'
cookie_name = 'Paywall-Voucher'
csrf_secret_key = 'NeVeR WoUnD a SnAke KiLl It' |
# Copyright 2017 Rice University
#
# 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 writin... | labels = ['swing', 'awt', 'security', 'sql', 'net', 'xml', 'crypto', 'math']
def get_api(config, calls, apiOrNot):
apis = []
for (call, api_bool) in zip(calls, apiOrNot):
if api_bool and call > 0:
api = config.vocab.chars_api[call]
apis.append(api)
apis_ = []
for api in ... |
__all__ = ['VERSION']
VERSION = '7.6.0'
SAVE_PATH = '~/.spotifydl'
SPOTIPY_CLIENT_ID = "4fe3fecfe5334023a1472516cc99d805"
SPOTIPY_CLIENT_SECRET = "0f02b7c483c04257984695007a4a8d5c"
| __all__ = ['VERSION']
version = '7.6.0'
save_path = '~/.spotifydl'
spotipy_client_id = '4fe3fecfe5334023a1472516cc99d805'
spotipy_client_secret = '0f02b7c483c04257984695007a4a8d5c' |
#!/usr/bin/env python3
print("Hello Inderpal Singh!")
print("Welcome to python scripting.")
print("Learning python opens new doors of opportunity.")
| print('Hello Inderpal Singh!')
print('Welcome to python scripting.')
print('Learning python opens new doors of opportunity.') |
while True:
try:
bil = input("masukan bilangan: ")
bil = int(bil)
break
except ValueError:
print("anda salah memasukan bilangan")
print("anda memasukan bilangan %s, data harus angka" % bil )
print("anda memasukan bilangan", bil) | while True:
try:
bil = input('masukan bilangan: ')
bil = int(bil)
break
except ValueError:
print('anda salah memasukan bilangan')
print('anda memasukan bilangan %s, data harus angka' % bil)
print('anda memasukan bilangan', bil) |
# Comma Code
# Say you have a list value like this:
# spam = ['apples', 'bananas', 'tofu', 'cats']
# Write a function that takes a list value as an argument and returns a string wit
# h all the items separated by a comma and a space, with and inserted before the l
# ast item. For example, passing the previous spam list... | spam = ['apples', 'bananas', 'tofu', 'cats']
def comma_code(l):
if len(l) <= 0:
return ''
elif len(l) == 1:
return l[0]
else:
return ', '.join(l[:-1]) + ' and ' + l[-1]
print(comma_code(spam)) |
a = [1, 0, 5, -2, -5, 7]
soma = a[0] + a[1] + a[5]
print(soma)
a[4] = 100
print(a)
for v in a:
print(v)
| a = [1, 0, 5, -2, -5, 7]
soma = a[0] + a[1] + a[5]
print(soma)
a[4] = 100
print(a)
for v in a:
print(v) |
sums_new_methodology = {
"Total revenue": {
"A01",
"A03",
"A09",
"A10",
"A12",
"A16",
"A18",
"A21",
"A36",
"A44",
"A45",
"A50",
"A54",
"A56",
"A59",
"A60",
"A61",
"A80",
... | sums_new_methodology = {'Total revenue': {'A01', 'A03', 'A09', 'A10', 'A12', 'A16', 'A18', 'A21', 'A36', 'A44', 'A45', 'A50', 'A54', 'A56', 'A59', 'A60', 'A61', 'A80', 'A81', 'A87', 'A89', 'A90', 'A91', 'A92', 'A93', 'A94', 'B01', 'B21', 'B22', 'B30', 'B42', 'B43', 'B46', 'B50', 'B54', 'B59', 'B79', 'B80', 'B89', 'B91'... |
class Solution:
def solve(self, nums, k):
nums = [0]+nums
for i in range(1,len(nums)):
nums[i] += nums[i-1]
sums = [[nums[i] - x for x in sorted(nums[:i])[:k]] for i in range(1,len(nums))]
return sorted(sum(sums,[]))[-k:]
| class Solution:
def solve(self, nums, k):
nums = [0] + nums
for i in range(1, len(nums)):
nums[i] += nums[i - 1]
sums = [[nums[i] - x for x in sorted(nums[:i])[:k]] for i in range(1, len(nums))]
return sorted(sum(sums, []))[-k:] |
class MyParser:
def __init__(self, text_1, text_2):
self.text_1 = text_1
self.text_2 = text_2
def parse_text(self, text):
stack = []
for char in text:
if char != '#':
stack.append(char)
else:
if len(stack) > 0:
... | class Myparser:
def __init__(self, text_1, text_2):
self.text_1 = text_1
self.text_2 = text_2
def parse_text(self, text):
stack = []
for char in text:
if char != '#':
stack.append(char)
elif len(stack) > 0:
stack.pop()
... |
if __name__ == '__main__':
n = int(input())
arr =list(map(int, input().split(" ")))
i = max(arr)
for i in range(0,n):
if max(arr) == i:
arr.remove(max(arr))
arr.sort(reverse=True)
print(arr[0])
| if __name__ == '__main__':
n = int(input())
arr = list(map(int, input().split(' ')))
i = max(arr)
for i in range(0, n):
if max(arr) == i:
arr.remove(max(arr))
arr.sort(reverse=True)
print(arr[0]) |
n=int(input())
p=[[int(i)for i in input().split()] for _ in range(n)]
p.sort(key=lambda x: x[2])
a,b,c=p[-1]
for y in range(101):
for x in range(101):
h=c+abs(a-x)+abs(b-y)
if all(k==max(h-abs(i-x)-abs(y-j),0) for i,j,k in p):
print(x,y,h)
exit() | n = int(input())
p = [[int(i) for i in input().split()] for _ in range(n)]
p.sort(key=lambda x: x[2])
(a, b, c) = p[-1]
for y in range(101):
for x in range(101):
h = c + abs(a - x) + abs(b - y)
if all((k == max(h - abs(i - x) - abs(y - j), 0) for (i, j, k) in p)):
print(x, y, h)
... |
# Copyright (c) 2021 Hashz Software.
class ArgNotFound:
def __init__(self, arg):
print("ArgNotFound: %s" % arg) | class Argnotfound:
def __init__(self, arg):
print('ArgNotFound: %s' % arg) |
#These information comes from Twitter API
#Create a Twitter Account and Get These Information from apps.twitter.com
consumer_key = 'R1feyoEHAw2Lg32k4OKyyn01v'
consumer_secret = 'KdxSi79P7PAjhmY4OYU2VfeKUcaUt4WmyJMb7Oew0nE1M7Ji5h'
access_token = '145566333-KIndElco5MlHXPIGWeGkvjVXlMchLyQI2bMD8BJT'
access_secret = 'iqf... | consumer_key = 'R1feyoEHAw2Lg32k4OKyyn01v'
consumer_secret = 'KdxSi79P7PAjhmY4OYU2VfeKUcaUt4WmyJMb7Oew0nE1M7Ji5h'
access_token = '145566333-KIndElco5MlHXPIGWeGkvjVXlMchLyQI2bMD8BJT'
access_secret = 'iqfFlcM4clh6wCwDSLZaQqJttgstiIybUDOoB3uyzaZx8' |
class lightswitch:
is_on = False
def Flip(self):
#self refers to the instance of the object. needs to be included only when using class, to ensure that it is defined only within the class
self.is_on = not self.is_on #field/attribute
print(self.is_on)
def FlipMany(self, number:... | class Lightswitch:
is_on = False
def flip(self):
self.is_on = not self.is_on
print(self.is_on)
def flip_many(self, number: int):
for i in range(number):
self.Flip()
living_room_light = lightswitch()
bedroom_light = lightswitch()
print('living_room_light:')
living_room_l... |
if __name__ == "__main__":
TC = int(input())
for t in range(0,TC):
N = int(input())
max_score = -1
tie = False
win = 0
for n in range(0,N):
T = [0] * 6
C = list(map(int, input().split()))
for c in range(1,len(C)):
T... | if __name__ == '__main__':
tc = int(input())
for t in range(0, TC):
n = int(input())
max_score = -1
tie = False
win = 0
for n in range(0, N):
t = [0] * 6
c = list(map(int, input().split()))
for c in range(1, len(C)):
T[C... |
def value_at(poly_spec, x):
num=1
total=0
for i,j in enumerate(poly_spec[::-1]):
total+=j*num
num=(num*(x-i))/(i+1)
return round(total, 2) | def value_at(poly_spec, x):
num = 1
total = 0
for (i, j) in enumerate(poly_spec[::-1]):
total += j * num
num = num * (x - i) / (i + 1)
return round(total, 2) |
REV_CLASS_MAP = {
0: "rock",
1: "paper",
2: "scissors",
3: "none"
}
# 0_Rock 1_Paper 2_Scissors
def mapper(val):
return REV_CLASS_MAP[val]
def calculate_winner(move1, move2):
if move1 == move2:
return "Tie"
if move1 == "rock":
if move2 == 2:
... | rev_class_map = {0: 'rock', 1: 'paper', 2: 'scissors', 3: 'none'}
def mapper(val):
return REV_CLASS_MAP[val]
def calculate_winner(move1, move2):
if move1 == move2:
return 'Tie'
if move1 == 'rock':
if move2 == 2:
return 'User'
if move2 == 1:
return 'Computer'... |
class ArtistNotFound(Exception):
pass
class AlbumNotFound(Exception):
pass
| class Artistnotfound(Exception):
pass
class Albumnotfound(Exception):
pass |
standard = {
'rulebook_white': {
'name':'Rulebook White T',
'style': {
'color': '#666666',
'background': '#fff',
'border-color': '#000',
},
},
'rulebook_pink': {
'name':'Rulebook Pink',
'style': {
'color': '#ffffdd',
... | standard = {'rulebook_white': {'name': 'Rulebook White T', 'style': {'color': '#666666', 'background': '#fff', 'border-color': '#000'}}, 'rulebook_pink': {'name': 'Rulebook Pink', 'style': {'color': '#ffffdd', 'background': '#F25292', 'border-color': '#FE98C0'}}, 'rulebook_blue': {'name': 'Rulebook Blue', 'style': {'co... |
def recurFibonaci(number):
if number <= 1:
return number
else:
return recurFibonaci(number - 1) + recurFibonaci(number - 2)
numberTerms = 10
if numberTerms <= 0:
print("enter positive integers")
else:
print("fibonaci sequence ")
for i in range(numberTerms):
print(recurFibon... | def recur_fibonaci(number):
if number <= 1:
return number
else:
return recur_fibonaci(number - 1) + recur_fibonaci(number - 2)
number_terms = 10
if numberTerms <= 0:
print('enter positive integers')
else:
print('fibonaci sequence ')
for i in range(numberTerms):
print(recur_fi... |
cadena_ingresada = input("Ingrese la fecha actual en formato dd/mm/yyyy: ");
separado = cadena_ingresada.split('/');
print(separado);
print(
f'Dia: {separado[0]}', '-',
f'Mes: {separado[1]}', '-',
f'Anio: {separado[2]}'
);
c = cadena_ingresada;
print(
f'Dia: {c[0]}{c[1]}', '-',
f'Mes: {c[3]}{c[... | cadena_ingresada = input('Ingrese la fecha actual en formato dd/mm/yyyy: ')
separado = cadena_ingresada.split('/')
print(separado)
print(f'Dia: {separado[0]}', '-', f'Mes: {separado[1]}', '-', f'Anio: {separado[2]}')
c = cadena_ingresada
print(f'Dia: {c[0]}{c[1]}', '-', f'Mes: {c[3]}{c[4]}', '-', f'Anio: {c[6]}{c[7]}{c... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.