content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
"""
Check that connecting from a non-local IP will result in an AddressBindingError
"""
#pragma repy
localip = getmyip()
localport = 12345
remoteport = 80
timeout = 0.00001
try:
remoteip = gethostbyname('www.google.com')
except NetworkAddressError:
log("Name lookup failed for www.google.com",'\n')
exitall()
try... | """
Check that connecting from a non-local IP will result in an AddressBindingError
"""
localip = getmyip()
localport = 12345
remoteport = 80
timeout = 1e-05
try:
remoteip = gethostbyname('www.google.com')
except NetworkAddressError:
log('Name lookup failed for www.google.com', '\n')
exitall()
try:
open... |
#file = open('sample.txt','r')
#contents = file.read()
#file.close()
#print(contents)
with open('file_example.txt', 'r') as file:
contents = file.read()
print(contents)
| with open('file_example.txt', 'r') as file:
contents = file.read()
print(contents) |
#!/usr/bin/env python3
"""CrooHtmlReportTracks
Author:
Jin Lee (leepc12@gmail.com) at ENCODE-DCC
"""
class CrooHtmlReportTracks(object):
HEAD = """
<link rel="stylesheet" type="text/css" href=\
"http://epigenomegateway.wustl.edu/legacy/style.css" />
<script type="text/javascript" src="http://epigenom... | """CrooHtmlReportTracks
Author:
Jin Lee (leepc12@gmail.com) at ENCODE-DCC
"""
class Croohtmlreporttracks(object):
head = '\n <link rel="stylesheet" type="text/css" href="http://epigenomegateway.wustl.edu/legacy/style.css" />\n <script type="text/javascript" src="http://epigenomegateway.wustl.edu/legacy/... |
def buildPalindrome(st):
for i in range(len(st)):
sub = st[i : len(st)]
if sub[::-1] == sub:
missing = st[0:i]
return st + missing[::-1]
return st
| def build_palindrome(st):
for i in range(len(st)):
sub = st[i:len(st)]
if sub[::-1] == sub:
missing = st[0:i]
return st + missing[::-1]
return st |
n, k = map(int, input().split())
count = 0
for _ in range(n):
a = int(input())
if a%k == 0:
count +=1
print(count) | (n, k) = map(int, input().split())
count = 0
for _ in range(n):
a = int(input())
if a % k == 0:
count += 1
print(count) |
# Programa em q o usuario possa adicionar valores numericos em uma lista, Caso o numero ja exista ele nao sera adicionado
# no final serao exibidos todos os valores unicos em ordem crescente
lista = []
resp = ''
old = 0
while True:
old = int(input('Digite um valor: '))
if old in lista:
print('Valor r... | lista = []
resp = ''
old = 0
while True:
old = int(input('Digite um valor: '))
if old in lista:
print('Valor repetido, nao vou adicionar...')
else:
lista.append(old)
print('Valor adicionado com sucesso...')
resp = input('Deseja continuar? [S/N] ').strip().upper()[0]
while res... |
male = [
'AKIO',
'AKIRA',
'AOI',
'ARATA',
'ASUKA',
'AYUMU',
'DAICHI',
'DAIKI',
'DAISUKE',
'GORO',
'GOROU',
'HACHIRO',
'HACHIROU',
'HARU',
'HARUKA',
'HARUKI',
'HARUTO',
'HAYATE',
'HAYATO',
'HIBIKI',
'HIDEAKI',
'HIDEKI',
'HIDEYOSH... | male = ['AKIO', 'AKIRA', 'AOI', 'ARATA', 'ASUKA', 'AYUMU', 'DAICHI', 'DAIKI', 'DAISUKE', 'GORO', 'GOROU', 'HACHIRO', 'HACHIROU', 'HARU', 'HARUKA', 'HARUKI', 'HARUTO', 'HAYATE', 'HAYATO', 'HIBIKI', 'HIDEAKI', 'HIDEKI', 'HIDEYOSHI', 'HIKARI', 'HIKARU', 'HINATA', 'HIRAKU', 'HIROKI', 'HIROSHI', 'HIROTO', 'ICHIRO', 'ICHIROU... |
class Scale:
def __init__(self, tonic):
if tonic in ["F", "Bb", "Eb", "Ab", "Db", "Gb", "d", "g", "c", "f", "bb", "eb", ]:
notes = ["A", "Bb", "B", "C", "Db", "D",
"Eb", "E", "F", "Gb", "G", "Ab", ]
else:
notes = ["A", "A#", "B", "C", "C#", "D",
... | class Scale:
def __init__(self, tonic):
if tonic in ['F', 'Bb', 'Eb', 'Ab', 'Db', 'Gb', 'd', 'g', 'c', 'f', 'bb', 'eb']:
notes = ['A', 'Bb', 'B', 'C', 'Db', 'D', 'Eb', 'E', 'F', 'Gb', 'G', 'Ab']
else:
notes = ['A', 'A#', 'B', 'C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#']
... |
# binStrToBytes : Converts a binary string to an array of bytes.
# @param bin : The binary string to be converted to byte array.
# @return : The byte array representation of the provided binary string.
def binStrToBytes(bin):
if (not isinstance(bin, str)):
raise TypeError("Unexpected type, expected 'str'")... | def bin_str_to_bytes(bin):
if not isinstance(bin, str):
raise type_error("Unexpected type, expected 'str'")
bin = bin.replace(' ', '')
size = len(bin)
if size % 8 != 0:
raise exception('Invalid length, cannot convert to byte array')
return bytes([int(bin[i:i + 8], 2) for i in range(0... |
# Hidden Street - Ardentmill :: 910001000
# Gere :: Master of Smithing :: 9031003
MINING_SKILL = 92010000
SMITHING_CRAFT_SKILL = 92020000
ACCESSORY_CRAFT_SKILL = 92030000
ALCHEMY_CRAFT_SKILL = 92040000
FEE = [5000, 15000, 25000, 40000, 60000, 85000, 115000, 150000, 190000, 235000]
if not sm.hasSkill(SMITHING_CRAFT_SK... | mining_skill = 92010000
smithing_craft_skill = 92020000
accessory_craft_skill = 92030000
alchemy_craft_skill = 92040000
fee = [5000, 15000, 25000, 40000, 60000, 85000, 115000, 150000, 190000, 235000]
if not sm.hasSkill(SMITHING_CRAFT_SKILL):
selection = sm.sendSay('I am #bGere#k, master Blacksmith. What do you want... |
''' Dataset 1
# This cases have displaced or incorrect annotation files
# Some maybe be corrected using the map below
skipCase = ['LUNG1-034',
'LUNG1-040',
'LUNG1-044',
'LUNG1-068',
'LUNG1-083',
'LUNG1-084',
'LUNG1-094',
'LUNG1-096',
... | """ Dataset 1
# This cases have displaced or incorrect annotation files
# Some maybe be corrected using the map below
skipCase = ['LUNG1-034',
'LUNG1-040',
'LUNG1-044',
'LUNG1-068',
'LUNG1-083',
'LUNG1-084',
'LUNG1-094',
'LUNG1-096',
... |
(5)(3)
l = [a, 21, l]
l(3)
a(20, 21, *n, b=m)
| 5(3)
l = [a, 21, l]
l(3)
a(20, 21, *n, b=m) |
ages = [5, 12, 17, 18, 24, 32]
def myFunc(x):
if x < 18:
return False
else:
return True
adults = filter(myFunc, ages)
for x in adults:
print(x) | ages = [5, 12, 17, 18, 24, 32]
def my_func(x):
if x < 18:
return False
else:
return True
adults = filter(myFunc, ages)
for x in adults:
print(x) |
def fraction(a, b):
try:
return "%.1f" % (float(a) / float(b))
except (ValueError, ZeroDivisionError):
return "ERR"
| def fraction(a, b):
try:
return '%.1f' % (float(a) / float(b))
except (ValueError, ZeroDivisionError):
return 'ERR' |
# M-1
x1 = 12
y1 = 5
z1 = x1*y1
print(z1)
# M-2
eggs = 12
unit_price = 5
total_price = eggs*unit_price
print(total_price)
# M-3
a12345 = 12
b12345 = 5
c12345 = a12345*b12345
print(c12345)
| x1 = 12
y1 = 5
z1 = x1 * y1
print(z1)
eggs = 12
unit_price = 5
total_price = eggs * unit_price
print(total_price)
a12345 = 12
b12345 = 5
c12345 = a12345 * b12345
print(c12345) |
# SAVE PATIENTS
n = int(input())
strength = list(map(int, input().split()))
patient = list(map(int, input().split()))
strength.sort()
patient.sort()
for i in range(n):
if strength[i]<patient[i]:
print("No")
break
else:
print("Yes")
| n = int(input())
strength = list(map(int, input().split()))
patient = list(map(int, input().split()))
strength.sort()
patient.sort()
for i in range(n):
if strength[i] < patient[i]:
print('No')
break
else:
print('Yes') |
# 06 Magic Methods
# https://rszalski.github.io/magicmethods/
# Magiv Methods are called automaticly by Python interpreter, depending on how we use our object and class
class Point:
point_color = "Red"
@classmethod
def zero(cls):
return cls(0, 0, 0)
def __init__(self, x, y, z):
self... | class Point:
point_color = 'Red'
@classmethod
def zero(cls):
return cls(0, 0, 0)
def __init__(self, x, y, z):
self.x = x
self.y = y
self.z = z
def __str__(self):
return f'{self.x}, {self.y}, {self.z}'
def draw(self):
print(f'Point coordinates (... |
# Implement Rand10() Using Rand7()
'''
Given the API rand7 which generates a uniform random integer in the range 1 to 7, write a function rand10 which generates a uniform random integer in the range 1 to 10. You can only call the API rand7 and you shouldn't call any other API. Please don't use the system's Math.random... | """
Given the API rand7 which generates a uniform random integer in the range 1 to 7, write a function rand10 which generates a uniform random integer in the range 1 to 10. You can only call the API rand7 and you shouldn't call any other API. Please don't use the system's Math.random().
Notice that Each test case has ... |
def BST_nearest_val(data, val):
"""Nearest Value in a Binary Seach Tree."""
nearest = abs(val - data.root.val)
hour = data.root.val
def _walk(node=None):
nonlocal nearest, hour
if node is None:
return
if node.left is not None:
_walk(node.left)
#... | def bst_nearest_val(data, val):
"""Nearest Value in a Binary Seach Tree."""
nearest = abs(val - data.root.val)
hour = data.root.val
def _walk(node=None):
nonlocal nearest, hour
if node is None:
return
if node.left is not None:
_walk(node.left)
if ... |
#EP:1
"""
import math
r = eval(raw_input('Please enter the length from the center to a vertex: '))
s = 2 * r * math.sin(math.pi/5)
area = 5 * s * s / (4*math.tan(math.pi/5))
print('The area of the pentagon is: {:.2f}'.format(area)) """
#EP:2
"""
import math
x1,y1 = eval(raw_input('Please enter point 1 (latitude and ... | """
import math
r = eval(raw_input('Please enter the length from the center to a vertex: '))
s = 2 * r * math.sin(math.pi/5)
area = 5 * s * s / (4*math.tan(math.pi/5))
print('The area of the pentagon is: {:.2f}'.format(area)) """
"\nimport math\nx1,y1 = eval(raw_input('Please enter point 1 (latitude and longitude) in ... |
# Python vs. C++ Example 4
# Rachel J. Morris, 2013 - RachelJMorris@gmail.com, Moosader.com, github.com/Moosader
# MIT License
# Generally, these shouldn't be stored in separate lists; we would create
# a class to store name & age, but we will do this in a later example.
lstStudentNames = []
lstStudentAges = []
doneW... | lst_student_names = []
lst_student_ages = []
done_with_program = False
while not doneWithProgram:
print('\n')
print('What would you like to do?')
print('1. Add another student')
print('2. End')
choice = input('? ')
while int(choice) != 1 and int(choice) != 2:
choice = input('Invalid choi... |
# Definition for a binary tree node
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
# @param root, a tree node
# @return an integer
def sumNumbers(self, root):
if not root:
return 0
qu... | class Solution:
def sum_numbers(self, root):
if not root:
return 0
queue = []
values = []
self.dfs(root, queue, values)
return sum(values)
def dfs(self, root, queue, values):
queue.append(root)
if not root.left and (not root.right):
... |
#!/usr/bin/env python
# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
# Simple test on a grid texture
command = testshade("-t 1 -groupname Beatles -layer Cake test")
command += testshade("-t 1 -g ... | command = testshade('-t 1 -groupname Beatles -layer Cake test')
command += testshade('-t 1 -g 2 2 -groupname Beatles -layer Cake test_v_name') |
"""The holiest cli template system
tmplr provides modules for working with tmplr templates, called Temples. Most
Temples are represented by actual files on disk, so a convenience function is
provided to create a Temple from a path. Programmatic access is also provided.
Modules:
temple -- provides the Temple class... | """The holiest cli template system
tmplr provides modules for working with tmplr templates, called Temples. Most
Temples are represented by actual files on disk, so a convenience function is
provided to create a Temple from a path. Programmatic access is also provided.
Modules:
temple -- provides the Temple class... |
#!/usr/bin/env python
"""
/*******************************************************************************
* Copyright (c) cortical.io GmbH. All rights reserved.
*
* This software is confidential and proprietary information.
* You shall use it only in accordance with the terms of the
* license agreement you ente... | """
/*******************************************************************************
* Copyright (c) cortical.io GmbH. All rights reserved.
*
* This software is confidential and proprietary information.
* You shall use it only in accordance with the terms of the
* license agreement you entered into with cortical... |
######################################
# general weight sampling
######################################
def gaussPertubation(weight,weightStt,offsetStd=0.0,out=None,n=1):
"""" very stupid sampling"""
pass
######################################
# general weight sampling
#####################################... | def gauss_pertubation(weight, weightStt, offsetStd=0.0, out=None, n=1):
"""" very stupid sampling"""
pass |
table = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
flag = [ord("X") for i in range(0x64)]
flag[0] = ord(table[0x1c])
flag[1] = ord(table[0x36])
flag[2] = ord(table[(0x1c + 0x36) >> 2])
flag[10] = flag[2]
flag[3] = 0x6a
flag[4] = flag[0] + 1
for p in [0xc, 0x16, 0x18]:
flag[p] = flag[4] - 1
fl... | table = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
flag = [ord('X') for i in range(100)]
flag[0] = ord(table[28])
flag[1] = ord(table[54])
flag[2] = ord(table[28 + 54 >> 2])
flag[10] = flag[2]
flag[3] = 106
flag[4] = flag[0] + 1
for p in [12, 22, 24]:
flag[p] = flag[4] - 1
flag[6] = flag[3] - ... |
class Configuration:
DB = 'aiohttpdemo_polls'
USER = 'aiohttpdemo_user'
PASS = 'aiohttpdemo_pass'
HOST = 'localhost'
PORT = '5432'
| class Configuration:
db = 'aiohttpdemo_polls'
user = 'aiohttpdemo_user'
pass = 'aiohttpdemo_pass'
host = 'localhost'
port = '5432' |
class Provider(object):
base_url = None
def __init__(self, url: str) -> None:
self.base_url = url
def watch(self):
pass | class Provider(object):
base_url = None
def __init__(self, url: str) -> None:
self.base_url = url
def watch(self):
pass |
#
# PySNMP MIB module XYLAN-BASE-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/XYLAN-BASE-MIB
# Produced by pysmi-0.3.4 at Wed May 1 11:44:24 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2... | (octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_intersection, value_range_constraint, constraints_union, value_size_constraint, single_value_constraint) ... |
pares, impares, positivos, negativos = 0, 0, 0, 0
for i in range(5):
num = int(input())
if num % 2 == 0:
pares += 1
else:
impares += 1
if num > 0:
positivos += 1
elif num < 0:
negativos += 1
print('{} valor(es) par(es)'.format(pares))
print('{} valor(es) i... | (pares, impares, positivos, negativos) = (0, 0, 0, 0)
for i in range(5):
num = int(input())
if num % 2 == 0:
pares += 1
else:
impares += 1
if num > 0:
positivos += 1
elif num < 0:
negativos += 1
print('{} valor(es) par(es)'.format(pares))
print('{} valor(es) impar(es)... |
arquivo = open('argv.py', 'r')
for line in arquivo:
print(line.rstrip())
| arquivo = open('argv.py', 'r')
for line in arquivo:
print(line.rstrip()) |
class D(object):
pass
class E(object):
pass
class F(object):
pass
class B(E, D):
pass
class C(D, F):
pass
class A(B, C):
pass
| class D(object):
pass
class E(object):
pass
class F(object):
pass
class B(E, D):
pass
class C(D, F):
pass
class A(B, C):
pass |
def null(X):
null_list = X.isnull().sum()
return null_list
| def null(X):
null_list = X.isnull().sum()
return null_list |
def findDecision(obj): #obj[0]: Driving_to, obj[1]: Passanger, obj[2]: Weather, obj[3]: Temperature, obj[4]: Time, obj[5]: Coupon, obj[6]: Coupon_validity, obj[7]: Gender, obj[8]: Age, obj[9]: Maritalstatus, obj[10]: Children, obj[11]: Education, obj[12]: Occupation, obj[13]: Income, obj[14]: Bar, obj[15]: Coffeehouse,... | def find_decision(obj):
if obj[13] <= 6:
if obj[5] > 0:
if obj[20] <= 2:
if obj[15] <= 2.0:
if obj[9] <= 2:
if obj[1] > 0:
if obj[14] > -1.0:
if obj[10] <= 0:
... |
class Question(object):
def __init__(self, id, title, text):
self._id = id
self._title = title
self._text = text
self._answers = []
self._chosen_answer = None
@property
def id(self):
return self._id
@id.setter
def id(self, id):
self._id = i... | class Question(object):
def __init__(self, id, title, text):
self._id = id
self._title = title
self._text = text
self._answers = []
self._chosen_answer = None
@property
def id(self):
return self._id
@id.setter
def id(self, id):
self._id = id... |
class MinStack(object):
def __init__(self):
"""
initialize your data structure here.
"""
self.data=[]
self.minData=[] # to store the min
def push(self, x):
"""
to add a number to the stack, and add min to minData
:type x: int
:rtype: Non... | class Minstack(object):
def __init__(self):
"""
initialize your data structure here.
"""
self.data = []
self.minData = []
def push(self, x):
"""
to add a number to the stack, and add min to minData
:type x: int
:rtype: None
"""
... |
# -*- coding: utf-8 -*-
name = 'usdview'
version = '18.11'
requires = [
'pyside-1.2',
'usd-18.11'
]
def commands():
env.DEFAULT_USD.set('{root}/bin/DefaultUSD.usda')
| name = 'usdview'
version = '18.11'
requires = ['pyside-1.2', 'usd-18.11']
def commands():
env.DEFAULT_USD.set('{root}/bin/DefaultUSD.usda') |
# 7. Write a program that asks the user to enter a word and determines whether the word is a
# palindrome or not. A palindrome is a word that reads the same backwards as forwards.
s = input('Enter a string: ')
new_string = s[::-1] # a negative step reverses the string
if s == new_string:
print('It is a palindro... | s = input('Enter a string: ')
new_string = s[::-1]
if s == new_string:
print('It is a palindrome.')
else:
print('It is not a palindrome.') |
# example of raise usage
try:
raise IndexError('spam') # storage arguments
except IndexError:
print('propagating')
raise # reusage of exception
"""
propagating
Traceback (most recent call last):
File "propagation_of_exception.py", line 4, in <module>
raise IndexError('spam') # storage arguments
IndexError... | try:
raise index_error('spam')
except IndexError:
print('propagating')
raise
'\npropagating\nTraceback (most recent call last):\nFile "propagation_of_exception.py", line 4, in <module>\nraise IndexError(\'spam\') # storage arguments\nIndexError: spam\n' |
moveSet1 = 'R1009,D117,L888,D799,L611,U766,L832,U859,L892,D79,R645,U191,L681,D787,R447,D429,L988,U536,L486,D832,R221,D619,R268,D545,L706,U234,L528,D453,R493,D24,L688,U658,L74,D281,R910,D849,L5,U16,R935,D399,L417,U609,R22,D782,L432,D83,L357,D982,L902,U294,L338,U102,R342,D621,R106,U979,L238,U158,R930,D948,L700,D808,R445,... | move_set1 = 'R1009,D117,L888,D799,L611,U766,L832,U859,L892,D79,R645,U191,L681,D787,R447,D429,L988,U536,L486,D832,R221,D619,R268,D545,L706,U234,L528,D453,R493,D24,L688,U658,L74,D281,R910,D849,L5,U16,R935,D399,L417,U609,R22,D782,L432,D83,L357,D982,L902,U294,L338,U102,R342,D621,R106,U979,L238,U158,R930,D948,L700,D808,R445... |
##
##
##
def exec(conexao):
cursor = conexao.cursor()
print("RULE 16 - Inicializando",end=' ')
update = " UPDATE principal SET "
update = update + " r25 = \"50\", "
update = update + " r31 = \"50\" "
update = update + " WHERE 1=1 "
update = update + " AND r1 = \"C170\" "
update =... | def exec(conexao):
cursor = conexao.cursor()
print('RULE 16 - Inicializando', end=' ')
update = ' UPDATE principal SET '
update = update + ' r25 = "50", '
update = update + ' r31 = "50" '
update = update + ' WHERE 1=1 '
update = update + ' AND r1 = "C170" '
update = update + ' AND r3 = "... |
#!/usr/bin/env python
# Import modules
# Read settings file
settings_file = open('./odin_fix_settings.txt')
input_file = settings_file.readline().rstrip()
output_file = settings_file.readline().rstrip()
parsed_file = open(output_file,'w')
parsed_file.write('Date\tTime\tDust\tRH\tTemp\tBatt\n')
with open(input_file,'r')... | settings_file = open('./odin_fix_settings.txt')
input_file = settings_file.readline().rstrip()
output_file = settings_file.readline().rstrip()
parsed_file = open(output_file, 'w')
parsed_file.write('Date\tTime\tDust\tRH\tTemp\tBatt\n')
with open(input_file, 'r') as datafile:
for line in datafile:
has_header... |
class Solution(object):
def grayCode(self, n):
"""
:type n: int
:rtype: List[int]
"""
res = [0,1]
if n == 1:
return res
elif n == 0:
return [0]
order = 1
while order<n:
count = len(res)
... | class Solution(object):
def gray_code(self, n):
"""
:type n: int
:rtype: List[int]
"""
res = [0, 1]
if n == 1:
return res
elif n == 0:
return [0]
order = 1
while order < n:
count = len(res)
while... |
t = int(input())
for ___ in range(t):
length = int(input())
a = [int(k) for k in input().split(' ')]
max_boost = 0
summm = 0
for k in range(length):
if k%2 == 0:
summm += a[k]
for l in range(length-1):
if l%2 == 0:
vygoda = 0
sum_nech, sum_ch =... | t = int(input())
for ___ in range(t):
length = int(input())
a = [int(k) for k in input().split(' ')]
max_boost = 0
summm = 0
for k in range(length):
if k % 2 == 0:
summm += a[k]
for l in range(length - 1):
if l % 2 == 0:
vygoda = 0
(sum_nech, s... |
class Solution:
def __init__(self) :
self.store = {
0 : [],
1 : ["()"]
}
def AllParenthesis(self,n):
if n in self.store :
return self.store[n]
ans = set()
for i in range(n) :
if i == 0 :
for co... | class Solution:
def __init__(self):
self.store = {0: [], 1: ['()']}
def all_parenthesis(self, n):
if n in self.store:
return self.store[n]
ans = set()
for i in range(n):
if i == 0:
for comb in self.AllParenthesis(n - 1):
... |
"""
004
Ask the user to enter
two numbers. Add
them together and
display the answer as
The total is
[answer].
"""
number1 = float(input("Enter two numbers plz :"))
number2 = float (input())
sum = number1 + number2
print("The total is \n",sum) | """
004
Ask the user to enter
two numbers. Add
them together and
display the answer as
The total is
[answer].
"""
number1 = float(input('Enter two numbers plz :'))
number2 = float(input())
sum = number1 + number2
print('The total is \n', sum) |
"""
In a town, there are N people labelled from 1 to N. There is a
rumor that one of these people is secretly the town judge.
If the town judge exists, then:
The town judge trusts nobody
Everybody (except for the town judge) trusts the town judge
There is exactly one person that satisfies properties 1 an... | """
In a town, there are N people labelled from 1 to N. There is a
rumor that one of these people is secretly the town judge.
If the town judge exists, then:
The town judge trusts nobody
Everybody (except for the town judge) trusts the town judge
There is exactly one person that satisfies properties 1 an... |
####################################################
# Problem 4, chapter 1, Bioinformatics VI finding
# mutations.
# Multiple pattern matching, using suffix tree,
# and Longest Repeat Problem
# Input: ATATCGTTTTATCGTT
# Output: TATCGTT
# ---------------------------------------------
#
# Use t... | class Trienode(object):
node_counter = 0
longest_b = 0
def __init__(self, char: str, pnode, charp: str, pos=0, pPath=0):
self.char = char
self.pnode = pnode
self.parent = charp
self.children = []
self.word_finished = False
self.counter = 1
self.positi... |
def translate(value, leftMin, leftMax, rightMin, rightMax):
leftSpan = leftMax - leftMin
rightSpan = rightMax - rightMin
valueScaled = float(value - leftMin) / float(leftSpan)
result = rightMin + (valueScaled * rightSpan)
return result
def reversed_iterator(iter):
return reversed(list(iter))
| def translate(value, leftMin, leftMax, rightMin, rightMax):
left_span = leftMax - leftMin
right_span = rightMax - rightMin
value_scaled = float(value - leftMin) / float(leftSpan)
result = rightMin + valueScaled * rightSpan
return result
def reversed_iterator(iter):
return reversed(list(iter)) |
t = int(input())
def find_max_level(n: int):
sums = [1]
i = 1
while max(sums) < n:
sums.append(2 * sums[i - 1] + 1)
i += 1
return i
def create_binomial_matrix(level: int):
mat = [[1 if j == i or j == 0 else 0 for j in range(0,level)] for i in range(0,level)]
for i in range... | t = int(input())
def find_max_level(n: int):
sums = [1]
i = 1
while max(sums) < n:
sums.append(2 * sums[i - 1] + 1)
i += 1
return i
def create_binomial_matrix(level: int):
mat = [[1 if j == i or j == 0 else 0 for j in range(0, level)] for i in range(0, level)]
for i in range(0,... |
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
# Check with 'pylint' command to code rating.
'''
A very simple script.
'''
def func():
'''
A simple function
'''
first = 1
second = 2
print(first)
print(second)
func()
| """
A very simple script.
"""
def func():
"""
A simple function
"""
first = 1
second = 2
print(first)
print(second)
func() |
_CLASH_ERR = "Cannot have more than one '{}' stanza (Clashing files: {})"
_VALID_ERR = "The data in the '{}' stanza from '{}' failed validation rules."
class MetaloaderError(RuntimeError):
pass
class ExclusiveStanzaClashError(MetaloaderError):
def __init__(self, key, clashing_files):
error_message =... | _clash_err = "Cannot have more than one '{}' stanza (Clashing files: {})"
_valid_err = "The data in the '{}' stanza from '{}' failed validation rules."
class Metaloadererror(RuntimeError):
pass
class Exclusivestanzaclasherror(MetaloaderError):
def __init__(self, key, clashing_files):
error_message = ... |
class Solution:
def defangIPaddr(self, address: str) -> str:
# replace
return address.replace('.', '[.]')
# def defangIPaddr(self, address: str) -> str:
# # split and join
# return '[.]'.join(address.split('.'))
# def defangIPaddr(self, address: str) -> str:
# # repla... | class Solution:
def defang_i_paddr(self, address: str) -> str:
return address.replace('.', '[.]') |
def somadig(n):
if n == 0:
return 0
else:
return (n % 10) + somadig(n // 10)
print(somadig(120))
#https://pt.stackoverflow.com/q/349093/101
| def somadig(n):
if n == 0:
return 0
else:
return n % 10 + somadig(n // 10)
print(somadig(120)) |
class Node:
def __init__(self, data):
self.data = data
self.next_node = None
class LinkedList:
def __init__(self):
self.head = None
self.size = 0
def insert_at_start(self, data):
new_node = Node(data)
self.size += 1
if not self.head:
se... | class Node:
def __init__(self, data):
self.data = data
self.next_node = None
class Linkedlist:
def __init__(self):
self.head = None
self.size = 0
def insert_at_start(self, data):
new_node = node(data)
self.size += 1
if not self.head:
se... |
"""
This script is to be run on Tropo
"""
def wait_for_signal():
while True:
event = say("http://www.phono.com/audio/holdmusic.mp3 http://www.phono.com/audio/holdmusic.mp3") #, {onSignal: make_call_handler})
if event.name == 'signal':
yield event.value
else:
break
... | """
This script is to be run on Tropo
"""
def wait_for_signal():
while True:
event = say('http://www.phono.com/audio/holdmusic.mp3 http://www.phono.com/audio/holdmusic.mp3')
if event.name == 'signal':
yield event.value
else:
break
def make_call(number):
log('***... |
# You are given the head of a linked list and two integers, i and j.
# You have to retain the first i nodes and then delete the next j nodes.
# Continue doing so until the end of the linked list.
# Example:
# linked-list = 1 2 3 4 5 6 7 8 9 10 11 12
# i = 2
# j = 3
# Output = 1 2 6 7 11 12
# LinkedList Node class f... | class Node:
def __init__(self, data):
self.data = data
self.next = None
def skip_i_delete_j(head, i, j):
"""
:param: head - head of linked list
:param: i - first `i` nodes that are to be skipped
:param: j - next `j` nodes that are to be deleted
return - return the updated head ... |
"""
https://leetcode.com/problems/palindrome-number/
Return True if a number is a palindrome
121 -> True
-121 -> False 121-
10 -> False 01
Bonus: Could you solve it without converting the int to a string?
I think I'll try converting the int into a list by using modulus.
Then make 2 pointers left and right to compar... | """
https://leetcode.com/problems/palindrome-number/
Return True if a number is a palindrome
121 -> True
-121 -> False 121-
10 -> False 01
Bonus: Could you solve it without converting the int to a string?
I think I'll try converting the int into a list by using modulus.
Then make 2 pointers left and right to compar... |
# jmespath/_lrtable.py
# This file is automatically generated. Do not edit.
_tabversion = '3.2'
_lr_method = 'LALR'
_lr_signature = '\xb4\x1bXD\x01\x03z\xbb\x19\xfc\rk\xd7x\x00\xa3'
_lr_action_items = {'STAR':([0,2,11,23,26,28,29,32,36,39,44,45,46,47,48,49,50,55,63,],[1,14,1,1,51,1,57,1,1,1,-16,-17,1,-18,-19,-1... | _tabversion = '3.2'
_lr_method = 'LALR'
_lr_signature = '´\x1bXD\x01\x03z»\x19ü\rk×x\x00£'
_lr_action_items = {'STAR': ([0, 2, 11, 23, 26, 28, 29, 32, 36, 39, 44, 45, 46, 47, 48, 49, 50, 55, 63], [1, 14, 1, 1, 51, 1, 57, 1, 1, 1, -16, -17, 1, -18, -19, -14, -15, 1, 1]), 'LPAREN': ([10], [23]), 'NUMBER': ([2, 26], [15, ... |
# Copyright lowRISC contributors.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
load("@python3//:defs.bzl", "interpreter")
def _bitstreams_repo_impl(rctx):
rctx.execute(
[
rctx.path(rctx.attr.python_interpreter),
rct... | load('@python3//:defs.bzl', 'interpreter')
def _bitstreams_repo_impl(rctx):
rctx.execute([rctx.path(rctx.attr.python_interpreter), rctx.attr._cache_manager, '--build-file=BUILD.bazel', '--bucket-url={}'.format(rctx.attr.bucket_url), '--cache={}'.format(rctx.attr.cache), '--refresh-time={}'.format(rctx.attr.refresh... |
# Reading data from file
f = open("student.txt", mode="r")
data1 = f.read(2)
data2 = f.read(2)
print(data1)
print(data2)
f.close()
print("complete!!!") | f = open('student.txt', mode='r')
data1 = f.read(2)
data2 = f.read(2)
print(data1)
print(data2)
f.close()
print('complete!!!') |
#!/usr/bin/env python
#--------- Javascript escaping code lifted from Django (BSD)
_base_js_escapes = (
('\\', r'\u005C'),
('\'', r'\u0027'),
('"', r'\u0022'),
('>', r'\u003E'),
('<', r'\u003C'),
('&', r'\u0026'),
('=', r'\u003D'),
('-', r'\u002D'),
(';', r'\u003B'),
(u'\u2028',... | _base_js_escapes = (('\\', '\\u005C'), ("'", '\\u0027'), ('"', '\\u0022'), ('>', '\\u003E'), ('<', '\\u003C'), ('&', '\\u0026'), ('=', '\\u003D'), ('-', '\\u002D'), (';', '\\u003B'), (u'\u2028', '\\u2028'), (u'\u2029', '\\u2029'))
_js_escapes = _base_js_escapes + tuple([('%c' % z, '\\u%04X' % z) for z in range(32)])
d... |
class Solution(object):
def removeDuplicates(self, nums):
ht = {}
insert = 0
for num in nums:
if num in ht:
ht[num] += 1
else:
ht[num] = 1
if ht[num] > 2:
continue
else:
nums[in... | class Solution(object):
def remove_duplicates(self, nums):
ht = {}
insert = 0
for num in nums:
if num in ht:
ht[num] += 1
else:
ht[num] = 1
if ht[num] > 2:
continue
else:
nums[ins... |
"""
cl-sii Python lib
=================
"""
__version__ = '0.15.0'
| """
cl-sii Python lib
=================
"""
__version__ = '0.15.0' |
def module2_1():
a = 2**0.5
print('%.6f' % (a))
def module2_2():
top = 10
bottom = 20
height = 8
area = (top+bottom)*height/2
print('Area of a Trapezoid:%.1f' % area)
def module2_3():
prime_number = [1]
for i in range(2,1001):
prime_flag = True
for prime in prime_nu... | def module2_1():
a = 2 ** 0.5
print('%.6f' % a)
def module2_2():
top = 10
bottom = 20
height = 8
area = (top + bottom) * height / 2
print('Area of a Trapezoid:%.1f' % area)
def module2_3():
prime_number = [1]
for i in range(2, 1001):
prime_flag = True
for prime in p... |
# list of file paths to ignore when decrypting
# any files that start with these names will not be dumped
nodecrypt = [
"data\\BehaviourCreator",
"data\\DirectXRedist",
"data\\RecommendedBuilds",
"data\\ReplayEncoder",
"data\\Replays",
"data\\Rofl",
"data\\Shaders",
"data\\Sound\\Music",... | nodecrypt = ['data\\BehaviourCreator', 'data\\DirectXRedist', 'data\\RecommendedBuilds', 'data\\ReplayEncoder', 'data\\Replays', 'data\\Rofl', 'data\\Shaders', 'data\\Sound\\Music', 'data\\VCRedist', 'data\\Video', 'data\\AwesomenautsIcon.bmp'] |
class CheckersBoard:
both = "B"
empty = " "
player_1 = "X"
player_2 = "O"
#
def __init__(self):
"""
Contains properties of CheckersBoard including dimensions, player
piece types, and board
"""
self.dimension = 10
self.player_1 = "X"
... | class Checkersboard:
both = 'B'
empty = ' '
player_1 = 'X'
player_2 = 'O'
def __init__(self):
"""
Contains properties of CheckersBoard including dimensions, player
piece types, and board
"""
self.dimension = 10
self.player_1 = 'X'
sel... |
def feet2inches(feet):
return feet * 12
def inches2feet(inches):
feet = inches / 12.0
remainder_inches = feet % 12.0
return feet, remainder_inches
def inches2meters(inches):
return inches * 39.37007874
def meters2inches(meters):
return meters / 0.0254
def meters2feet(meters):
inches = meters2inches(... | def feet2inches(feet):
return feet * 12
def inches2feet(inches):
feet = inches / 12.0
remainder_inches = feet % 12.0
return (feet, remainder_inches)
def inches2meters(inches):
return inches * 39.37007874
def meters2inches(meters):
return meters / 0.0254
def meters2feet(meters):
inches = ... |
#file --pair--
# Jakub Grobelny
# 2018
class pair:
def __init__(self, first, second):
self.first = first
self.second = second
def get(self, which):
if which == 0:
return self.first
elif which == 1:
return self.second
else:
... | class Pair:
def __init__(self, first, second):
self.first = first
self.second = second
def get(self, which):
if which == 0:
return self.first
elif which == 1:
return self.second
else:
raise exception('Pair access violation!') |
# WAP to show the use of for loop
cities = ['new york city', 'mountain view', 'chicago', 'los angeles']
for city in cities: #city is the iteration variable, cities is the iterable being looped over
print(city)
print("Done!")
| cities = ['new york city', 'mountain view', 'chicago', 'los angeles']
for city in cities:
print(city)
print('Done!') |
nombre = None
edad = None
apellido = None
def nombre_completo():
return nombre + ' ' + apellido
def cumplir_anios():
global edad
edad += 1
| nombre = None
edad = None
apellido = None
def nombre_completo():
return nombre + ' ' + apellido
def cumplir_anios():
global edad
edad += 1 |
#!/usr/bin/python
"""
==============================================================================
Author: Tao Li (taoli@ucsd.edu)
Date: Jul 10, 2015
Question: 234-Palindrome-Linked-List
Link: https://leetcode.com/problems/palindrome-linked-list/
=============================================================... | """
==============================================================================
Author: Tao Li (taoli@ucsd.edu)
Date: Jul 10, 2015
Question: 234-Palindrome-Linked-List
Link: https://leetcode.com/problems/palindrome-linked-list/
==============================================================================
... |
class Solution:
def maxIncreaseKeepingSkyline(self, grid: List[List[int]]) -> int:
n = len(grid)
row_high = [0]*n
col_high = [0]*n
for i in range(n):
row_high[i] = max(grid[i])
col_high[i] = 0
for j in range(n):
col_hig... | class Solution:
def max_increase_keeping_skyline(self, grid: List[List[int]]) -> int:
n = len(grid)
row_high = [0] * n
col_high = [0] * n
for i in range(n):
row_high[i] = max(grid[i])
col_high[i] = 0
for j in range(n):
col_high[i] ... |
"""
PASSENGERS
"""
numPassengers = 3290
passenger_arriving = (
(2, 5, 7, 5, 3, 0, 6, 10, 6, 8, 1, 0), # 0
(2, 8, 4, 3, 2, 0, 8, 6, 5, 5, 4, 0), # 1
(5, 10, 6, 4, 3, 0, 2, 10, 7, 4, 2, 0), # 2
(2, 7, 3, 1, 2, 0, 6, 7, 3, 5, 3, 0), # 3
(5, 6, 4, 5, 1, 0, 5, 7, 5, 6, 0, 0), # 4
(3, 6, 6, 6, 1, 0, 11, 4, 7, 6... | """
PASSENGERS
"""
num_passengers = 3290
passenger_arriving = ((2, 5, 7, 5, 3, 0, 6, 10, 6, 8, 1, 0), (2, 8, 4, 3, 2, 0, 8, 6, 5, 5, 4, 0), (5, 10, 6, 4, 3, 0, 2, 10, 7, 4, 2, 0), (2, 7, 3, 1, 2, 0, 6, 7, 3, 5, 3, 0), (5, 6, 4, 5, 1, 0, 5, 7, 5, 6, 0, 0), (3, 6, 6, 6, 1, 0, 11, 4, 7, 6, 1, 0), (9, 11, 2, 3, 0, 0, 5, 10... |
# coding:utf-8
"""
@author:weiwei
@time:2018.01.30
@version:0.1
"""
| """
@author:weiwei
@time:2018.01.30
@version:0.1
""" |
#!/usr/bin/env python3
# Write a program that computes the running sum from 1..n
# Also, have it compute the factorial of n while you're at it
# No, you may not use math.factorial()
# Use the same loop for both calculations
# your code goes here
n = 5
runsum = 0
runmult = 1
for i in range(1, n+1):
runsum += i
runm... | n = 5
runsum = 0
runmult = 1
for i in range(1, n + 1):
runsum += i
runmult *= i
print(n, runsum, runmult)
'\n#expected output\npython3 11sumfac.py\n5 15 120\n' |
def obfuscated_id(x):
y = x
z = y
return z
a = 42
b = obfuscated_id(a)
| def obfuscated_id(x):
y = x
z = y
return z
a = 42
b = obfuscated_id(a) |
"""
Author : Drew Heasman
Date(last updated) : 05 June 2021
Description : Code used for geological calcuations.
"""
| """
Author : Drew Heasman
Date(last updated) : 05 June 2021
Description : Code used for geological calcuations.
""" |
# noinspection PyUnusedLocal
# friend_name = unicode string
def hello(friend_name):
'''
:param Int1: Integer between 0 and 100 inclusive
:param Int2: Integer between 0 and 100 inclusive
:return: Sum of Int1 and Int2
>>> hello ('Bob') --> 'Hello Bob'
>>> sumR1 ('Alice') --> '... | def hello(friend_name):
"""
:param Int1: Integer between 0 and 100 inclusive
:param Int2: Integer between 0 and 100 inclusive
:return: Sum of Int1 and Int2
>>> hello ('Bob') --> 'Hello Bob'
>>> sumR1 ('Alice') --> 'Hello Alice'
"""
msg = 'Hello, '
screamer = '!'
return ms... |
# const
N_INPUTS = 2
N_OUTPUTS = 1
# supported values: 1000, 2000, 4000, 8000, 16000
BATCH_SIZE = 1000
# variables
N_LAYERS = 3
MAX_ITER = 1000
SEED = 41
N_UNITS = []
for i in range(N_LAYERS):
N_UNITS.append(16)
| n_inputs = 2
n_outputs = 1
batch_size = 1000
n_layers = 3
max_iter = 1000
seed = 41
n_units = []
for i in range(N_LAYERS):
N_UNITS.append(16) |
# Irupe Canet
# Check if one number divides another
p = 8
m = 2
if (p % m) == 0:
print(p, "divided by", m, "leaves a reminder of zero.")
print("I'll run too if the condition is True.")
else:
print(p, "divided by", m, "does not leaves a reminder of zero.")
print("I'll run no matter what.")
| p = 8
m = 2
if p % m == 0:
print(p, 'divided by', m, 'leaves a reminder of zero.')
print("I'll run too if the condition is True.")
else:
print(p, 'divided by', m, 'does not leaves a reminder of zero.')
print("I'll run no matter what.") |
# This file is where you keep secret settings, passwords, and tokens!
# If you put them in the code you risk committing that info or sharing it
secrets = {
'ssid' : 'home_network',
'password' : 'ssid_password',
'timezone' : "America/New_York", # http://worldtimeapi.org/timezones
'github_token' : 'fawfj... | secrets = {'ssid': 'home_network', 'password': 'ssid_password', 'timezone': 'America/New_York', 'github_token': 'fawfj23rakjnfawiefa', 'hackaday_token': 'h4xx0rs3kret'} |
"""
@generated
cargo-raze generated Bazel file.
DO NOT EDIT! Replaced on runs of cargo-raze
"""
load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository") # buildifier: disable=load
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") # buildifier: disable=load
load("@bazel_tools//too... | """
@generated
cargo-raze generated Bazel file.
DO NOT EDIT! Replaced on runs of cargo-raze
"""
load('@bazel_tools//tools/build_defs/repo:git.bzl', 'new_git_repository')
load('@bazel_tools//tools/build_defs/repo:http.bzl', 'http_archive')
load('@bazel_tools//tools/build_defs/repo:utils.bzl', 'maybe')
def proxy_wasm_c... |
width = int(input())
lenght = int(input())
count = width * lenght
while count > 0:
line = input()
if line == "STOP":
break
else:
new_pieces = int(line)
count = count - new_pieces
if count > 0:
print(f"{count} pieces are left.")
else:
print(f"No more cake left! You need {ab... | width = int(input())
lenght = int(input())
count = width * lenght
while count > 0:
line = input()
if line == 'STOP':
break
else:
new_pieces = int(line)
count = count - new_pieces
if count > 0:
print(f'{count} pieces are left.')
else:
print(f'No more cake left! You need {abs(c... |
"""Summary."""
class Key:
"""Summary."""
def __init__(self, key_str: str):
"""Summary.
Args:
key_str (str): Description
"""
self._key = key_str
def __str__(self) -> str:
"""Summary.
Returns:
str: Description
"""
re... | """Summary."""
class Key:
"""Summary."""
def __init__(self, key_str: str):
"""Summary.
Args:
key_str (str): Description
"""
self._key = key_str
def __str__(self) -> str:
"""Summary.
Returns:
str: Description
"""
ret... |
# Program to find GCD of the digits of a number
# Recursive function to return gcd of a and b
def gcd(a, b):
return a if (b == 0) else gcd(b, a % b)
def digitGCD(n):
ans = 0
while n > 0:
ans = gcd(n % 10, ans)
# If at any point GCD is 1, return
if gcd == 1:
return 1
... | def gcd(a, b):
return a if b == 0 else gcd(b, a % b)
def digit_gcd(n):
ans = 0
while n > 0:
ans = gcd(n % 10, ans)
if gcd == 1:
return 1
n = n // 10
return ans
n = int(input('Enter a number: '))
print('GCD of the digits of n is', digit_gcd(n)) |
class Solution:
def groupAnagrams(self, strs: List[str]) -> List[List[str]]:
dic = collections.defaultdict(list)
for s in strs : dic["".join(sorted(s))].append(s)
return list(dic.values())
| class Solution:
def group_anagrams(self, strs: List[str]) -> List[List[str]]:
dic = collections.defaultdict(list)
for s in strs:
dic[''.join(sorted(s))].append(s)
return list(dic.values()) |
#!/usr/bin/env python
wc_arr = [0 for x in range(0, 14000/8)]
def _iswordchar(ch):
return (not (
ch <= 33
or ch == ord(';') or ch == ord('-') or ch == ord('"') or ch == ord('\'')
or (ch >= 35 and ch <= 38)
or (ch >= 40 and ch <= 44)
or (ch >= 46 and ch <= 47)
or ch == 58
or (ch >= 60 and ch <= 63)
... | wc_arr = [0 for x in range(0, 14000 / 8)]
def _iswordchar(ch):
return not (ch <= 33 or ch == ord(';') or ch == ord('-') or (ch == ord('"')) or (ch == ord("'")) or (ch >= 35 and ch <= 38) or (ch >= 40 and ch <= 44) or (ch >= 46 and ch <= 47) or (ch == 58) or (ch >= 60 and ch <= 63) or (ch >= 91 and ch <= 94) or (ch... |
# The main module for the plugin.
# Note: In ALL plugins there must be a python file called [name-of-plugin].py in a folder called [name-of-plugin]!
def init(page, config):
# This code runs when the generate command is called.
print("Example plugin initialized!")
def site(page):
# This code run whenever a new Dars... | def init(page, config):
print('Example plugin initialized!')
def site(page):
print('Site created.')
print('Site title: ' + page.title)
def closesite(page):
print('Site closed: ' + page.title) |
def belongs_to_file(word, filename):
with open(filename) as f:
l = f.readlines()
for w in l:
if w.strip() == word:
return True
return False
print(belongs_to_file("renard", "words.txt"))
print(belongs_to_file("abbots", "words.txt"))
| def belongs_to_file(word, filename):
with open(filename) as f:
l = f.readlines()
for w in l:
if w.strip() == word:
return True
return False
print(belongs_to_file('renard', 'words.txt'))
print(belongs_to_file('abbots', 'words.txt')) |
class LampTextureSlot:
color_factor = None
object = None
shadow_factor = None
texture_coords = None
use_map_color = None
use_map_shadow = None
| class Lamptextureslot:
color_factor = None
object = None
shadow_factor = None
texture_coords = None
use_map_color = None
use_map_shadow = None |
'''
Created on Feb 24, 2018
@author: danie
'''
| """
Created on Feb 24, 2018
@author: danie
""" |
# Task 05. Faro Shuffle
def faro_shuffle(arr_input):
left_half = deck[:len(arr_input) // 2]
right_half = deck[len(arr_input) // 2:]
new_list = []
for ind in range(len(left_half)):
new_list.append(right_half[ind])
new_list.append(left_half[ind])
return new_list
deck = input().split... | def faro_shuffle(arr_input):
left_half = deck[:len(arr_input) // 2]
right_half = deck[len(arr_input) // 2:]
new_list = []
for ind in range(len(left_half)):
new_list.append(right_half[ind])
new_list.append(left_half[ind])
return new_list
deck = input().split()
count = int(input())
fir... |
class AccountInfo(object):
_LABELS = ('section',
'organization',
'account-group-code',
'account-code',
'account-group-name',
'account-name',
'amount')
def __init__(self):
self.section = None
self.organizat... | class Accountinfo(object):
_labels = ('section', 'organization', 'account-group-code', 'account-code', 'account-group-name', 'account-name', 'amount')
def __init__(self):
self.section = None
self.organization = None
self.account_group_code = None
self.account_code = None
... |
class WitEmulator(object):
def __init__(self):
self.name='wit'
def normalise_request_json(self,data):
_data = {}
_data["text"]=data['q'][0]
return _data
def normalise_response_json(self,data):
print('plain response {0}'.format(data))
return [
{
... | class Witemulator(object):
def __init__(self):
self.name = 'wit'
def normalise_request_json(self, data):
_data = {}
_data['text'] = data['q'][0]
return _data
def normalise_response_json(self, data):
print('plain response {0}'.format(data))
return [{'_text':... |
def gcd(a, b):
if b == 0:
return a
return gcd(b, a % b)
def bgcd(a, b):
if b == 0:
return a
if a == 0:
return b
if a & 1:
if b & 1:
return bgcd((a - b) >> 1, b)
else:
return bgcd(a, b >> 1)
else:
if b & 1:
retu... | def gcd(a, b):
if b == 0:
return a
return gcd(b, a % b)
def bgcd(a, b):
if b == 0:
return a
if a == 0:
return b
if a & 1:
if b & 1:
return bgcd(a - b >> 1, b)
else:
return bgcd(a, b >> 1)
elif b & 1:
return bgcd(a >> 1, b)
... |
# Copyright 2013-2021 Aerospike, Inc.
#
# 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 writ... | class Lookupdict:
lookup_mode = 0
prefix_mode = 1
suffix_mode = 2
def __init__(self, mode=None):
self._kv = {}
if mode == None:
mode = self.LOOKUP_MODE
self.mode = mode
def __setitem__(self, key, value):
return self.add(key, value)
def __getitem__(s... |
'''
Doc Header
'''
def test_this1():
assert 1 == 1, "This should never fail"
| """
Doc Header
"""
def test_this1():
assert 1 == 1, 'This should never fail' |
name = 'stackdandelion'
aliases = ['stackdandelions', 'fixdandelionstacking']
fix_dandelion_stacking_fixed = False
async def run(message):
'Fixes dandelion stacking.'
global fix_dandelion_stacking_fixed
if not fix_dandelion_stacking_fixed:
await message.send('Dandelion stacking has been fixed.')
else:
await ... | name = 'stackdandelion'
aliases = ['stackdandelions', 'fixdandelionstacking']
fix_dandelion_stacking_fixed = False
async def run(message):
"""Fixes dandelion stacking."""
global fix_dandelion_stacking_fixed
if not fix_dandelion_stacking_fixed:
await message.send('Dandelion stacking has been fixed.'... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.