content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
MANAGER_PATHS = {
'service': {
'ASSESSMENT': ('dlkit.services.assessment.AssessmentManager',
'dlkit.services.assessment.AssessmentManager'),
'REPOSITORY': ('dlkit.services.repository.RepositoryManager',
'dlkit.services.repository.RepositoryManager'),
... | manager_paths = {'service': {'ASSESSMENT': ('dlkit.services.assessment.AssessmentManager', 'dlkit.services.assessment.AssessmentManager'), 'REPOSITORY': ('dlkit.services.repository.RepositoryManager', 'dlkit.services.repository.RepositoryManager'), 'LEARNING': ('dlkit.services.learning.LearningManager', 'dlkit.services... |
# A magic index in an array A[0...n-1] is defined to be an indexe such that
# A[i] = i. Given a sorted array of distinct integers, write a method to find a
# magic index, if one exists, in array A.
# Assumes distinct
def find(sorted_array):
i = 0
while i < len(sorted_array):
difference = sorted_array[i] - i
... | def find(sorted_array):
i = 0
while i < len(sorted_array):
difference = sorted_array[i] - i
if difference > 0:
return None
elif difference == 0:
return i
else:
i += -difference
return None
def findr(sorted_array):
def h(a, l, r):
... |
def read_pairs():
file_name = "Data/day14.txt"
file = open(file_name, "r")
pairs = {}
for line in file:
line = line.strip("\n").split(" -> ")
pairs[(line[0][0], line[0][1])] = line[1]
return pairs, set(pairs.values())
def insertion_process(template, pairs, l... | def read_pairs():
file_name = 'Data/day14.txt'
file = open(file_name, 'r')
pairs = {}
for line in file:
line = line.strip('\n').split(' -> ')
pairs[line[0][0], line[0][1]] = line[1]
return (pairs, set(pairs.values()))
def insertion_process(template, pairs, letters, steps):
pair_... |
"""Top-level package for frontend_control."""
__author__ = """Marco Berzborn"""
__email__ = 'mbe@akustik.rwth-aachen.de'
__version__ = '0.1.0'
| """Top-level package for frontend_control."""
__author__ = 'Marco Berzborn'
__email__ = 'mbe@akustik.rwth-aachen.de'
__version__ = '0.1.0' |
"""
Webtoon providers.
A provider is module containing functions to parse webtoons.
A provider implements:
get_image_list(src): Get image list from given source.
get_next_episode_url(src): Get next episode's url from given source.
get_episode_name(src): Get episode's name from given source.
A mapping is a... | """
Webtoon providers.
A provider is module containing functions to parse webtoons.
A provider implements:
get_image_list(src): Get image list from given source.
get_next_episode_url(src): Get next episode's url from given source.
get_episode_name(src): Get episode's name from given source.
A mapping is a... |
"""sh module. Contains classes Shape, Square and Circle"""
class Shape:
"""Shape class: has method move"""
def __init__(self, x, y):
self.x = x
self.y = y
def move(self, deltaX, deltaY):
self.x = self.x + deltaX
self.y = self.y + deltaY
class Square(Shape):
"""Square Cla... | """sh module. Contains classes Shape, Square and Circle"""
class Shape:
"""Shape class: has method move"""
def __init__(self, x, y):
self.x = x
self.y = y
def move(self, deltaX, deltaY):
self.x = self.x + deltaX
self.y = self.y + deltaY
class Square(Shape):
"""Square ... |
class Stack:
sizeof = 0
def __init__(self,list = None):
if list == None:
self.item =[]
else :
self.item = list
def push(self,i):
self.item.append(i)
def size(self):
return len(self.item)
def isEmpty(self):
if self.size()==0:
... | class Stack:
sizeof = 0
def __init__(self, list=None):
if list == None:
self.item = []
else:
self.item = list
def push(self, i):
self.item.append(i)
def size(self):
return len(self.item)
def is_empty(self):
if self.size() == 0:
... |
# https://adventofcode.com/2021/day/17
# SAMPLE
# target area: x=20..30, y=-10..-5
target_x = [20, 30]
target_y = [-10, -5]
# velocity ranges to probe brute force (start by big enough values then tweak it down based on the printed value range)
velocity_range_x = [0, 40]
velocity_range_y = [-30, 1000]
steps_range = 25 ... | target_x = [20, 30]
target_y = [-10, -5]
velocity_range_x = [0, 40]
velocity_range_y = [-30, 1000]
steps_range = 25
target_x = [144, 178]
target_y = [-100, -76]
velocity_range_x = [0, 350]
velocity_range_y = [-101, 100]
steps_range = 200
total_max_y = 0
hit_counter = 0
total_max_steps_to_hit = 0
range_y_min = 999999
ra... |
'''
Author: ZHAO Zinan
Created: 12/13/2018
62. Unique Paths
'''
class Solution:
def uniquePaths(self, m, n):
"""
:type m: int
:type n: int
:rtype: int
"""
if not m or not n:
return 0
if n == 1:
return 1
if m... | """
Author: ZHAO Zinan
Created: 12/13/2018
62. Unique Paths
"""
class Solution:
def unique_paths(self, m, n):
"""
:type m: int
:type n: int
:rtype: int
"""
if not m or not n:
return 0
if n == 1:
return 1
if m == 1:
... |
class Solution:
def nthSuperUglyNumber(self, n, primes):
"""
:type n: int
:type primes: List[int]
:rtype: int
"""
uglies = [1]
pq = [(prime, 0, prime) for prime in primes]
heapq.heapify(pq)
while len(uglies) < n:
val, i, factor = he... | class Solution:
def nth_super_ugly_number(self, n, primes):
"""
:type n: int
:type primes: List[int]
:rtype: int
"""
uglies = [1]
pq = [(prime, 0, prime) for prime in primes]
heapq.heapify(pq)
while len(uglies) < n:
(val, i, factor... |
"""
Complete this function such that it returns True if and only if
the string passed into this function is a palindrome, that is if
it is the same string of characters forwards and in reverse.
Return False otherwise.
This solution computes the midpoint of the input_string and then
compares letters from the outside... | """
Complete this function such that it returns True if and only if
the string passed into this function is a palindrome, that is if
it is the same string of characters forwards and in reverse.
Return False otherwise.
This solution computes the midpoint of the input_string and then
compares letters from the outside... |
class Object():
def __init__(self, pos, img):
self.pos = pos
self.img = img
self.rect = []
def fromSafe(string):
string = string.strip()
s = string.split(",")
ret = Object((int(s[2]), int(s[1])), s[0])
return ret
| class Object:
def __init__(self, pos, img):
self.pos = pos
self.img = img
self.rect = []
def from_safe(string):
string = string.strip()
s = string.split(',')
ret = object((int(s[2]), int(s[1])), s[0])
return ret |
"""
author: https://github.com/alif-arrizqy
lesson: boolean logic
"""
print(20 > 8)
# output: True
print(8 > 20)
# output: False
print(9==9)
# output: True | """
author: https://github.com/alif-arrizqy
lesson: boolean logic
"""
print(20 > 8)
print(8 > 20)
print(9 == 9) |
class MovieModel:
def __init__(self, *, id, title, year, rating):
self.id = id
self.title = title
self.year = year
self.rating = rating
| class Moviemodel:
def __init__(self, *, id, title, year, rating):
self.id = id
self.title = title
self.year = year
self.rating = rating |
"""
278
first bad version
easy
You are a product manager and currently leading a team to develop a new product.
Unfortunately, the latest version of your product fails the quality check. Since
each version is developed based on the previous version, all the versions after
a bad version are also bad.
Suppose you hav... | """
278
first bad version
easy
You are a product manager and currently leading a team to develop a new product.
Unfortunately, the latest version of your product fails the quality check. Since
each version is developed based on the previous version, all the versions after
a bad version are also bad.
Suppose you hav... |
N = int(input())
IN = OUT = 0
for _ in range(0, N):
X = int(input())
if 10 <= X <= 20:
IN += 1
else:
OUT += 1
print(f"{IN} in")
print(f"{OUT} out")
| n = int(input())
in = out = 0
for _ in range(0, N):
x = int(input())
if 10 <= X <= 20:
in += 1
else:
out += 1
print(f'{IN} in')
print(f'{OUT} out') |
"""Settings for the Topology NApp."""
# Set this option to true if you need the topology with bi-directional links
# DISPLAY_FULL_DUPLEX_LINKS = True
# Time (in seconds) to wait before setting a link as up
LINK_UP_TIMER = 10
# Time (in seconds) to wait for a confirmation from storehouse
# when retrieving or updating... | """Settings for the Topology NApp."""
link_up_timer = 10
storehouse_timeout = 5.0
storehouse_wait_interval = 0.05 |
# https://quera.ir/problemset/contest/9595/
n = int(input())
lines = [input() for i in range(2 * n)]
cnt = 0
for i in range(0, 2 * n, 2):
if lines[i].replace(' ', '') == lines[i + 1].replace(' ', ''):
continue
cnt += 1
print(cnt)
| n = int(input())
lines = [input() for i in range(2 * n)]
cnt = 0
for i in range(0, 2 * n, 2):
if lines[i].replace(' ', '') == lines[i + 1].replace(' ', ''):
continue
cnt += 1
print(cnt) |
"""
Python file unde ne declaram clasa "Bicicleta" - obiect prinicipal al acestei aplicatii
"""
class Bicicleta:
def __init__(self , id , tip , pret):
self.id = id #integer number greater than 0
self.tip = tip #a basic string
self.pret = pret #float number greater than 0
def getid(sel... | """
Python file unde ne declaram clasa "Bicicleta" - obiect prinicipal al acestei aplicatii
"""
class Bicicleta:
def __init__(self, id, tip, pret):
self.id = id
self.tip = tip
self.pret = pret
def getid(self):
"""
Functie care returneaza id-ul unui obiect de tip "Bicic... |
#!/usr/bin/env python3
class Piece:
def __init__(self, id, value):
self.__id = id
self.__value = value
@property
def id(self):
return self.__id
@id.setter
def id(self, id):
self.__id = id
@property
def value(self):
return self.__value
@value.... | class Piece:
def __init__(self, id, value):
self.__id = id
self.__value = value
@property
def id(self):
return self.__id
@id.setter
def id(self, id):
self.__id = id
@property
def value(self):
return self.__value
@value.setter
def value(sel... |
#!/usr/bin/env python3
def solution(n):
"""
Given a positive integer N,
returns the length of its longest binary gap.
"""
# possible states (START state is necessary to ignore trailing zeros)
START = -1
LAST_SAW_ONE = 1
LAST_SAW_ZERO = 0
current_state = START
# we move the bit mask's bit one po... | def solution(n):
"""
Given a positive integer N,
returns the length of its longest binary gap.
"""
start = -1
last_saw_one = 1
last_saw_zero = 0
current_state = START
bit_mask = 1
max_gap = 0
loop_gap = 0
while bit_mask <= n:
if n & bit_mask == 0:
if current... |
class Person:
def __init__(self, age):
self.age = age
def drink(self):
return "drinking"
def drive(self):
return "driving"
def drink_and_drive(self):
return "driving while drunk"
class ResponsiblePerson:
def __init__(self, person):
self.person = person
... | class Person:
def __init__(self, age):
self.age = age
def drink(self):
return 'drinking'
def drive(self):
return 'driving'
def drink_and_drive(self):
return 'driving while drunk'
class Responsibleperson:
def __init__(self, person):
self.person = person
... |
class A(object):
pass
class B(object):
pass
| class A(object):
pass
class B(object):
pass |
class Solution:
"""
@param image: a binary matrix with '0' and '1'
@param x: the location of one of the black pixels
@param y: the location of one of the black pixels
@return: an integer
"""
def minArea(self, image, x, y):
if image is None or len(image) == 0:
return 0
... | class Solution:
"""
@param image: a binary matrix with '0' and '1'
@param x: the location of one of the black pixels
@param y: the location of one of the black pixels
@return: an integer
"""
def min_area(self, image, x, y):
if image is None or len(image) == 0:
return 0
... |
"""
@author: Jessie Jiang
"""
class Style:
'''
class describing the style for the ploting and drawing
'''
def __init__(self, style_name=None,
compartment_fill_color=None,
compartment_border_color=None,
species_fill_color=None,
species_b... | """
@author: Jessie Jiang
"""
class Style:
"""
class describing the style for the ploting and drawing
"""
def __init__(self, style_name=None, compartment_fill_color=None, compartment_border_color=None, species_fill_color=None, species_border_color=None, reaction_line_color=None, font_color=None, progr... |
"""MapReduce job that makes predictions with MLModel classes."""
# package metadata
__version_info__ = (0, 1, 0)
__version__ = '.'.join([str(i) for i in __version_info__])
| """MapReduce job that makes predictions with MLModel classes."""
__version_info__ = (0, 1, 0)
__version__ = '.'.join([str(i) for i in __version_info__]) |
sum=0
for i in range(5):
n=int(input())
sum+=n
print(sum) | sum = 0
for i in range(5):
n = int(input())
sum += n
print(sum) |
#
# @lc app=leetcode id=170 lang=python3
#
# [170] Two Sum III - Data structure design
#
# @lc code=start
class TwoSum:
def __init__(self):
self.vals = []
def add(self, number: int) -> None:
self.vals.append(number)
def find(self, value: int) -> bool:
s = set()
... | class Twosum:
def __init__(self):
self.vals = []
def add(self, number: int) -> None:
self.vals.append(number)
def find(self, value: int) -> bool:
s = set()
for val in self.vals:
if value - val in s:
return True
elif val not in s:
... |
def go_to_formation_2_alg(position_blue_robots):
rule_0 = [0] + go_to_point(position_blue_robots[0][0], position_blue_robots[0][1], -4500.0, 0.0)
rule_1 = [1] + go_to_point(position_blue_robots[1][0], position_blue_robots[1][1], -3600.0, -550.0)
rule_2 = [2] + go_to_point(position_blue_robots[2]... | def go_to_formation_2_alg(position_blue_robots):
rule_0 = [0] + go_to_point(position_blue_robots[0][0], position_blue_robots[0][1], -4500.0, 0.0)
rule_1 = [1] + go_to_point(position_blue_robots[1][0], position_blue_robots[1][1], -3600.0, -550.0)
rule_2 = [2] + go_to_point(position_blue_robots[2][0], positio... |
infile=int(open('primes.in','r').readline())
outfile=open('primes.out','w')
max1=10**infile
for i in range(infile,max1):
prime=True
for e in range(2,i//2):
if (i%e) == 0:
prime=False
break
if i==1:
answer=0
break
elif prime==True:
answer=... | infile = int(open('primes.in', 'r').readline())
outfile = open('primes.out', 'w')
max1 = 10 ** infile
for i in range(infile, max1):
prime = True
for e in range(2, i // 2):
if i % e == 0:
prime = False
break
if i == 1:
answer = 0
break
elif prime == True:
... |
"""
__init__.py
Created by: Martin Sicho
On: 5/4/20, 10:46 AM
"""
| """
__init__.py
Created by: Martin Sicho
On: 5/4/20, 10:46 AM
""" |
class Node:
def __init__(self, data=None):
self.data = data
self.left = None
self.right = None
# Insert method to create nodes
def insert(self, data):
if self.data:
if data < self.data:
if self.left is None:
self.left ... | class Node:
def __init__(self, data=None):
self.data = data
self.left = None
self.right = None
def insert(self, data):
if self.data:
if data < self.data:
if self.left is None:
self.left = node(data)
else:
... |
n, m = [int(i) for i in input().split()]
if n-m > m-1:
print(min(m+1, n))
else:
print(max(m-1, 1))
| (n, m) = [int(i) for i in input().split()]
if n - m > m - 1:
print(min(m + 1, n))
else:
print(max(m - 1, 1)) |
"""
Module containing functions for cleaning label-lists.
"""
def merge_consecutive_labels_with_same_values(label_list, threshold=0.01):
"""
If there are consecutive (end equals start) labels, those two labels are merged into one.
Args:
label_list (LabelList): The label-list to clean.
t... | """
Module containing functions for cleaning label-lists.
"""
def merge_consecutive_labels_with_same_values(label_list, threshold=0.01):
"""
If there are consecutive (end equals start) labels, those two labels are merged into one.
Args:
label_list (LabelList): The label-list to clean.
th... |
#!/usr/bin/env python 3
############################################################################################
# #
# Program purpose: Count the number of substrings from a given string of lowercase #
# ... | def has_uppercase(data: str) -> bool:
for char in data:
if str.isupper(char):
return True
return False
def obtain_user_data(input_mess: str) -> str:
(is_valid, user_data) = (False, '')
while is_valid is False:
try:
user_data = input(input_mess)
if len... |
http = require("net/http")
def hello(w, req):
w.WriteHeader(201)
w.Write("hello world\n")
http.HandleFunc("/hello", hello)
http.ListenAndServe(":8080", http.Handler)
| http = require('net/http')
def hello(w, req):
w.WriteHeader(201)
w.Write('hello world\n')
http.HandleFunc('/hello', hello)
http.ListenAndServe(':8080', http.Handler) |
""" Given a sorted integer array where the range of elements are in the inclusive range [lower, upper],
return its missing ranges.
For example, given [0, 1, 3, 50, 75], lower = 0 and upper = 99, return ["2", "4->49", "51->74", "76->99"]. """
class Solution(object):
def findMissingRanges(self, nums, lower, upper):... | """ Given a sorted integer array where the range of elements are in the inclusive range [lower, upper],
return its missing ranges.
For example, given [0, 1, 3, 50, 75], lower = 0 and upper = 99, return ["2", "4->49", "51->74", "76->99"]. """
class Solution(object):
def find_missing_ranges(self, nums, lower, upper... |
'''
Sum of even & odd
Write a program to input an integer N and print the sum of all its even digits and sum of all its odd digits separately.
Digits mean numbers, not the places! That is, if the given integer is "13245", even digits are 2 & 4 and odd digits are 1, 3 & 5.
Input format :
Integer N
Output format :
Sum... | """
Sum of even & odd
Write a program to input an integer N and print the sum of all its even digits and sum of all its odd digits separately.
Digits mean numbers, not the places! That is, if the given integer is "13245", even digits are 2 & 4 and odd digits are 1, 3 & 5.
Input format :
Integer N
Output format :
Sum... |
# Eoin Lees
# this program creates a tuple that prints the summer months
months = ("January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December")
summer = months[4:7]
for month in summer:
print(month) | months = ('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December')
summer = months[4:7]
for month in summer:
print(month) |
# PERSON
SEARCH_PERSON = '''
query SearchPerson($searchTerm: String){
searchPerson(searchTerm: $searchTerm){
id
birth{
surname
}
}
}
'''
| search_person = '\nquery SearchPerson($searchTerm: String){\n searchPerson(searchTerm: $searchTerm){\n id\n birth{\n surname\n }\n }\n}\n' |
def is_paired(input_string):
pairs = {'[': ']', '{': '}', '(': ')'}
stack = list()
for char in input_string:
if char in pairs.keys():
stack.append(char)
elif char in pairs.values():
if not stack or pairs[stack.pop()] != char:
return False
return ... | def is_paired(input_string):
pairs = {'[': ']', '{': '}', '(': ')'}
stack = list()
for char in input_string:
if char in pairs.keys():
stack.append(char)
elif char in pairs.values():
if not stack or pairs[stack.pop()] != char:
return False
return no... |
def missing_number(original_list=[1,2,3,4,6,7,10], num_list=[10,11,12,14,17]):
original_list = [x for x in range(num_list[0], num_list[-1] + 1)]
num_list = set(num_list)
return (list(num_list ^ set(original_list)))
print(missing_number([1,2,3,4,6,7,10]))
print(missing_number([10,11,12,14,17]))
... | def missing_number(original_list=[1, 2, 3, 4, 6, 7, 10], num_list=[10, 11, 12, 14, 17]):
original_list = [x for x in range(num_list[0], num_list[-1] + 1)]
num_list = set(num_list)
return list(num_list ^ set(original_list))
print(missing_number([1, 2, 3, 4, 6, 7, 10]))
print(missing_number([10, 11, 12, 1... |
def plateau_affichage(plateau,taille,plateau_list,Htaille,plateau_lists = []) :
L=taille
H=taille
for x in range (0,L+1) :
print (str(x),(' '), end='')
for y in range (0,H+1) :
if y==0 :
print (' ')
else :
print (str(y), )
for y in range(H):
... | def plateau_affichage(plateau, taille, plateau_list, Htaille, plateau_lists=[]):
l = taille
h = taille
for x in range(0, L + 1):
print(str(x), ' ', end='')
for y in range(0, H + 1):
if y == 0:
print(' ')
else:
print(str(y))
for y in range(H):
... |
# -*- coding: utf-8 -*-
""" Encapsulates Functionality for Building Web Requests. """
class RequestBuilder(object):
""" Encapsulates Functionality for Building Web Requests.
:attr _domain: The domain component of the request.
:type _domain: str
:attr _path: The path component of the request (default... | """ Encapsulates Functionality for Building Web Requests. """
class Requestbuilder(object):
""" Encapsulates Functionality for Building Web Requests.
:attr _domain: The domain component of the request.
:type _domain: str
:attr _path: The path component of the request (default: '').
:type _path: st... |
# !/usr/bin/env python
# coding: utf-8
'''
Description:
Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive),
prove that at least one duplicate number must exist. Assume that there is only one duplicate number, find the duplicate one.
Note:
1. You must not modify... | """
Description:
Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive),
prove that at least one duplicate number must exist. Assume that there is only one duplicate number, find the duplicate one.
Note:
1. You must not modify the array (assume the array is read onl... |
# needed to let the vscode test discoverer find and import the tests
__all__ = [
'TestUnitCaja',
'TestUnitSplitter'
]
| __all__ = ['TestUnitCaja', 'TestUnitSplitter'] |
GENOMES_DIR='/media/data1/genomes'
OUT_DIR = '/media/data2/HuR_human_mouse/mouse/ribo-seq'
SRC_DIR = '/home/saket/github_projects/clip_seq_pipeline/scripts'
RAWDATA_DIR ='/media/data1/HuR_human_mouse/mouse/ribo/Penalva_L_03222017'
GENOME_BUILD = 'mm10'
GENOME_FASTA = GENOMES_DIR + '/' + GENOME_BUILD + '/fasta/'+ GENOME... | genomes_dir = '/media/data1/genomes'
out_dir = '/media/data2/HuR_human_mouse/mouse/ribo-seq'
src_dir = '/home/saket/github_projects/clip_seq_pipeline/scripts'
rawdata_dir = '/media/data1/HuR_human_mouse/mouse/ribo/Penalva_L_03222017'
genome_build = 'mm10'
genome_fasta = GENOMES_DIR + '/' + GENOME_BUILD + '/fasta/' + GE... |
class Solution:
# @param A : head node of linked list
# @param B : integer
# @return the head node in the linked list
def partition(self, A, B):
head0 = None
tail0 = None
head1 = None
tail1 = None
ptr = A
while ptr is not None :
ptr2 = ptr.next
... | class Solution:
def partition(self, A, B):
head0 = None
tail0 = None
head1 = None
tail1 = None
ptr = A
while ptr is not None:
ptr2 = ptr.next
ptr.next = None
if ptr.val < B:
if head0 is None:
hea... |
"""
ord
"""
def hash_me(text):
hash_value = 0
for e in text:
hash_value += ord(e)
return hash_value
def print_my_chars(text):
for e in text:
print(ord(e), end=" ")
message1 = "Python is Great!"
message2 = "Python is GREAT!"
print(hash_me(message1))
print(hash_me(mes... | """
ord
"""
def hash_me(text):
hash_value = 0
for e in text:
hash_value += ord(e)
return hash_value
def print_my_chars(text):
for e in text:
print(ord(e), end=' ')
message1 = 'Python is Great!'
message2 = 'Python is GREAT!'
print(hash_me(message1))
print(hash_me(message2))
print_my_cha... |
# Author : SNEH DESAI
# Description : THIS IS THE CODE FOR NAIVE BAYES THEOREM
# AND IT HAD ALSO BEEN TESTED FOR ALL THE POSSIBLE RESULTS.
# DATA MINING
# Open File to read
myFile = open('Play Or Not.csv', 'r')
# Logic
ListOfLines = myFile.read().splitlines() # Reads The ... | my_file = open('Play Or Not.csv', 'r')
list_of_lines = myFile.read().splitlines()
print(ListOfLines[0])
count = 0
sunny = 0
overcast = 0
rainy = 0
hot = 0
mild = 0
cool = 0
high = 0
normal = 0
t = 0
f = 0
yes = 0
no = 0
y_sunny = 0
y_overcast = 0
y_rainy = 0
y_hot = 0
y_mild = 0
y_cool = 0
y_high = 0
y_normal = 0
y_t =... |
# https://www.codechef.com/problems/ADACRA
for T in range(int(input())):
s,u,d=input(),0,0
if(s[0]=='U'): u+=1
elif(s[0]=='D'): d+=1
for z in range(1,len(s)):
if(s[z]=='D' and s[z-1]=='U'): d+=1
elif(s[z]=='U' and s[z-1]=='D'): u+=1
print(min(d,u)) | for t in range(int(input())):
(s, u, d) = (input(), 0, 0)
if s[0] == 'U':
u += 1
elif s[0] == 'D':
d += 1
for z in range(1, len(s)):
if s[z] == 'D' and s[z - 1] == 'U':
d += 1
elif s[z] == 'U' and s[z - 1] == 'D':
u += 1
print(min(d, u)) |
__author__ = 'fengyuyao'
class Node(object):
pass
| __author__ = 'fengyuyao'
class Node(object):
pass |
ART = {
"BANNER":
"""
::'#######::::'#####::::'#######::::'#####:::
:'##.... ##::'##.. ##::'##.... ##::'##.. ##::
:..::::: ##:'##:::: ##:..::::: ##:'##:::: ##:
::'#######:: ##:::: ##::'#######:: ##:::: ##:
:'##:::::::: ##:::: #... | art = {'BANNER': '\n ::\'#######::::\'#####::::\'#######::::\'#####:::\n :\'##.... ##::\'##.. ##::\'##.... ##::\'##.. ##::\n :..::::: ##:\'##:::: ##:..::::: ##:\'##:::: ##:\n ::\'#######:: ##:::: ##::\'#######:: ##:::: ##:\n :\'##:::::::: #... |
pynasqmin = ''\
'# -*- Mode: json -*-\n'\
'############################################################\n'\
'# HPC Info (Slurm Supported)\n'\
'############################################################\n'\
'# Change here whether you are working on your personal computer\n'\
'# or an HPC with SLURM\n'... | pynasqmin = '# -*- Mode: json -*-\n############################################################\n# HPC Info (Slurm Supported)\n############################################################\n# Change here whether you are working on your personal computer\n# or an HPC with SLURM\n "is_hpc": "False",\n#... |
class OrderError(Exception):
pass
class DimensionError(Exception):
pass
class IncompatibleOrder(Exception):
pass
class InvalidOperation(Exception):
pass
class OperationNotAllowed(Exception):
pass
class OutOfRange(Exception):
pass
class ImprobableError(Exception):
pass
class Un... | class Ordererror(Exception):
pass
class Dimensionerror(Exception):
pass
class Incompatibleorder(Exception):
pass
class Invalidoperation(Exception):
pass
class Operationnotallowed(Exception):
pass
class Outofrange(Exception):
pass
class Improbableerror(Exception):
pass
class Unacceptab... |
def get_hostname(use_bytes=True):
if use_bytes:
return (b'test-server\n', b'')
else:
return 'test-server'
def get_xen_host_events():
return (
b"""
748dee41-c47f-4ec7-b2cd-037e51da4031 = "{"name": "keyinit"\n""",
b''
)
def get_xen_guest_events():
return (
... | def get_hostname(use_bytes=True):
if use_bytes:
return (b'test-server\n', b'')
else:
return 'test-server'
def get_xen_host_events():
return (b'\n748dee41-c47f-4ec7-b2cd-037e51da4031 = "{"name": "keyinit"\n', b'')
def get_xen_guest_events():
return (b'cd4ae803-1577-4e37-90b3-3de01bc4bba... |
level = {
"Fresher" : list(range(20,36)),
"Junior": list(range(36,51)),
"Middle": list(range(51,76)),
"Senior": list(range(76,101))
}
keys = {
"Frontend":{
"ReactJS":{
"Component": 6,
"Redux": 6,
"Hook": 5,
"Event": 4,
"Function Co... | level = {'Fresher': list(range(20, 36)), 'Junior': list(range(36, 51)), 'Middle': list(range(51, 76)), 'Senior': list(range(76, 101))}
keys = {'Frontend': {'ReactJS': {'Component': 6, 'Redux': 6, 'Hook': 5, 'Event': 4, 'Function Component': 3, 'Class Component': 3, 'React performance': 4, 'Unit test': 3, 'Unittest': 3,... |
#
# PySNMP MIB module ASCEND-MIBVACM-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ASCEND-MIBVACM-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 17:12:49 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, ... | (configuration,) = mibBuilder.importSymbols('ASCEND-MIB', 'configuration')
(object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, value_range_const... |
def peer(parser,logic,logging,args=0):
if args:
if "ip" in args.keys() and "p" in args.keys():
ip = args["ip"][0]
try:
port = int(args["p"][0])
except:
parser.print(args["p"][0]+": could not be cast to integer")
return
... | def peer(parser, logic, logging, args=0):
if args:
if 'ip' in args.keys() and 'p' in args.keys():
ip = args['ip'][0]
try:
port = int(args['p'][0])
except:
parser.print(args['p'][0] + ': could not be cast to integer')
return
... |
nc = str(input('Digite seu nome completo:')).strip()
print('Maisculo: {}'.format(nc.upper()))
print('Minusculo: {}'.format(nc.lower()))
print('Total de letras: {}'.format(len(nc.replace(' ', ''))))
dividido = nc.split()
print('Total de letras do primeiro nome: {}'.format(len(dividido[0])))
nc2 = str(input('Digite seu ... | nc = str(input('Digite seu nome completo:')).strip()
print('Maisculo: {}'.format(nc.upper()))
print('Minusculo: {}'.format(nc.lower()))
print('Total de letras: {}'.format(len(nc.replace(' ', ''))))
dividido = nc.split()
print('Total de letras do primeiro nome: {}'.format(len(dividido[0])))
nc2 = str(input('Digite seu n... |
nCups = int(input())
cups = {}
for i in range(nCups):
line = input().split()
if line[0].isnumeric():
cups[int(line[0])/2] = line[1]
else:
cups[int(line[1])] = line[0]
print("\n".join([cups[k] for k in sorted(cups.keys())])) | n_cups = int(input())
cups = {}
for i in range(nCups):
line = input().split()
if line[0].isnumeric():
cups[int(line[0]) / 2] = line[1]
else:
cups[int(line[1])] = line[0]
print('\n'.join([cups[k] for k in sorted(cups.keys())])) |
def test_args_kwargs(*args, **kwargs):
for k in kwargs.keys():
print(k)
test_args_kwargs(fire="hot", ice="cold") | def test_args_kwargs(*args, **kwargs):
for k in kwargs.keys():
print(k)
test_args_kwargs(fire='hot', ice='cold') |
# Template for Matrix Operations
# Created by manish.17
# https://github.com/iammanish17/CP-templates
# ----- Usage -----
#m1 = Matrix(2, 2, [[2, 4],[3, 7]])
#m2 = Matrix(2, 2, [[3, 1],[5, 2]])
#print(m1 + m2)
#print(m1 - m2)
#print(m1*m2)
#print(m1**100)
# ------------------
class Matrix(object):
def __init__(self... | class Matrix(object):
def __init__(self, n, m, values, modulo=10 ** 9 + 7):
"""Initialize a nxm matrix with given set of values!"""
self.n = n
self.m = m
self.modulo = modulo
if len(values) == n * m:
self.values = values
else:
self.values = [i... |
for episode in range(nb_episodes):
callbacks.on_episode_begin(episode)
episode_reward = 0.
episode_step = 0
# Obtain the initial observation by resetting the environment.
self.reset_states()
observation = deepcopy(env.reset())
if self.processor is not None:
observation = self.proces... | for episode in range(nb_episodes):
callbacks.on_episode_begin(episode)
episode_reward = 0.0
episode_step = 0
self.reset_states()
observation = deepcopy(env.reset())
if self.processor is not None:
observation = self.processor.process_observation(observation)
assert observation is not ... |
# sources: http://www.atrixnet.com/bs-generator.html
# https://en.wikipedia.org/wiki/List_of_buzzwords
# http://cbsg.sourceforge.net/cgi-bin/live
BUZZWORDS = {
'en': ['as a tier 1 company', 'paving the way for', 'relative to our peers', '-free', '200%', '24/365',
'24/7', '360-degree', '360... | buzzwords = {'en': ['as a tier 1 company', 'paving the way for', 'relative to our peers', '-free', '200%', '24/365', '24/7', '360-degree', '360-degree thinking', '50/50', '99.9', 'ability to deliver', 'ability to move fast', 'above-average', 'accelerate', 'accelerate the strategy', 'accelerated', 'accelerating', 'accep... |
class GLLv3:
i2c = None
__GLL_ACQ_COMMAND = 0x00
__GLL_STATUS = 0x01
__GLL_SIG_COUNT_VAL = 0x02
__GLL_ACQ_CONFIG_REG = 0x04
__GLL_VELOCITY = 0x09
__GLL_PEAK_CORR = 0x0C
__GLL_NOISE_PEAK = 0x0D
__GLL_SIGNAL_STRENGTH = 0x0E... | class Gllv3:
i2c = None
__gll_acq_command = 0
__gll_status = 1
__gll_sig_count_val = 2
__gll_acq_config_reg = 4
__gll_velocity = 9
__gll_peak_corr = 12
__gll_noise_peak = 13
__gll_signal_strength = 14
__gll_full_delay_high = 15
__gll_full_delay_low = 16
__gll_outer_loop_c... |
"""
Definition for singly-linked list with a random pointer.
class RandomListNode:
def __init__(self, x):
self.label = x
self.next = None
self.random = None
"""
class Solution:
# @param head: A RandomListNode
# @return: A RandomListNode
def copyRandomList(self, head):
d... | """
Definition for singly-linked list with a random pointer.
class RandomListNode:
def __init__(self, x):
self.label = x
self.next = None
self.random = None
"""
class Solution:
def copy_random_list(self, head):
dummy = random_list_node(0)
mapping = {}
new_node =... |
'''
06 - Using a plotting function
Defining functions allows us to reuse the same code without having to repeat all of
it. Programmers sometimes say "Don't repeat yourself".
In the previous exercise, you defined a function called plot_timeseries:
`plot_timeseries(axes, x, y, color, xlabel, ylabel)`
that takes an ... | """
06 - Using a plotting function
Defining functions allows us to reuse the same code without having to repeat all of
it. Programmers sometimes say "Don't repeat yourself".
In the previous exercise, you defined a function called plot_timeseries:
`plot_timeseries(axes, x, y, color, xlabel, ylabel)`
that takes an ... |
"""
Problem 2_3:
Write a function problem2_3() that should have a 'for' loop that steps
through the list below and prints the name of the state and the number of
letters in the state's name. You may use the len() function.
Here is the output from mine:
In [70]: problem2_3(newEngland)
Maine has 5 letters.
New Hampshire... | """
Problem 2_3:
Write a function problem2_3() that should have a 'for' loop that steps
through the list below and prints the name of the state and the number of
letters in the state's name. You may use the len() function.
Here is the output from mine:
In [70]: problem2_3(newEngland)
Maine has 5 letters.
New Hampshire... |
class Solution:
def reachNumber(self, target: int) -> int:
target = abs(target)
step, summ = 0, 0
while summ < target or (summ - target) % 2:
step += 1
summ += step
return step
| class Solution:
def reach_number(self, target: int) -> int:
target = abs(target)
(step, summ) = (0, 0)
while summ < target or (summ - target) % 2:
step += 1
summ += step
return step |
def camera_connected(messages):
for message in messages:
if u'Nikon D3000' in message:
yield u'add' == message[1:4]
| def camera_connected(messages):
for message in messages:
if u'Nikon D3000' in message:
yield (u'add' == message[1:4]) |
__package__ = 'croprows-cli'
__author__ = "Andres Herrera"
__copyright__ = "Copyright 2018, Crop Rows Generator CLI"
__credits__ = ["Andres Herrera", "Maria Patricia Uribe", "Ivan Mauricio Cabezas"]
__license__ = "GPL"
__version__ = "1.0"
__maintainer__ = "Andres Herrera"
__email__ = "fabio.herrera@correounivalle.edu.c... | __package__ = 'croprows-cli'
__author__ = 'Andres Herrera'
__copyright__ = 'Copyright 2018, Crop Rows Generator CLI'
__credits__ = ['Andres Herrera', 'Maria Patricia Uribe', 'Ivan Mauricio Cabezas']
__license__ = 'GPL'
__version__ = '1.0'
__maintainer__ = 'Andres Herrera'
__email__ = 'fabio.herrera@correounivalle.edu.c... |
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ASSETS_DEBUG = True
ALLOWED_HOSTS = []
# Database
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'midnight',
... | debug = True
assets_debug = True
allowed_hosts = []
databases = {'default': {'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'midnight', 'USER': 'postgres', 'PASSWORD': 'password', 'HOST': '192.168.56.101'}}
email_backend = 'django.core.mail.backends.filebased.EmailBackend'
email_file_path = '/tmp/emails'
a... |
"""
Module with color bar definitions.
"""
def _inflate_colorbar(cbar, numColors):
if len(cbar) >= numColors:
return cbar # do not reduce color bars
newBar = [None] * numColors
step = float(len(cbar) - 1) / (numColors - 1)
for i in xrange(numColors):
c_int = int(step * i)
... | """
Module with color bar definitions.
"""
def _inflate_colorbar(cbar, numColors):
if len(cbar) >= numColors:
return cbar
new_bar = [None] * numColors
step = float(len(cbar) - 1) / (numColors - 1)
for i in xrange(numColors):
c_int = int(step * i)
c_frac = step * i - c_int
... |
# -*- coding: utf-8 -*-
class User():
def __init__(self, username = "", password = "", email = ""):
self.username = username
self.password = password
self.email = email
def __str__(self):
return f"[{self.username}] - [pwd:{self.password} eml:{self.email}]"
| class User:
def __init__(self, username='', password='', email=''):
self.username = username
self.password = password
self.email = email
def __str__(self):
return f'[{self.username}] - [pwd:{self.password} eml:{self.email}]' |
"""Provides a decororator that automatically adds math dunder methods to a class."""
unary = "abs ceil floor neg pos round trunc".split()
binary = "add divmod floordiv mod mul pow sub truediv".split()
binary = binary + [f"r{name}" for name in binary]
dunders = tuple(f"__{name}__" for name in unary + binary)
def math... | """Provides a decororator that automatically adds math dunder methods to a class."""
unary = 'abs ceil floor neg pos round trunc'.split()
binary = 'add divmod floordiv mod mul pow sub truediv'.split()
binary = binary + [f'r{name}' for name in binary]
dunders = tuple((f'__{name}__' for name in unary + binary))
def math... |
score = 76
grades = [
(60, 'F'),
(70, 'D'),
(80, 'C'),
(90, 'B'),
]
print(next((g for x, g in grades if score < x), 'A'))
| score = 76
grades = [(60, 'F'), (70, 'D'), (80, 'C'), (90, 'B')]
print(next((g for (x, g) in grades if score < x), 'A')) |
# Flask settings
SERVER_NAME = None
DEBUG = True # Do not use debug mode in production
PORT = 5000
HOST = '0.0.0.0'
# Flask-Restplus settings
RESTPLUS_SWAGGER_UI_DOC_EXPANSION = 'list'
RESTPLUS_VALIDATE = True
RESTPLUS_MASK_SWAGGER = False
RESTPLUS_ERROR_404_HELP = False
# SQLAlchemy settings
SQLALCHEMY_DATABASE_URI... | server_name = None
debug = True
port = 5000
host = '0.0.0.0'
restplus_swagger_ui_doc_expansion = 'list'
restplus_validate = True
restplus_mask_swagger = False
restplus_error_404_help = False
sqlalchemy_database_uri = 'sqlite:///database/db.diboards'
sqlalchemy_track_modifications = True
diboards_path_upload = 'E:/Sourc... |
lista = list()
lista.append(0)
for i in range(5):
aux = int(input())
for j in range(len(lista)):
if aux <= lista[j]:
lista.insert(j,aux)
break
else:
if j==len(lista)-1:
lista.insert(j,aux)
lista.remove(lista[len(lista)-1])
print(lista) | lista = list()
lista.append(0)
for i in range(5):
aux = int(input())
for j in range(len(lista)):
if aux <= lista[j]:
lista.insert(j, aux)
break
elif j == len(lista) - 1:
lista.insert(j, aux)
lista.remove(lista[len(lista) - 1])
print(lista) |
N,K=map(int,input().split())
t=[int(input()) for i in range(N)]
count=0
for i in range(N-2):
if sum(t[i:i+3])<K:
print(i+3)
break
else:
print(-1) | (n, k) = map(int, input().split())
t = [int(input()) for i in range(N)]
count = 0
for i in range(N - 2):
if sum(t[i:i + 3]) < K:
print(i + 3)
break
else:
print(-1) |
s="(a)"
charac=["+","-","*","/"]
stack=[]
for i in s:
if i=="(":
stack.append(False)
elif i in charac:
if not stack:
continue
stack[-1]=True
elif i==")":
if stack[-1]:
stack.pop()
else:
print(1)
print(0) ... | s = '(a)'
charac = ['+', '-', '*', '/']
stack = []
for i in s:
if i == '(':
stack.append(False)
elif i in charac:
if not stack:
continue
stack[-1] = True
elif i == ')':
if stack[-1]:
stack.pop()
else:
print(1)
print(0) |
# Linear search program to search an element, return the index position of the #array
def searching(search_arr, x):
for i in range(len(search_arr)):
if search_arr[i] == x:
return i
return -1
search_arr = [3, 4, 1, 6, 14]
x=4
print("Index position for the element x i... | def searching(search_arr, x):
for i in range(len(search_arr)):
if search_arr[i] == x:
return i
return -1
search_arr = [3, 4, 1, 6, 14]
x = 4
print('Index position for the element x is:', searching(search_arr, x)) |
#Method find() searches a substring, passed as an argument, inside the string on which it's called.
# The function returns the index of the first occurrence of the substring.
# If the substring is not found, the method returns -1.
s = 'Hello'
print(s.find('e'))
print(s.find('ll'))
print(s.find("L"))
| s = 'Hello'
print(s.find('e'))
print(s.find('ll'))
print(s.find('L')) |
def isValidSubsequence(array, sequence):
"""
Takes one array and a sequence(another array) and checks if the sequence is the subsequence of the array.
solution complexity : O(n) time complexity and O(1) space complexity
args:
-----------
array : an array of numbers
sequence : an array of numbers
output... | def is_valid_subsequence(array, sequence):
"""
Takes one array and a sequence(another array) and checks if the sequence is the subsequence of the array.
solution complexity : O(n) time complexity and O(1) space complexity
args:
-----------
array : an array of numbers
sequence : an array of numbers
o... |
__author__ = 'Thierry Schellenbach'
__copyright__ = 'Copyright 2010, Thierry Schellenbach'
__credits__ = ['Thierry Schellenbach, mellowmorning.com, @tschellenbach']
__license__ = 'BSD'
__version__ = '2.3.2'
__maintainer__ = 'Thierry Schellenbach'
__email__ = 'thierryschellenbach@gmail.com'
__status__ = 'Production'
... | __author__ = 'Thierry Schellenbach'
__copyright__ = 'Copyright 2010, Thierry Schellenbach'
__credits__ = ['Thierry Schellenbach, mellowmorning.com, @tschellenbach']
__license__ = 'BSD'
__version__ = '2.3.2'
__maintainer__ = 'Thierry Schellenbach'
__email__ = 'thierryschellenbach@gmail.com'
__status__ = 'Production'
'\n... |
# Embedded file name: D:\Users\Akiva\Competition\cyber-pirates\admin-tools\simulator\bots\python\Demo3.py
""" Demo 3 sends two pirates to go get islands """
pirates = [0, 1]
islands = [3, 2]
def do_turn(game):
global islands
global pirates
if len(game.not_my_islands()) < 2:
return
for index, p ... | """ Demo 3 sends two pirates to go get islands """
pirates = [0, 1]
islands = [3, 2]
def do_turn(game):
global islands
global pirates
if len(game.not_my_islands()) < 2:
return
for (index, p) in enumerate(pirates):
if game.get_my_pirate(p).is_lost:
newp = [pir.id for pir in g... |
valid = set('+-* |')
def countMines(x, y, board):
xmin, xmax = (max(0, x - 1), min(x + 2, len(board[y])))
ymin, ymax = (max(0, y - 1), min(y + 2, len(board)))
result = [c for r in board[ymin:ymax]
for c in r[xmin:xmax]
if c == '*']
return len(result) if len(result)... | valid = set('+-* |')
def count_mines(x, y, board):
(xmin, xmax) = (max(0, x - 1), min(x + 2, len(board[y])))
(ymin, ymax) = (max(0, y - 1), min(y + 2, len(board)))
result = [c for r in board[ymin:ymax] for c in r[xmin:xmax] if c == '*']
return len(result) if len(result) > 0 else ' '
def board(inp):
... |
# coding: utf-8
class DialogMessage(object):
def __init__(self, msg):
if type(msg) is not dict or 'type' not in msg or 'content' not in msg:
raise ValueError('Invalid message format: {}'.format(msg))
self.type = msg['type']
self.content = msg['content']
| class Dialogmessage(object):
def __init__(self, msg):
if type(msg) is not dict or 'type' not in msg or 'content' not in msg:
raise value_error('Invalid message format: {}'.format(msg))
self.type = msg['type']
self.content = msg['content'] |
"""
Project Euler Problem 7: 10,001st prime
"""
# What is the 10,001st prime number?
# NOTE: this solution implements the pseudocode explained in the posted solutions on projecteuler.net
# url: (https://projecteuler.net/overview=007)
def is_prime(n):
if ... | """
Project Euler Problem 7: 10,001st prime
"""
def is_prime(n):
if n == 1:
return False
elif n < 4:
return True
elif n % 2 == 0:
return False
elif n < 9:
return True
elif n % 3 == 0:
return False
else:
r = int(n ** (1 / 2))
f = 5
... |
class Solution:
def findTarget(self, root, k):
"""
:type root: TreeNode
:type k: int
:rtype: bool
"""
if not root:
return False
seen = set()
stack = [root]
for node in stack:
if k - node.val in seen:
retu... | class Solution:
def find_target(self, root, k):
"""
:type root: TreeNode
:type k: int
:rtype: bool
"""
if not root:
return False
seen = set()
stack = [root]
for node in stack:
if k - node.val in seen:
re... |
# Se desea eliminar todos los numeros duplicados de una lista o vector
# Por ejemplo si toma los valores [4,7,11,4,9,5,11,7,3,5]
# Ha de cambiarse a [4,7,11,9,5,3]
def eliminar(numArray: list) -> list:
largo = len(numArray)
unicos = list()
for i in range ((largo - 1), -1, -1):
if (numArray[i] not in ... | def eliminar(numArray: list) -> list:
largo = len(numArray)
unicos = list()
for i in range(largo - 1, -1, -1):
if numArray[i] not in unicos:
unicos.append(numArray[i])
else:
numArray.remove(numArray[i])
return numArray
if __name__ == '__main__':
numeros = [4, ... |
post = 'div._1poyrkZ7g36PawDueRza-J._11R7M_VOgKO1RJyRSRErT3 > div.STit0dLageRsa2yR4te_b > div > div._3JgI-GOrkmyIeDeyzXdyUD._2CSlKHjH7lsjx0IpjORx14 > div > a'
image_link = 'div > div._1NSbknF8ucHV2abfCZw2Z1 > div > a'
image_name = 'div.y8HYJ-y_lTUHkQIc1mdCq._2INHSNB8V5eaWp4P0rY_mE > div > h1'
| post = 'div._1poyrkZ7g36PawDueRza-J._11R7M_VOgKO1RJyRSRErT3 > div.STit0dLageRsa2yR4te_b > div > div._3JgI-GOrkmyIeDeyzXdyUD._2CSlKHjH7lsjx0IpjORx14 > div > a'
image_link = 'div > div._1NSbknF8ucHV2abfCZw2Z1 > div > a'
image_name = 'div.y8HYJ-y_lTUHkQIc1mdCq._2INHSNB8V5eaWp4P0rY_mE > div > h1' |
# In Windows, Control+Z is the typical keyboard shortcut to mean "end of file",
# in Linux and Unix it's typically Control+D.
try:
text=input('Enter something -->')
except EOFError:
print('Why did you do an EOF on me?')
except KeyboardInterrupt:
print('You cancelled the opration.')
else:
print('You en... | try:
text = input('Enter something -->')
except EOFError:
print('Why did you do an EOF on me?')
except KeyboardInterrupt:
print('You cancelled the opration.')
else:
print('You entered {}'.format(text)) |
"""
File: part1b.py
Created by Andrew Ingson (aings1@umbc.edu)
Date: 4/26/2020
CMSC 441 (Design and Analysis of Algorithms)
"""
# size is 312 bits (supposedly)
n = 6207034496804283879630919311406969504330524655944955079581115322595987746105035112739268374117
print("Modulus is", n)
| """
File: part1b.py
Created by Andrew Ingson (aings1@umbc.edu)
Date: 4/26/2020
CMSC 441 (Design and Analysis of Algorithms)
"""
n = 6207034496804283879630919311406969504330524655944955079581115322595987746105035112739268374117
print('Modulus is', n) |
INPUT = [
1036,
1897,
1256,
1080,
1909,
1817,
1759,
1883,
1088,
1841,
1780,
1907,
1874,
1831,
1932,
1999,
1989,
1840,
1973,
1102,
1906,
1277,
1089,
1275,
1228,
1917,
1075,
1060,
1964,
1942,
2001,
... | input = [1036, 1897, 1256, 1080, 1909, 1817, 1759, 1883, 1088, 1841, 1780, 1907, 1874, 1831, 1932, 1999, 1989, 1840, 1973, 1102, 1906, 1277, 1089, 1275, 1228, 1917, 1075, 1060, 1964, 1942, 2001, 1950, 1181, 1121, 1854, 1083, 1772, 1481, 1976, 1805, 1594, 1889, 1726, 1866, 798, 1739, 1709, 1946, 1948, 1808, 1836, 1849, ... |
__author__ = "jes3cu"
# Name: Jake Shankman
# CompID: jes3cu
# Date: 9/28/15
# Assignment: Lab 5
# Language: python3
if __name__ == "__main__":
print("1 + 1 = 2") | __author__ = 'jes3cu'
if __name__ == '__main__':
print('1 + 1 = 2') |
class GraphDataStructureException(Exception):
def __init__(self, message):
super().__init__(message)
class UninitializedGraph(GraphDataStructureException):
def __init__(self, message='Graph object is not initialized'):
super().__init__(message)
| class Graphdatastructureexception(Exception):
def __init__(self, message):
super().__init__(message)
class Uninitializedgraph(GraphDataStructureException):
def __init__(self, message='Graph object is not initialized'):
super().__init__(message) |
__version__ = '0.0'
__all__ = ['seed','inspect','cross','trans','reel','sieve','refine']
# sown the seed, inspect the crop,
# crossbreed to improve, transplant to adapt,
# reel them in, sieve for good, and refine for the best.
# ---- qharv maxim
| __version__ = '0.0'
__all__ = ['seed', 'inspect', 'cross', 'trans', 'reel', 'sieve', 'refine'] |
"""
Data storage class
TODO: Add ability to analyse bar type
"""
class OHLCData:
def __init__(self, open, high, low, close):
self.open = float(open)
self.high = float(high)
self.low = float(low)
self.close = float(close)
def linearize(self):
return self.open, self.hig... | """
Data storage class
TODO: Add ability to analyse bar type
"""
class Ohlcdata:
def __init__(self, open, high, low, close):
self.open = float(open)
self.high = float(high)
self.low = float(low)
self.close = float(close)
def linearize(self):
return (self.open, self.hi... |
def get_order_amount(order_string, price_list):
'''
This function returns the order amount, based on the items in the
order string, and the price of each item in the price list.
'''
# write your answer between #start and #end
#start
if len(order_string) == 0:
return 0
... | def get_order_amount(order_string, price_list):
"""
This function returns the order amount, based on the items in the
order string, and the price of each item in the price list.
"""
if len(order_string) == 0:
return 0
order_list_inconsistent = order_string.split(',')
order_list = [... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.