content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
class CourseType():
__doc__ = "Type of degree, e.g. BA, BEng, BSc"
possibleCourseTypes = ["BA", "BSc"] #TODO extend to values from http://typesofdegrees.org/
def __init__(self, name, accepts, singleHons = 0, jointHons = 0):
if self.checkName(name):
self._name = name
self.accepts = accepts
self.singleHons ... | class Coursetype:
__doc__ = 'Type of degree, e.g. BA, BEng, BSc'
possible_course_types = ['BA', 'BSc']
def __init__(self, name, accepts, singleHons=0, jointHons=0):
if self.checkName(name):
self._name = name
self.accepts = accepts
self.singleHons = singleHons
sel... |
def collatz_len(n):
ct = 1
while n != 1:
if n % 2 == 0:
n = n/2
else:
n = 3*n+1
ct += 1
return ct
len_max = i_max = 0
for i in range(1, 1000001):
current_len = collatz_len(i)
if current_len > len_max:
len_max = current_len
i_max = i
... | def collatz_len(n):
ct = 1
while n != 1:
if n % 2 == 0:
n = n / 2
else:
n = 3 * n + 1
ct += 1
return ct
len_max = i_max = 0
for i in range(1, 1000001):
current_len = collatz_len(i)
if current_len > len_max:
len_max = current_len
i_max =... |
# Sorts a Python list in ascending order using the quick sort
# algorithm
def quickSort(theList):
n = len(theList)
recQuickSort(theList, 0, n-1)
# The recursive "in-place" implementation
def recQuickSort(theList, first, last):
# Check the base case (range is trivially sorted)
if first >= last:
... | def quick_sort(theList):
n = len(theList)
rec_quick_sort(theList, 0, n - 1)
def rec_quick_sort(theList, first, last):
if first >= last:
return
else:
pos = partition_seq(theList, first, last)
rec_quick_sort(theList, first, pos - 1)
rec_quick_sort(theList, pos + 1, last)
... |
class Time:
max_hours = 23
max_minutes = 59
max_seconds = 59
def __init__(self, hours: int, minutes: int, seconds: int):
self.hours = hours
self.minutes = minutes
self.seconds = seconds
def set_time(self, hours, minutes, seconds):
self.hours = hours
... | class Time:
max_hours = 23
max_minutes = 59
max_seconds = 59
def __init__(self, hours: int, minutes: int, seconds: int):
self.hours = hours
self.minutes = minutes
self.seconds = seconds
def set_time(self, hours, minutes, seconds):
self.hours = hours
self.min... |
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:
def isValidBST(self, root: Optional[TreeNode]) -> bool:
def subfun(root, minimal, maximal):
... | class Solution:
def is_valid_bst(self, root: Optional[TreeNode]) -> bool:
def subfun(root, minimal, maximal):
if not root:
return
if root.val >= maximal or root.val <= minimal:
self.out = False
else:
subfun(root.left, mini... |
# Lambda funkcie
#
# Tato sekcia sluzi na precvicenie si lambda vyrazov
#
# Uloha 1:
def make_square():
return(lambda x: x*x)
# Uloha 2:
def make_upper():
return(lambda x: x.upper())
# Uloha 3:
def make_power():
return(lambda x, N: x ** N)
# Uloha 4:
def make_power2(N):
return(lambda x: x ** N)
... | def make_square():
return lambda x: x * x
def make_upper():
return lambda x: x.upper()
def make_power():
return lambda x, N: x ** N
def make_power2(N):
return lambda x: x ** N
def call_name():
return lambda x, name: getattr(x, name)() |
def forever2():
pass
forever(forever2) | def forever2():
pass
forever(forever2) |
def retrieve_page(page):
if page > 3:
return {"next_page": None, "items": []}
return {"next_page": page + 1, "items": ["A", "B", "C"]}
items = []
page = 1
while page is not None:
page_result = retrieve_page(page)
items += page_result["items"]
page = page_result["next_page"]
print(items) ... | def retrieve_page(page):
if page > 3:
return {'next_page': None, 'items': []}
return {'next_page': page + 1, 'items': ['A', 'B', 'C']}
items = []
page = 1
while page is not None:
page_result = retrieve_page(page)
items += page_result['items']
page = page_result['next_page']
print(items) |
# SIEL type compliance cases require a specific control code prefixes. currently: (0 to 9)D, (0 to 9)E, ML21, ML22.
COMPLIANCE_CASE_ACCEPTABLE_GOOD_CONTROL_CODES = "(^[0-9][DE].*$)|(^ML21.*$)|(^ML22.*$)"
class ComplianceVisitTypes:
FIRST_CONTACT = "first_contact"
FIRST_VISIT = "first_visit"
ROUTINE_VISIT ... | compliance_case_acceptable_good_control_codes = '(^[0-9][DE].*$)|(^ML21.*$)|(^ML22.*$)'
class Compliancevisittypes:
first_contact = 'first_contact'
first_visit = 'first_visit'
routine_visit = 'routine_visit'
revisit = 'revisit'
choices = [(FIRST_CONTACT, 'First contact'), (FIRST_VISIT, 'First visit... |
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution:
def mergeInBetween(self, list1: ListNode, a: int, b: int, list2: ListNode) -> ListNode:
k=-1
pre=ListNode(-1000,list1)
x=List... | class Solution:
def merge_in_between(self, list1: ListNode, a: int, b: int, list2: ListNode) -> ListNode:
k = -1
pre = list_node(-1000, list1)
x = list_node()
y = list_node()
while pre:
if pre.next and k == a - 1:
x = pre
while k !... |
class Stack:
def __init__(self):
self.items = []
def push(self, item):
self.items.append(item)
def pop(self):
return self.items.pop()
def peek(self):
return self.items[-1]
def size(self):
return len(self.items)
def get_max(self):
return ma... | class Stack:
def __init__(self):
self.items = []
def push(self, item):
self.items.append(item)
def pop(self):
return self.items.pop()
def peek(self):
return self.items[-1]
def size(self):
return len(self.items)
def get_max(self):
return max(s... |
def palindrome(word, index):
left = index
right = len(word) - 1 - index
if left >= right:
return f"{word} is a palindrome"
right_letter = word[len(word)-1-index]
left_letter = word[index]
if left_letter != right_letter:
return f"{word} is not a palindrome"
return palindrome... | def palindrome(word, index):
left = index
right = len(word) - 1 - index
if left >= right:
return f'{word} is a palindrome'
right_letter = word[len(word) - 1 - index]
left_letter = word[index]
if left_letter != right_letter:
return f'{word} is not a palindrome'
return palindro... |
#
# PySNMP MIB module CISCO-HEALTH-MONITOR-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-HEALTH-MONITOR-MIB
# Produced by pysmi-0.3.4 at Wed May 1 11:59:45 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.... | (integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_size_constraint, single_value_constraint, value_range_constraint, constraints_union, constraints_intersection) ... |
class ListNode:
def __init__(self, key=None, value=None, next_node=None):
self.key = key
self.val = value
self.next = next_node
class MyHashMap:
def __init__(self):
self.size = 8
self.used = 0
self.threshold = 0.618
self.buckets = [None] * self.size
... | class Listnode:
def __init__(self, key=None, value=None, next_node=None):
self.key = key
self.val = value
self.next = next_node
class Myhashmap:
def __init__(self):
self.size = 8
self.used = 0
self.threshold = 0.618
self.buckets = [None] * self.size
... |
n=int(input());ans=0
def s(x,h):
global ans
for i in range(3):
if i==0 and x==0: continue
if x==n:
if h%3==0: ans+=1;return
else:
s(x+1,h+i)
s(0,0)
print(ans)
| n = int(input())
ans = 0
def s(x, h):
global ans
for i in range(3):
if i == 0 and x == 0:
continue
if x == n:
if h % 3 == 0:
ans += 1
return
else:
s(x + 1, h + i)
s(0, 0)
print(ans) |
class NoChoice(Exception):
def __init__(self):
super().__init__("Took too long.")
class PaginationError(Exception):
pass
class CannotEmbedLinks(PaginationError):
def __init__(self):
super().__init__("Bot cannot embed links in this channel.")
| class Nochoice(Exception):
def __init__(self):
super().__init__('Took too long.')
class Paginationerror(Exception):
pass
class Cannotembedlinks(PaginationError):
def __init__(self):
super().__init__('Bot cannot embed links in this channel.') |
# This file is part of Indico.
# Copyright (C) 2002 - 2021 CERN
#
# Indico is free software; you can redistribute it and/or
# modify it under the terms of the MIT License; see the
# LICENSE file for more details.
def isStringHTML(s):
if not isinstance(s, str):
return False
s = s.lower()
return any(... | def is_string_html(s):
if not isinstance(s, str):
return False
s = s.lower()
return any((tag in s for tag in ('<p>', '<p ', '<br', '<li>'))) |
def assert_dict_equal(expected, actual):
message = []
equal = True
for k, v in expected.items():
if actual[k] != v:
message.append(f"For key {k} want {v}, got {actual[k]}")
equal = False
for k, v in actual.items():
if not k in expected:
message.append(f"Got extra key {k} with value {v... | def assert_dict_equal(expected, actual):
message = []
equal = True
for (k, v) in expected.items():
if actual[k] != v:
message.append(f'For key {k} want {v}, got {actual[k]}')
equal = False
for (k, v) in actual.items():
if not k in expected:
message.app... |
x = int(input())
for j in range(x):
q = int(input())
print("Case", j + 1, end=": ")
for t in range(1, int(q / 2 + 1)):
if q % t == 0:
print(t, end=" ")
print(q)
| x = int(input())
for j in range(x):
q = int(input())
print('Case', j + 1, end=': ')
for t in range(1, int(q / 2 + 1)):
if q % t == 0:
print(t, end=' ')
print(q) |
class RobotStatus:
def __init__(self):
self.status = 'init'
self.position = ''
def isAvailable(self):
if self.status == 'available':
return True
else:
return False
def isWaitEV(self):
if self.status == 'waitEV':
return True
... | class Robotstatus:
def __init__(self):
self.status = 'init'
self.position = ''
def is_available(self):
if self.status == 'available':
return True
else:
return False
def is_wait_ev(self):
if self.status == 'waitEV':
return True
... |
# The language mapping for 2 and 3 character language code.
language_dict = {
"kn": "kannada",
"kan": "kannada",
"hi": "hindi",
"hin": "hindi",
}
| language_dict = {'kn': 'kannada', 'kan': 'kannada', 'hi': 'hindi', 'hin': 'hindi'} |
# Recursive Functions
def iterTest(low, high):
while low <= high:
print(low)
low=low+1
def recurTest(low,high):
if low <= high:
print(low)
recurTest(low+1, high)
| def iter_test(low, high):
while low <= high:
print(low)
low = low + 1
def recur_test(low, high):
if low <= high:
print(low)
recur_test(low + 1, high) |
# find min. no. of sets an array (awards) can be divided into such that couple-wise difference of each element is at most k
# ex: awards=[1,5,4,6,8,9,2], k=3, o/p=3
# [1,2][4,5,6][8,9] with max diff 1,2,1 respectively
# int minimumGroups(int awards[n],int k) => o/p
def max_diff(arr):
return max(arr) - min(arr)... | def max_diff(arr):
return max(arr) - min(arr)
def minimum_groups(awards, k):
awards.sort()
count = 1
n = len(awards)
(i, j) = (0, 1)
while j != n:
if max_diff(awards[i:j + 1]) >= k:
count += 1
i = j
j = i + 1
j = j + 1
return count
def ma... |
class Solution:
def countBits(self, n: int) -> List[int]:
arr = []
for i in range(n+1):
i_b = int(bin(i)[2:])
arr.append(self.calculate1(i_b))
return arr
def calculate1(self, i):
count = 0
while i >= 1:
re... | class Solution:
def count_bits(self, n: int) -> List[int]:
arr = []
for i in range(n + 1):
i_b = int(bin(i)[2:])
arr.append(self.calculate1(i_b))
return arr
def calculate1(self, i):
count = 0
while i >= 1:
res = i % 10
if ... |
class Heap:
def __init__(self, arr):
self.arr = arr
self.size = len(self.arr)
def max_heapify(self, current_index):
if not self.is_leaf(current_index):
left_child = (2 * current_index) + 1
right_child = (2 * current_index) + 2
if right_child < self.... | class Heap:
def __init__(self, arr):
self.arr = arr
self.size = len(self.arr)
def max_heapify(self, current_index):
if not self.is_leaf(current_index):
left_child = 2 * current_index + 1
right_child = 2 * current_index + 2
if right_child < self.size:... |
# -*- coding: utf-8 -*-
# @Author: Wenwen Yu
# @Created Time: 7/8/2020 9:34 PM
Entities_list = [
"date_echeance",
"date_facture",
"methode_payement",
"numero_facture",
"rib",
"adresse",
"contact",
"nom_fournisseur",
"matricule_fiscale",
"total_ht",
"total_ttc"
]
# Entities_... | entities_list = ['date_echeance', 'date_facture', 'methode_payement', 'numero_facture', 'rib', 'adresse', 'contact', 'nom_fournisseur', 'matricule_fiscale', 'total_ht', 'total_ttc'] |
data = (
'Guo ', # 0x00
'Yin ', # 0x01
'Hun ', # 0x02
'Pu ', # 0x03
'Yu ', # 0x04
'Han ', # 0x05
'Yuan ', # 0x06
'Lun ', # 0x07
'Quan ', # 0x08
'Yu ', # 0x09
'Qing ', # 0x0a
'Guo ', # 0x0b
'Chuan ', # 0x0c
'Wei ', # 0x0d
'Yuan ', # 0x0e
'Quan ', # 0x0f
'K... | data = ('Guo ', 'Yin ', 'Hun ', 'Pu ', 'Yu ', 'Han ', 'Yuan ', 'Lun ', 'Quan ', 'Yu ', 'Qing ', 'Guo ', 'Chuan ', 'Wei ', 'Yuan ', 'Quan ', 'Ku ', 'Fu ', 'Yuan ', 'Yuan ', 'E ', 'Tu ', 'Tu ', 'Tu ', 'Tuan ', 'Lue ', 'Hui ', 'Yi ', 'Yuan ', 'Luan ', 'Luan ', 'Tu ', 'Ya ', 'Tu ', 'Ting ', 'Sheng ', 'Pu ', 'Lu ', 'Iri ', ... |
FEATURES = {"DEBUG_MODE": False}
def feature(feature_id: str) -> bool:
if feature_id not in FEATURES:
raise ValueError("Key not a valid feature")
return FEATURES[feature_id]
| features = {'DEBUG_MODE': False}
def feature(feature_id: str) -> bool:
if feature_id not in FEATURES:
raise value_error('Key not a valid feature')
return FEATURES[feature_id] |
team_names = ['LA Chargers', 'LA Rams', 'NE Patriots', 'NY Giants',
'Chicago Bears']
locations = ['LA', 'NY', 'SF', 'CH', 'NE']
weeks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] | team_names = ['LA Chargers', 'LA Rams', 'NE Patriots', 'NY Giants', 'Chicago Bears']
locations = ['LA', 'NY', 'SF', 'CH', 'NE']
weeks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] |
x = int(input(""))
y = int(input(""))
div = int(x/y)
print(div)
mod = int(x % y)
print(mod)
z = divmod(x, y)
print(z) | x = int(input(''))
y = int(input(''))
div = int(x / y)
print(div)
mod = int(x % y)
print(mod)
z = divmod(x, y)
print(z) |
red = 'Red'
blue = 'Blue'
green = 'Green'
spring_green = 'SpringGreen'
hot_pink = 'HotPink'
blue_violet = 'BlueViolet'
cadet_blue = 'CadetBlue'
chocolate = 'Chocolate'
coral = 'Coral'
dodger_blue = 'DodgerBlue'
firebrick = 'Firebrick'
golden_rod = 'GoldenRod'
orange_red = 'OrangeRed'
yellow_green = 'YellowGreen'
sea_gr... | red = 'Red'
blue = 'Blue'
green = 'Green'
spring_green = 'SpringGreen'
hot_pink = 'HotPink'
blue_violet = 'BlueViolet'
cadet_blue = 'CadetBlue'
chocolate = 'Chocolate'
coral = 'Coral'
dodger_blue = 'DodgerBlue'
firebrick = 'Firebrick'
golden_rod = 'GoldenRod'
orange_red = 'OrangeRed'
yellow_green = 'YellowGreen'
sea_gr... |
class Solution:
def numSub(self, s: str) -> int:
l = [int(i) for i in s]
res = 0
i = 0
while i < len(l):
if l[i] != 1:
i += 1
continue
count = 0
curr = 0
while i < len(l) and l[i] == 1:
i ... | class Solution:
def num_sub(self, s: str) -> int:
l = [int(i) for i in s]
res = 0
i = 0
while i < len(l):
if l[i] != 1:
i += 1
continue
count = 0
curr = 0
while i < len(l) and l[i] == 1:
... |
class conta_corrente:
def __Init__(self, nome):
self.nome = nome
self.email = None
self.telefone = None
self._saldo = 0
def _checar_saldo(self, valor):
return self._saldo >= valor
def depositar(self, valor):
self._saldo += valor
def sacar(self, valor):
... | class Conta_Corrente:
def ___init__(self, nome):
self.nome = nome
self.email = None
self.telefone = None
self._saldo = 0
def _checar_saldo(self, valor):
return self._saldo >= valor
def depositar(self, valor):
self._saldo += valor
def sacar(self, valor)... |
chromedriver_path='***'
from_station='***'
to_station='***'
email='***'
phone_num='***'
full_name='***'
card_num='***'
exp='***'
cvv='***' | chromedriver_path = '***'
from_station = '***'
to_station = '***'
email = '***'
phone_num = '***'
full_name = '***'
card_num = '***'
exp = '***'
cvv = '***' |
# terrascript/data/camptocamp/jwt.py
# Automatically generated by tools/makecode.py (24-Sep-2021 15:19:50 UTC)
__all__ = []
| __all__ = [] |
mon_fichier = open("mdp.txt" , "r")
crypt = mon_fichier.read()
mon_fichier.close()
mon_fichier = open("encrypt.txt" , "r")
decrypt1 = mon_fichier.read()
mon_fichier.close()
def encrypt(crypt):
number=input("donner une cle de cryptage (numero)")
b=list(crypt)
str(b)
c=[ord(x)for x in(b)]
... | mon_fichier = open('mdp.txt', 'r')
crypt = mon_fichier.read()
mon_fichier.close()
mon_fichier = open('encrypt.txt', 'r')
decrypt1 = mon_fichier.read()
mon_fichier.close()
def encrypt(crypt):
number = input('donner une cle de cryptage (numero)')
b = list(crypt)
str(b)
c = [ord(x) for x in b]
d = []
... |
'''dom.py contains all referenced dom elements. Gathering all fragile dom elements in one config file makes it easier to maintain the code'''
def dom():
dom = {
'loginButton': 'html/body/div[3]/header/div/div/div/div[2]/button/span',
'einverstandenButton': 'div.c-button--bold... | """dom.py contains all referenced dom elements. Gathering all fragile dom elements in one config file makes it easier to maintain the code"""
def dom():
dom = {'loginButton': 'html/body/div[3]/header/div/div/div/div[2]/button/span', 'einverstandenButton': 'div.c-button--bold', 'usernameInput': 'Username'}
retu... |
'''
2. Write a Python Program to read the contents of a file and find how many upper case letters,
lower case letters and digits existed in the file.
'''
file = open('SampleCount.txt','r')
data = file.read()
print('Contents of a file is')
print(data)
digit = upper = lower = special = 0
for ch in data:
if ch.islo... | """
2. Write a Python Program to read the contents of a file and find how many upper case letters,
lower case letters and digits existed in the file.
"""
file = open('SampleCount.txt', 'r')
data = file.read()
print('Contents of a file is')
print(data)
digit = upper = lower = special = 0
for ch in data:
if ch.isl... |
# Specialization: Google IT Automation with Python
# Course 01: Crash Course with Python
# Week 5 Module Part 2 Exercise 02
# Student: Shawn Solomon
# Learning Platform: Coursera.org
# Want to see this in action?
# In this code, there's a Person class that has an attribute name, which gets set when constructing... | class Person:
def __init__(self, name):
self.name = name
def greeting(self):
return 'hi, my name is {}'.format(self.name)
some_person = person('Nobody')
print(some_person.greeting()) |
def solve(data):
result = 0
# Declares an unordered collection of unique elements
unique_frequencies = set()
while True:
for number in data:
result += number
# Checks if current sum(result) already exists in the collection
if result in unique_frequencies:
... | def solve(data):
result = 0
unique_frequencies = set()
while True:
for number in data:
result += number
if result in unique_frequencies:
return result
unique_frequencies.add(result) |
def next_13_numbers_product(num, start):
if start + 13 > len(num):
return 0
x = 1
for index in range(start, start + 13):
x *= int(num[index])
return x
number = "73167176531330624919225119674426574742355349194934\
96983520312774506326239578318016984801869478851843\
858615607891129494... | def next_13_numbers_product(num, start):
if start + 13 > len(num):
return 0
x = 1
for index in range(start, start + 13):
x *= int(num[index])
return x
number = '7316717653133062491922511967442657474235534919493496983520312774506326239578318016984801869478851843858615607891129494954595017... |
class Solution:
def intervalIntersection(self, A: List[List[int]], B: List[List[int]]) -> List[List[int]]:
ans = []
i = 0
j = 0
while i < len(A) and j < len(B):
if A[i][0] <= B[j][0] and A[i][1] >= B[j][1]:
C = []
C.append(B[j][0])... | class Solution:
def interval_intersection(self, A: List[List[int]], B: List[List[int]]) -> List[List[int]]:
ans = []
i = 0
j = 0
while i < len(A) and j < len(B):
if A[i][0] <= B[j][0] and A[i][1] >= B[j][1]:
c = []
C.append(B[j][0])
... |
def fibonacci():
a = 0
b = 1
while True: # keep going...
yield a # report value, a, during this pass
future = a + b
a = b # this will be next value reported
b = future # and subsequently this
| def fibonacci():
a = 0
b = 1
while True:
yield a
future = a + b
a = b
b = future |
X = int(input())
Y = int(input())
print(int(input())*60 + int(input()))
a = int(input())
print(a//60)
print(a%60)
x=int(input())
h=int(input())
m=int(input())
print(h+(x+m)//60)
print((x+m)%60) | x = int(input())
y = int(input())
print(int(input()) * 60 + int(input()))
a = int(input())
print(a // 60)
print(a % 60)
x = int(input())
h = int(input())
m = int(input())
print(h + (x + m) // 60)
print((x + m) % 60) |
def confusion_matrix(yreal, ypred):
n_classes = len(set(yreal))
new_matrix = []
print("len yreal: ", len(yreal))
print("len ypred: ", len(ypred))
print("n classes: ", n_classes)
for i_class in range(n_classes):
new_matrix.append([])
for _ in range(n_classes): #i_ypred
... | def confusion_matrix(yreal, ypred):
n_classes = len(set(yreal))
new_matrix = []
print('len yreal: ', len(yreal))
print('len ypred: ', len(ypred))
print('n classes: ', n_classes)
for i_class in range(n_classes):
new_matrix.append([])
for _ in range(n_classes):
new_matr... |
def quicksort(array):
if len(array) < 2:
return array
print(quicksort([ ])) | def quicksort(array):
if len(array) < 2:
return array
print(quicksort([])) |
#
# PySNMP MIB module Unisphere-Data-SONET-CONF (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/Unisphere-Data-SONET-CONF
# Produced by pysmi-0.3.4 at Wed May 1 15:32:59 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.... | (object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, constraints_union, value_range_constraint, constraints_intersection, value_size_constraint) ... |
name1=["ales","Mark","Deny","Hendry"]
name2=name1
name3=name1[:]
name1=["Anand"]
name3=["Murugan"]
sum=0
for ls in (name1,name2,name3):
if ls[0]=="Anand":
sum+=1
pass
if ls[1]=="Murugan":
sum+=5
print(sum)
pass | name1 = ['ales', 'Mark', 'Deny', 'Hendry']
name2 = name1
name3 = name1[:]
name1 = ['Anand']
name3 = ['Murugan']
sum = 0
for ls in (name1, name2, name3):
if ls[0] == 'Anand':
sum += 1
pass
if ls[1] == 'Murugan':
sum += 5
print(sum)
pass |
def solution():
def integers():
x = 1
while True:
yield x
x += 1
def halves():
for x in integers():
yield x / 2
def take(n, seq):
result = []
for i in range(n):
result.append(next(seq))
return result
retu... | def solution():
def integers():
x = 1
while True:
yield x
x += 1
def halves():
for x in integers():
yield (x / 2)
def take(n, seq):
result = []
for i in range(n):
result.append(next(seq))
return result
ret... |
# Copyright (c) 2017 Pieter Wuille
# Copyright (c) 2018 Oskar Hladky
# Copyright (c) 2018 Pavol Rusnak
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without... | charset = 'qpzry9x8gf2tvdw0s3jn54khce6mua7l'
address_type_p2_kh = 0
address_type_p2_sh = 8
def cashaddr_polymod(values):
generator = [656907472481, 522768456162, 1044723512260, 748107326120, 130178868336]
chk = 1
for value in values:
top = chk >> 35
chk = (chk & 34359738367) << 5 ^ value
... |
lines = open('input','r').readlines()
size_linea = 12
unos = [0,0,0,0,0,0,0,0,0,0,0,0]
for line in lines:
for i in range(size_linea):
if (line[i] == '1'):
unos[i] += 1
media = len(lines)/2
gamma = 0
epsilon = 0
for i in range(size_linea):
if (unos[i] > media):
gamma += 2**(size_... | lines = open('input', 'r').readlines()
size_linea = 12
unos = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
for line in lines:
for i in range(size_linea):
if line[i] == '1':
unos[i] += 1
media = len(lines) / 2
gamma = 0
epsilon = 0
for i in range(size_linea):
if unos[i] > media:
gamma += 2 **... |
# Using flag
prompt = "\nTell me your name, and I will reprint your name: "
prompt += "\nEnter 'quit' to end the program."
active = True
while active:
message = input(prompt)
if message == 'quit':
active = False
else:
print(message) | prompt = '\nTell me your name, and I will reprint your name: '
prompt += "\nEnter 'quit' to end the program."
active = True
while active:
message = input(prompt)
if message == 'quit':
active = False
else:
print(message) |
print('Numeros pares!!!')
print('=-=' * 15)
for c in range(2, 52, 2):
print(c)
print('=-=' * 15)
print('ACABOU.')
| print('Numeros pares!!!')
print('=-=' * 15)
for c in range(2, 52, 2):
print(c)
print('=-=' * 15)
print('ACABOU.') |
class medicamento:
def __init__(self, id, nombre, precio, descripcion, cantidad, rol):
self.id = id
self.nombre = nombre
self.precio = precio
self.descripcion = descripcion
self.cantidad = cantidad
self.rol = rol
def actualizar_datos(self, id, nombre, preci... | class Medicamento:
def __init__(self, id, nombre, precio, descripcion, cantidad, rol):
self.id = id
self.nombre = nombre
self.precio = precio
self.descripcion = descripcion
self.cantidad = cantidad
self.rol = rol
def actualizar_datos(self, id, nombre, precio, de... |
def test_it(binbb, groups_cfg):
for account, accgrp_cfg in groups_cfg.items():
bbcmd = ["groups", "--account", account]
res = binbb.sysexec(*bbcmd)
# very simple test of group names and member names being seen in output
for group_name, members in accgrp_cfg.items():
asser... | def test_it(binbb, groups_cfg):
for (account, accgrp_cfg) in groups_cfg.items():
bbcmd = ['groups', '--account', account]
res = binbb.sysexec(*bbcmd)
for (group_name, members) in accgrp_cfg.items():
assert group_name in res
for member_name in members:
... |
def pattern_eighten(steps):
''' Pattern eighteen
9 8 7 6 5 4 3 2 1
9 8 7 6 5 4 3 2
9 8 7 6 5 4 3
9 8 7 6 5 4
9 8 7 6 5
9 8 7 6
9 8 7
9 8
9
'''
get_range = [str(i) for i in range(1, steps + 1)][::-1]
for i in range... | def pattern_eighten(steps):
""" Pattern eighteen
9 8 7 6 5 4 3 2 1
9 8 7 6 5 4 3 2
9 8 7 6 5 4 3
9 8 7 6 5 4
9 8 7 6 5
9 8 7 6
9 8 7
9 8
9
"""
get_range = [str(i) for i in range(1, steps + 1)][::-1]
for i in range(len(get_range), 0... |
# puck_properties_consts.py
#
# ~~~~~~~~~~~~
#
# pyHand Constants File
#
# ~~~~~~~~~~~~
#
# ------------------------------------------------------------------
# Authors : Chloe Eghtebas,
# Brendan Ritter,
# Pravina Samaratunga,
# Jason Schwartz
#
# Last change: 08.08.2013
#
#... | finger1 = 11
finger2 = 12
finger3 = 13
spread = 14
all_fingers = (FINGER1, FINGER2, FINGER3, SPREAD)
grasp = (FINGER1, FINGER2, FINGER3)
accel = 82
addr = 6
ana0 = 18
ana1 = 19
baud = 12
cmd = 29
cmd_load = 0
cmd_save = 1
cmd_reset = 2
cmd_def = 3
cmd_get = 4
cmd_find = 5
cmd_set = 6
cmd_home = 7
cmd_keep = 8
cmd_loop ... |
#
# @lc app=leetcode id=680 lang=python3
#
# [680] Valid Palindrome II
#
# https://leetcode.com/problems/valid-palindrome-ii/description/
#
# algorithms
# Easy (37.22%)
# Total Accepted: 275.1K
# Total Submissions: 737.9K
# Testcase Example: '"aba"'
#
# Given a string s, return true if the s can be palindrome after... | class Solution:
def valid_palindrome(self, s: str) -> bool:
head = 0
tail = len(s) - 1
while head < tail:
if s[head] == s[tail]:
head += 1
tail -= 1
else:
return self.isPalindrome(s[head + 1:tail + 1]) or self.isPalindr... |
'''
Module contains basic functions
'''
def number_to_power(number, power):
'''
:param number: number to be taken
:param power:
:return: number to power
>>> number_to_power(3, 2)
9
>>> number_to_power(2, 3)
8
'''
return number**power
def number_addition(... | """
Module contains basic functions
"""
def number_to_power(number, power):
"""
:param number: number to be taken
:param power:
:return: number to power
>>> number_to_power(3, 2)
9
>>> number_to_power(2, 3)
8
"""
return number ** power
def number_addition(number1, number... |
def mask_out(sentence, banned, substitutes):
# write your answer between #start and #end
#start
return ''
#end
print('Test 1')
print('Expected:abcd#')
print('Actual :' + mask_out('abcde', 'e', '#'))
print()
print('Test 2')
print('Expected:#$solute')
print('Actual :' + mask_out('absolute', 'ab', '#$... | def mask_out(sentence, banned, substitutes):
return ''
print('Test 1')
print('Expected:abcd#')
print('Actual :' + mask_out('abcde', 'e', '#'))
print()
print('Test 2')
print('Expected:#$solute')
print('Actual :' + mask_out('absolute', 'ab', '#$'))
print()
print('Test 3')
print('Expected:121hon')
print('Actual :' ... |
def linear_search_recursive(arr, value, start, end):
if start >= end: return -1
if arr[start] == value:
return start
if arr[end] == value: return end
else:
return linear_search_recursive(arr, value, start+1, end-1)
test_list = [1,3,9,11,15,19,29]
print(linear_search_recursive(tes... | def linear_search_recursive(arr, value, start, end):
if start >= end:
return -1
if arr[start] == value:
return start
if arr[end] == value:
return end
else:
return linear_search_recursive(arr, value, start + 1, end - 1)
test_list = [1, 3, 9, 11, 15, 19, 29]
print(linear_se... |
'''
Joe Walter
difficulty: 5%
run time: 0:20
answer: 40730
***
034 Digit Factorials
145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 120 = 145.
Find the sum of all numbers which are equal to the sum of the factorial of their digits.
Note: as 1! = 1 and 2! = 2 are not sums they are not included.
***
O... | """
Joe Walter
difficulty: 5%
run time: 0:20
answer: 40730
***
034 Digit Factorials
145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 120 = 145.
Find the sum of all numbers which are equal to the sum of the factorial of their digits.
Note: as 1! = 1 and 2! = 2 are not sums they are not included.
***
O... |
config = {
"bootstrap_servers": 'localhost:9092',
"async_produce": False,
"models": [
{
"module_name": "image_classification.predict",
"class_name": "ModelPredictor",
}
]
} | config = {'bootstrap_servers': 'localhost:9092', 'async_produce': False, 'models': [{'module_name': 'image_classification.predict', 'class_name': 'ModelPredictor'}]} |
'''
Have the function SimpleMode(arr) take the array of numbers stored in arr and return the number that appears most frequently (the mode).
For example: if arr contains [10, 4, 5, 2, 4] the output should be 4. If there is more than one mode return the one
that appeared in the array first (ie. [5, 10, 10, 6, 5] sh... | """
Have the function SimpleMode(arr) take the array of numbers stored in arr and return the number that appears most frequently (the mode).
For example: if arr contains [10, 4, 5, 2, 4] the output should be 4. If there is more than one mode return the one
that appeared in the array first (ie. [5, 10, 10, 6, 5] shoul... |
class Pipe(object):
def __init__(self, *args):
self.functions = args
self.state = {'error': '', 'result': None}
def __call__(self, value):
if not value:
raise "Not any value for running"
self.state['result'] = self.data_pipe(value)
return self.state
def ... | class Pipe(object):
def __init__(self, *args):
self.functions = args
self.state = {'error': '', 'result': None}
def __call__(self, value):
if not value:
raise 'Not any value for running'
self.state['result'] = self.data_pipe(value)
return self.state
def... |
#code
class Node :
def __init__(self,data):
self.data = data
self.next = None
class LinkedList :
def __init__(self):
self.head = None
def Push(self,new_data):
if(self.head== None):
self.head = Node(new_data)
else:
new_node = Node(new_data)
... | class Node:
def __init__(self, data):
self.data = data
self.next = None
class Linkedlist:
def __init__(self):
self.head = None
def push(self, new_data):
if self.head == None:
self.head = node(new_data)
else:
new_node = node(new_data)
... |
NONE = 0
HALT = 1 << 0
FAULT = 1 << 1
BREAK = 1 << 2
| none = 0
halt = 1 << 0
fault = 1 << 1
break = 1 << 2 |
# Pascal's Triangle
# @author unobatbayar
# Input website link and download to a directory
# @author unobatbayar just for comments not whole code this time
# @program 10
# date 27-10-2018
print("Welcome to Pascal's Triangle!" + "\n")
row = int(input('Please input a row number to which you want to see the triangle ... | print("Welcome to Pascal's Triangle!" + '\n')
row = int(input('Please input a row number to which you want to see the triangle to' + '\n'))
a = []
for i in range(row):
a.append([])
a[i].append(1)
for j in range(1, i):
a[i].append(a[i - 1][j - 1] + a[i - 1][j])
if row != 0:
a[i].append(1)... |
class StorageDriverError(Exception):
pass
class ObjectDoesNotExistError(StorageDriverError):
def __init__(self, driver, bucket, object_name):
super().__init__(
f"Bucket {bucket} does not contain {object_name} (driver={driver})"
)
class AssetsManagerError(Exception):
pass
cl... | class Storagedrivererror(Exception):
pass
class Objectdoesnotexisterror(StorageDriverError):
def __init__(self, driver, bucket, object_name):
super().__init__(f'Bucket {bucket} does not contain {object_name} (driver={driver})')
class Assetsmanagererror(Exception):
pass
class Assetalreadyexistser... |
class Solution:
def maximizeSweetness(self, sweetness: List[int], K: int) -> int:
low, high = 1, sum(sweetness) // (K + 1)
while low < high:
mid = (low + high + 1) // 2
count = curr = 0
for s in sweetness:
curr += s
if curr >= mid:
... | class Solution:
def maximize_sweetness(self, sweetness: List[int], K: int) -> int:
(low, high) = (1, sum(sweetness) // (K + 1))
while low < high:
mid = (low + high + 1) // 2
count = curr = 0
for s in sweetness:
curr += s
if curr >=... |
taggable_resources = [
# API Gateway
"aws_api_gateway_stage",
# ACM
"aws_acm_certificate",
"aws_acmpca_certificate_authority",
# CloudFront
"aws_cloudfront_distribution",
# CloudTrail
"aws_cloudtrail",
# AppSync
"aws_appsync_graphql_api",
# Backup
"aws_backup_plan",
... | taggable_resources = ['aws_api_gateway_stage', 'aws_acm_certificate', 'aws_acmpca_certificate_authority', 'aws_cloudfront_distribution', 'aws_cloudtrail', 'aws_appsync_graphql_api', 'aws_backup_plan', 'aws_backup_vault', 'aws_cloudformation_stack', 'aws_cloudformation_stack_set', 'aws_batch_compute_environment', 'aws_c... |
CREATE_VENV__CMD = b'UkVNIE5lY2Vzc2FyeSBGaWxlczoNClJFTSAtIHByZV9zZXR1cF9zY3JpcHRzLnR4dA0KUkVNIC0gcmVxdWlyZWRfcGVyc29uYWxfcGFja2FnZXMudHh0DQpSRU0gLSByZXF1aXJlZF9taXNjLnR4dA0KUkVNIC0gcmVxdWlyZWRfUXQudHh0DQpSRU0gLSByZXF1aXJlZF9mcm9tX2dpdGh1Yi50eHQNClJFTSAtIHJlcXVpcmVkX3Rlc3QudHh0DQpSRU0gLSByZXF1aXJlZF9kZXYudHh0DQpSRU0gLSB... | create_venv__cmd = b'UkVNIE5lY2Vzc2FyeSBGaWxlczoNClJFTSAtIHByZV9zZXR1cF9zY3JpcHRzLnR4dA0KUkVNIC0gcmVxdWlyZWRfcGVyc29uYWxfcGFja2FnZXMudHh0DQpSRU0gLSByZXF1aXJlZF9taXNjLnR4dA0KUkVNIC0gcmVxdWlyZWRfUXQudHh0DQpSRU0gLSByZXF1aXJlZF9mcm9tX2dpdGh1Yi50eHQNClJFTSAtIHJlcXVpcmVkX3Rlc3QudHh0DQpSRU0gLSByZXF1aXJlZF9kZXYudHh0DQpSRU0gLSB... |
n = int(input())
def sum_input():
_sum = 0
for i in range(n):
_sum += int(input())
return _sum
left_sum = sum_input()
right_sum = sum_input()
if left_sum == right_sum:
print("Yes, sum =", left_sum)
else:
print("No, diff =", abs(left_sum - right_sum)) | n = int(input())
def sum_input():
_sum = 0
for i in range(n):
_sum += int(input())
return _sum
left_sum = sum_input()
right_sum = sum_input()
if left_sum == right_sum:
print('Yes, sum =', left_sum)
else:
print('No, diff =', abs(left_sum - right_sum)) |
a = int(input())
while(a):
counti = 0
counte = 0
b = input()
for i in b:
if(i=='1'):
counti+=1
elif(i=='2'):
counte+=1
elif(i=='0'):
counte+=1
counti+=1
if(counti>counte):
print("INDIA")
elif(counte>counti):
... | a = int(input())
while a:
counti = 0
counte = 0
b = input()
for i in b:
if i == '1':
counti += 1
elif i == '2':
counte += 1
elif i == '0':
counte += 1
counti += 1
if counti > counte:
print('INDIA')
elif counte > coun... |
text = input('Enter the text:\n')
if ('make a lot of money' in text):
spam = True
elif ('buy now' in text):
spam = True
elif ('watch this' in text):
spam = True
elif ('click this' in text):
spam = True
elif ('subscribe this' in text):
spam = True
else:
spam = False
if (spam):
... | text = input('Enter the text:\n')
if 'make a lot of money' in text:
spam = True
elif 'buy now' in text:
spam = True
elif 'watch this' in text:
spam = True
elif 'click this' in text:
spam = True
elif 'subscribe this' in text:
spam = True
else:
spam = False
if spam:
print('This text is spam.')... |
a=input()
b=int(len(a))
for i in range(b):
print(a[i])
| a = input()
b = int(len(a))
for i in range(b):
print(a[i]) |
def second_largest(mylist):
largest = None
second_largest = None
for num in mylist:
if largest is None:
largest = num
elif num > largest:
second_largest = largest
largest = num
elif second_largest is None:
second_largest = num
elif num > second_largest:
second_largest = num
return second_la... | def second_largest(mylist):
largest = None
second_largest = None
for num in mylist:
if largest is None:
largest = num
elif num > largest:
second_largest = largest
largest = num
elif second_largest is None:
second_largest = num
e... |
# ===========
# BoE
# ===========
class HP_IMDB_BOE:
batch_size = 64
learning_rate = 1e-3
learning_rate_dpsgd = 1e-3
patience = 5
tgt_class = 1
sequence_length = 512
class HP_DBPedia_BOE:
batch_size = 256
learning_rate = 1e-3
learning_rate_dpsgd = 1e-3
patience = 2
tgt_cla... | class Hp_Imdb_Boe:
batch_size = 64
learning_rate = 0.001
learning_rate_dpsgd = 0.001
patience = 5
tgt_class = 1
sequence_length = 512
class Hp_Dbpedia_Boe:
batch_size = 256
learning_rate = 0.001
learning_rate_dpsgd = 0.001
patience = 2
tgt_class = 1
sequence_length = 256... |
def get_azure_config(provider_config):
config_dict = {}
azure_storage_type = provider_config.get("azure_cloud_storage", {}).get("azure.storage.type")
if azure_storage_type:
config_dict["AZURE_STORAGE_TYPE"] = azure_storage_type
azure_storage_account = provider_config.get("azure_cloud_storage",... | def get_azure_config(provider_config):
config_dict = {}
azure_storage_type = provider_config.get('azure_cloud_storage', {}).get('azure.storage.type')
if azure_storage_type:
config_dict['AZURE_STORAGE_TYPE'] = azure_storage_type
azure_storage_account = provider_config.get('azure_cloud_storage', {... |
backslashes_test_text_001 = '''
string = 'string'
'''
backslashes_test_text_002 = '''
string = 'string_start \\
string end'
'''
backslashes_test_text_003 = '''
if arg_one is not None \\
and arg_two is None:
pass
'''
backslashes_test_text_004 = '''
string = \'\'\'
text \\\\
text
\'\'\'
'''
| backslashes_test_text_001 = "\nstring = 'string'\n"
backslashes_test_text_002 = "\nstring = 'string_start \\\n string end'\n"
backslashes_test_text_003 = '\nif arg_one is not None \\\n and arg_two is None:\n pass\n'
backslashes_test_text_004 = "\nstring = '''\n text \\\\\n text\n'''\n" |
# 1
def front_two_back_two(input_string):
return '' if len(input_string) < 2 else input_string[:2] + input_string[-2:]
# 2
def kelvin_to_celsius(k):
return k - 273.15
# 2
def kelvin_to_fahrenheit(k):
return kelvin_to_celsius(k) * 9.0 / 5.0 + 32.0
# 4
def min_max_sum(input_list):
return [min(input_... | def front_two_back_two(input_string):
return '' if len(input_string) < 2 else input_string[:2] + input_string[-2:]
def kelvin_to_celsius(k):
return k - 273.15
def kelvin_to_fahrenheit(k):
return kelvin_to_celsius(k) * 9.0 / 5.0 + 32.0
def min_max_sum(input_list):
return [min(input_list), max(input_li... |
class Data:
def __init__(self, dia, mes, ano):
self.dia = dia
self.mes = mes
self.ano = ano
print(self)
@classmethod
def de_string(cls, data_string):
dia, mes, ano = map(int, data_string.split('-'))
data = cls(dia, mes, ano)
return data
@staticmethod
def is_date_valid(data_string):
dia, mes, an... | class Data:
def __init__(self, dia, mes, ano):
self.dia = dia
self.mes = mes
self.ano = ano
print(self)
@classmethod
def de_string(cls, data_string):
(dia, mes, ano) = map(int, data_string.split('-'))
data = cls(dia, mes, ano)
return data
@stati... |
# author: Fei Gao
#
# Evaluate Reverse Polish Notation
#
# Evaluate the value of an arithmetic expression in Reverse Polish Notation.
# Valid operators are +, -, *, /. Each operand may be an integer or another expression.
# Some examples:
# ["2", "1", "+", "3", "*"] -> ((2 + 1) * 3) -> 9
# ["4", "13", "5", "/", "+"] ->... | class Solution:
def eval_rpn(self, tokens):
if not tokens:
return None
op = {'+': lambda x, y: x + y, '-': lambda x, y: x - y, '*': lambda x, y: x * y, '/': lambda x, y: int(float(x) / y)}
queue = list()
for val in tokens:
if isinstance(val, list):
... |
ROUTE_MIDDLEWARE = {
'test': 'app.http.middleware.MiddlewareTest.MiddlewareTest',
'middleware.test': [
'app.http.middleware.MiddlewareTest.MiddlewareTest',
'app.http.middleware.AddAttributeMiddleware.AddAttributeMiddleware'
]
}
| route_middleware = {'test': 'app.http.middleware.MiddlewareTest.MiddlewareTest', 'middleware.test': ['app.http.middleware.MiddlewareTest.MiddlewareTest', 'app.http.middleware.AddAttributeMiddleware.AddAttributeMiddleware']} |
# file creation
myfile1 = open("truncate.txt", "w")
# writing data to the file
myfile1.write("Python is a user-friendly language for beginners")
# file truncating to 30 bytes
myfile1.truncate(30)
# file is getting closed
myfile1.close()
# file reading and displaying the text
myfile2 = open("truncate.tx... | myfile1 = open('truncate.txt', 'w')
myfile1.write('Python is a user-friendly language for beginners')
myfile1.truncate(30)
myfile1.close()
myfile2 = open('truncate.txt', 'r')
print(myfile2.read())
myfile2.close() |
a = {'C', 'C++', 'Java'}
b = {'C++', 'Java', 'Python'}
c = {'java', 'Python', 'C', 'pascal'}
# who known all three subject
u = a.union(b).union(c)
print("Union", u)
# find subject known to A and not to B
i = a.intersection(b)
print("Intersection", i)
diff1 = a.difference(b)
print(a, b, "C-F", diff1)
#find a subjec... | a = {'C', 'C++', 'Java'}
b = {'C++', 'Java', 'Python'}
c = {'java', 'Python', 'C', 'pascal'}
u = a.union(b).union(c)
print('Union', u)
i = a.intersection(b)
print('Intersection', i)
diff1 = a.difference(b)
print(a, b, 'C-F', diff1)
studentswhoknowonlypascal = []
if 'pascal ' in a:
studentswhoknowonlypascal.append('... |
nk = input().split()
n = int(nk[0])
k = int(nk[1])
r = int(input())
c = int(input())
o = []
z=0
for _ in range(k):
o.append(list(map(int, input().rstrip().split())))
l=[]
p=[]
a=[]
for i in range(n):
l=l+[0]
for i in range(n):
l[i]=[0]*n
l[r-1][c-1]=1
for i in range(len(o)):
l[o[i][0]-... | nk = input().split()
n = int(nk[0])
k = int(nk[1])
r = int(input())
c = int(input())
o = []
z = 0
for _ in range(k):
o.append(list(map(int, input().rstrip().split())))
l = []
p = []
a = []
for i in range(n):
l = l + [0]
for i in range(n):
l[i] = [0] * n
l[r - 1][c - 1] = 1
for i in range(len(o)):
l[o[i]... |
def eig(a):
# TODO(beam2d): Implement it
raise NotImplementedError
def eigh(a, UPLO='L'):
# TODO(beam2d): Implement it
raise NotImplementedError
def eigvals(a):
# TODO(beam2d): Implement it
raise NotImplementedError
def eigvalsh(a, UPLO='L'):
# TODO(beam2d): Implement it
raise NotI... | def eig(a):
raise NotImplementedError
def eigh(a, UPLO='L'):
raise NotImplementedError
def eigvals(a):
raise NotImplementedError
def eigvalsh(a, UPLO='L'):
raise NotImplementedError |
# ex1116 Dividindo x por y
n = int(input())
for c in range(1, n + 1):
x, y = map(float, input().split())
if x > y and y != 0:
divisao = x / y
print('{:.1f}'.format(divisao))
elif x > y and y == 0:
print('divisao impossivel')
if x < y and y != 0:
divisao = x / y
p... | n = int(input())
for c in range(1, n + 1):
(x, y) = map(float, input().split())
if x > y and y != 0:
divisao = x / y
print('{:.1f}'.format(divisao))
elif x > y and y == 0:
print('divisao impossivel')
if x < y and y != 0:
divisao = x / y
print('{:.1f}'.format(divis... |
# https://leetcode.com/problems/valid-perfect-square
class Solution:
def isPerfectSquare(self, num):
if num == 1:
return True
l, r = 1, num
while l <= r:
mid = (l + r) // 2
if mid ** 2 == num:
return True
elif mid ** 2 < num:
... | class Solution:
def is_perfect_square(self, num):
if num == 1:
return True
(l, r) = (1, num)
while l <= r:
mid = (l + r) // 2
if mid ** 2 == num:
return True
elif mid ** 2 < num:
l = mid + 1
else:
... |
'''
Color Pallette
'''
# Generic Stuff
BLACK = ( 0, 0, 0)
WHITE = (255, 255, 255)
# Pane Colors
PANE1 = (236, 236, 236)
PANE2 = (255, 255, 255)
PANE3 = (236, 236, 236)
# Player Color
PLAYER_COLOR = BLACK
# Reds
RED_POMEGRANATE = (242, 38, 19)
RED_THUNDERBIRD = (217, 30, 24)
RED_FLAMINGO = (239, 72, 54... | """
Color Pallette
"""
black = (0, 0, 0)
white = (255, 255, 255)
pane1 = (236, 236, 236)
pane2 = (255, 255, 255)
pane3 = (236, 236, 236)
player_color = BLACK
red_pomegranate = (242, 38, 19)
red_thunderbird = (217, 30, 24)
red_flamingo = (239, 72, 54)
red_razzmatazz = (219, 10, 91)
red_radicalred = (246, 36, 89)
red_ecs... |
lista = list()
vezesInput = 0
while vezesInput < 6:
valor = float(input())
if valor > 0:
lista.append(valor)
vezesInput += 1
print(f'{len(lista)} valores positivos') | lista = list()
vezes_input = 0
while vezesInput < 6:
valor = float(input())
if valor > 0:
lista.append(valor)
vezes_input += 1
print(f'{len(lista)} valores positivos') |
# -*- coding: utf-8 -*-
# This file is generated from NI Switch Executive API metadata version 19.1.0d1
enums = {
'ExpandAction': {
'values': [
{
'documentation': {
'description': 'Expand to routes'
},
'name': 'NISE_VAL_EXPAND_T... | enums = {'ExpandAction': {'values': [{'documentation': {'description': 'Expand to routes'}, 'name': 'NISE_VAL_EXPAND_TO_ROUTES', 'value': 0}, {'documentation': {'description': 'Expand to paths'}, 'name': 'NISE_VAL_EXPAND_TO_PATHS', 'value': 1}]}, 'MulticonnectMode': {'values': [{'documentation': {'description': 'Defaul... |
# Click trackpad of first controller by "C" key
alvr.buttons[0][alvr.Id("trackpad_click")] = keyboard.getKeyDown(Key.C)
alvr.buttons[0][alvr.Id("trackpad_touch")] = keyboard.getKeyDown(Key.C)
# Move trackpad position by arrow keys
if keyboard.getKeyDown(Key.LeftArrow):
alvr.trackpad[0][0] = -1.0
alvr.trackpad[0][1... | alvr.buttons[0][alvr.Id('trackpad_click')] = keyboard.getKeyDown(Key.C)
alvr.buttons[0][alvr.Id('trackpad_touch')] = keyboard.getKeyDown(Key.C)
if keyboard.getKeyDown(Key.LeftArrow):
alvr.trackpad[0][0] = -1.0
alvr.trackpad[0][1] = 0.0
elif keyboard.getKeyDown(Key.UpArrow):
alvr.trackpad[0][0] = 0.0
alv... |
class Solution:
def checkInclusion(self, s1: str, s2: str) -> bool:
'''
T: O(n2 * n1 log n1); can be reduced to O(n2 * n1) by using char counter
S: O(n1); can be reduced to O(26) = O(1) by using character counting array
'''
n1, n2 = len(s1), len(s2)
s1 = sorted(s1)
... | class Solution:
def check_inclusion(self, s1: str, s2: str) -> bool:
"""
T: O(n2 * n1 log n1); can be reduced to O(n2 * n1) by using char counter
S: O(n1); can be reduced to O(26) = O(1) by using character counting array
"""
(n1, n2) = (len(s1), len(s2))
s1 = sorted(... |
#!/usr/bin/env python3
# MIT License
# Copyright (c) 2020 pixelbubble
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, ... | def generate_accounts():
first_name = input('First name: ').lower()
last_name = input('Last name: ').lower()
year_of_birth = input('Year of birth: ')
pseudo = input('Username (optional): ').lower()
zip_code = input('Zip code (optional): ')
results_list = []
results_list.append(firstName + la... |
# MYSQL_CONFIG = {
# 'host': '10.70.14.244',
# 'port': 33044,
# 'user': 'view',
# 'password': '!@View123',
# 'database': 'yjyg'
# }
MYSQL_CONFIG = {
'host': '127.0.0.1',
'port': 33004,
'user': 'root',
'password': 'q1w2e3r4',
'database': 'yjyg'
} | mysql_config = {'host': '127.0.0.1', 'port': 33004, 'user': 'root', 'password': 'q1w2e3r4', 'database': 'yjyg'} |
def cheapest_flour(input1,output1):
a=[]
b=[]
with open(input1,"r") as input_file:
number1=0
for i in input_file.readlines():
a.append(i.split())
b.append(int(a[number1][0])/int(a[number1][1]))
number1+=1
b=sorted(b,reverse=True)
with... | def cheapest_flour(input1, output1):
a = []
b = []
with open(input1, 'r') as input_file:
number1 = 0
for i in input_file.readlines():
a.append(i.split())
b.append(int(a[number1][0]) / int(a[number1][1]))
number1 += 1
b = sorted(b, reverse=True)
... |
# config.py
SEED = 42
EXTENSION = ".png"
IMAGE_H = 28
IMAGE_W = 28
CHANNELS = 3
BATCH_SIZE = 30
EPOCHS = 400
LEARNING_RATE = 0.001
CIRCLES = "../input/shapes/circles/"
SQUARES = "../input/shapes/squares/"
TRIANGLES = "../input/shapes/triangles/"
INPUT_FOLD = "../input/"
OUTPUT_FOLD = "../output/"
TRAIN_DATA = "../i... | seed = 42
extension = '.png'
image_h = 28
image_w = 28
channels = 3
batch_size = 30
epochs = 400
learning_rate = 0.001
circles = '../input/shapes/circles/'
squares = '../input/shapes/squares/'
triangles = '../input/shapes/triangles/'
input_fold = '../input/'
output_fold = '../output/'
train_data = '../input/train_datas... |
# In one of the Chinese provinces, it was decided to build a series of machines to protect the
# population against the coronavirus. The province can be visualized as an array of values 1 and 0,
# which arr[i] = 1 means that in city [i] it is possible to build a machine and value 0 that it can't.
# There is also a numb... | def machines_saving_people(T, k):
count = 0
distance = -1
protected = distance + k
while distance + k < len(T):
if protected > len(T) - 1:
protected = len(T) - 1
while T[protected] == 0 and protected >= distance + 1:
protected -= 1
if protected == distance... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.