content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
print(f'Enter a number and I will let you know if it is an even or odd number')
a = int(input())
print(a)
while a != 0:
if a % 2 == 0:
print(f'The number {a} is an even number')
else:
print(f'The number {a} is an odd number')
print(f'please re-enter a new nonzero number or enter 0 if you wa... | print(f'Enter a number and I will let you know if it is an even or odd number')
a = int(input())
print(a)
while a != 0:
if a % 2 == 0:
print(f'The number {a} is an even number')
else:
print(f'The number {a} is an odd number')
print(f'please re-enter a new nonzero number or enter 0 if you wan... |
class Solution:
def checkRecord(self, n: int) -> int:
dp00 = dp01 = dp10 = 1
dp11 = dp02 = dp12 = 0
for i in range(n):
dp00, dp01, dp02 = (dp00 + dp01 + dp02) % (10 ** 9 + 7), dp00, dp01
dp10, dp11, dp12 = (dp00 + dp10 + dp11 + dp12) % (10 ** 9 + 7), dp10, dp11
... | class Solution:
def check_record(self, n: int) -> int:
dp00 = dp01 = dp10 = 1
dp11 = dp02 = dp12 = 0
for i in range(n):
(dp00, dp01, dp02) = ((dp00 + dp01 + dp02) % (10 ** 9 + 7), dp00, dp01)
(dp10, dp11, dp12) = ((dp00 + dp10 + dp11 + dp12) % (10 ** 9 + 7), dp10, dp... |
# -*- coding: utf-8 -*-
# Copyright 2015 Donne Martin. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "lice... | formatted_gitignores = u'\x1b[35m 1. \x1b[0mActionscript \x1b[0m\n\x1b[35m 2. \x1b[0mAda \x1b[0m\n\x1b[35m 3. \x1b[0mAgda \x1b[0m\n\x1b[35m 4. \x1b[0mAndroid \x1b[0m\n\x1b[35m 5. \x1b[0mAppEngine \x1b[0m\n\x1b[0m'
formatted_gitignores_tip = u' Run the following command to view or download a .gitignore f... |
input = """R1, L4, L5, L5, R2, R2, L1, L1, R2, L3, R4, R3, R2, L4, L2, R5, L1, R5, L5, L2, L3, L1, R1, R4, R5, L3, R2, L4, L5, R1, R2, L3, R3, L3, L1, L2, R5, R4, R5, L5, R1, L190, L3, L3, R3, R4, R47, L3, R5, R79, R5, R3, R1, L4, L3, L2, R194, L2, R1, L2, L2, R4, L5, L5, R1, R1, L1, L3, L2, R5, L3, L3, R4, R1, R5, L4,... | input = 'R1, L4, L5, L5, R2, R2, L1, L1, R2, L3, R4, R3, R2, L4, L2, R5, L1, R5, L5, L2, L3, L1, R1, R4, R5, L3, R2, L4, L5, R1, R2, L3, R3, L3, L1, L2, R5, R4, R5, L5, R1, L190, L3, L3, R3, R4, R47, L3, R5, R79, R5, R3, R1, L4, L3, L2, R194, L2, R1, L2, L2, R4, L5, L5, R1, R1, L1, L3, L2, R5, L3, L3, R4, R1, R5, L4, R... |
#AI.py
#Richard Greenbaum, Karson Daecher, Max Melamed
"""This module contains the AI components of the pentago bot"""
#Points for each board condition
CENTER_BONUS = 5
SEQUENCE2_WEAK = 2
SEQUENCE2_STRONG = 3
SEQUENCE3_WEAK = 10
SEQUENCE3_STRONG = 15
SEQUENCE4 = 20
CENTER_SPREAD1 = .05
CENTER_SPREAD2 = .025
MINVAL = ... | """This module contains the AI components of the pentago bot"""
center_bonus = 5
sequence2_weak = 2
sequence2_strong = 3
sequence3_weak = 10
sequence3_strong = 15
sequence4 = 20
center_spread1 = 0.05
center_spread2 = 0.025
minval = -9999999
maxval = 9999999
def evaluate(board):
"""Returns an float representing the... |
#formatter
class formatter:
def format(self, message, synonym):
return message.format(**synonym.getForFormatting()) | class Formatter:
def format(self, message, synonym):
return message.format(**synonym.getForFormatting()) |
class Solution:
def findContentChildren(self, g: 'List[int]', s: 'List[int]') -> 'int':
g.sort()
s.sort()
i = j = 0
while i < len(g) and j < len(s):
if s[j] >= g[i]:
i += 1
j += 1
return i
| class Solution:
def find_content_children(self, g: 'List[int]', s: 'List[int]') -> 'int':
g.sort()
s.sort()
i = j = 0
while i < len(g) and j < len(s):
if s[j] >= g[i]:
i += 1
j += 1
return i |
class Parcel:
pass
class DBParcelBuilder:
query_obj = None
class ImageDBModel:
name = None
description = None
image_url = None
thumb_url = None
dimensions = None
tags = None
class WebImageParcel(ImageDBModel):
source_id = None
source_url = None
width = None
height =... | class Parcel:
pass
class Dbparcelbuilder:
query_obj = None
class Imagedbmodel:
name = None
description = None
image_url = None
thumb_url = None
dimensions = None
tags = None
class Webimageparcel(ImageDBModel):
source_id = None
source_url = None
width = None
height = No... |
"""Write a HashTable class that stores strings
in a hash table, where keys are calculated
using the first two letters of the string."""
class HashTable(object):
def __init__(self):
self.table = [None]*10000
def store(self , string):
val = self.calculate_hash_value(string)
... | """Write a HashTable class that stores strings
in a hash table, where keys are calculated
using the first two letters of the string."""
class Hashtable(object):
def __init__(self):
self.table = [None] * 10000
def store(self, string):
val = self.calculate_hash_value(string)
if val != -... |
#!/usr/bin/env python3
challenge = '((((()(()(((((((()))(((()((((()())(())()(((()((((((()((()(()(((()(()((())))()((()()())))))))))()((((((())((()))(((((()(((((((((()()))((()(())()((())((()(()))((()))()))()(((((()(((()()))()())((()((((())()())()((((())()(()(()(((()(())(()(())(((((((())()()(((())(()(()(()(())))(()((((()... | challenge = '((((()(()(((((((()))(((()((((()())(())()(((()((((((()((()(()(((()(()((())))()((()()())))))))))()((((((())((()))(((((()(((((((((()()))((()(())()((())((()(()))((()))()))()(((((()(((()()))()())((()((((())()())()((((())()(()(()(((()(())(()(())(((((((())()()(((())(()(()(()(())))(()((((())((()))(((()(()()(((((()... |
# example of advantages by using super()
"""Changing of classes in process
"""
class X:
def m(self):
print('X.m')
class Y:
def m(self):
print('Y.m')
class C(X):
def m(self):
super().m() # in that position we cant hardcode name of class
class D(X):
def m(self):
... | """Changing of classes in process
"""
class X:
def m(self):
print('X.m')
class Y:
def m(self):
print('Y.m')
class C(X):
def m(self):
super().m()
class D(X):
def m(self):
D.__bases__[0].m(self)
'Usage of super() for class constructors\n'
class B:
def __init__... |
class Objective(object):
def __init__(self, hparams):
super(Objective, self).__init__()
self.hparams = hparams
def task_error(self, w, x, y):
raise NotImplementedError
def oracle(w, x, y):
raise NotImplementedError
| class Objective(object):
def __init__(self, hparams):
super(Objective, self).__init__()
self.hparams = hparams
def task_error(self, w, x, y):
raise NotImplementedError
def oracle(w, x, y):
raise NotImplementedError |
# -*- coding: utf-8 -*-
LUMIA_925 = {
'mode': 'RGBA',
'header_height': 232,
'footer_height': 116,
'additional_message_gap': 2,
'reply_message_gap': 7
}
| lumia_925 = {'mode': 'RGBA', 'header_height': 232, 'footer_height': 116, 'additional_message_gap': 2, 'reply_message_gap': 7} |
#proper way to create a class and object
class Parrot:
#define attributes
species = 'bird'
#instance_attribute
def __init__(self, name, age):
self.name = name
self.age = age
#instantiate the parrot class
blu = Parrot('Blu',10)
woo = Parrot('woo',15)
#access the class attributes
prin... | class Parrot:
species = 'bird'
def __init__(self, name, age):
self.name = name
self.age = age
blu = parrot('Blu', 10)
woo = parrot('woo', 15)
print('Blu is a {}'.format(blu.species))
print('woo is a {}'.format(woo.species))
print('{} is {} years old '.format(blu.name, blu.age))
print('{} is {} ... |
message = "hello python world!"
print(message)
message = "hello world!"
print(message)
| message = 'hello python world!'
print(message)
message = 'hello world!'
print(message) |
__title__ = "dj-rest-auth-social"
__description__ = "Authentication and Registration in Django Rest Framework."
__url__ = "https://github.com/robertwt7/dj-rest-auth-social"
__version__ = "2.2.4"
__author__ = "@robertwt7 https://github.com/robertwt7"
__author_email__ = "robert@sharkware.org"
__license__ = "MIT"
__copyri... | __title__ = 'dj-rest-auth-social'
__description__ = 'Authentication and Registration in Django Rest Framework.'
__url__ = 'https://github.com/robertwt7/dj-rest-auth-social'
__version__ = '2.2.4'
__author__ = '@robertwt7 https://github.com/robertwt7'
__author_email__ = 'robert@sharkware.org'
__license__ = 'MIT'
__copyri... |
def isInt(n):
return int(n) == float(n)
def bin_pow(num, p):
if p == 0:
return 1
if p % 2:
return num * bin_pow(num, p - 1)
else:
b = bin_pow(num, p // 2)
return b * b
num = float(input())
p = int(input())
ans = bin_pow(num, p)
print(ans) | def is_int(n):
return int(n) == float(n)
def bin_pow(num, p):
if p == 0:
return 1
if p % 2:
return num * bin_pow(num, p - 1)
else:
b = bin_pow(num, p // 2)
return b * b
num = float(input())
p = int(input())
ans = bin_pow(num, p)
print(ans) |
def revertNumber(n):
result = 0
while n != 0:
result = (result * 10) + (n % 10)
n = n // 10
else:
return result
def main():
n = int(input('Enter a integer number: '))
result = revertNumber(n)
print(result)
if __name__ == "__main__":
main() | def revert_number(n):
result = 0
while n != 0:
result = result * 10 + n % 10
n = n // 10
else:
return result
def main():
n = int(input('Enter a integer number: '))
result = revert_number(n)
print(result)
if __name__ == '__main__':
main() |
class BaseModel(object):
def __init__(self):
pass
def build_inputs(self):
raise NotImplementedError
def build_inference(self):
raise NotImplementedError
def build_loss(self):
raise NotImplementedError
def build_solver(self):
raise NotImplementedError
... | class Basemodel(object):
def __init__(self):
pass
def build_inputs(self):
raise NotImplementedError
def build_inference(self):
raise NotImplementedError
def build_loss(self):
raise NotImplementedError
def build_solver(self):
raise NotImplementedError
... |
pos = {
'I': 0.09,
'always': 0.07,
'like': 0.29,
'foreign': 0.04,
'films': 0.08
}
neg = {
'I': 0.16,
'always': 0.06,
'like': 0.06,
'foreign': 0.15,
'films': 0.11
}
prior_pos = 0.4
prior_neg = 0.6
sentence = 'I always like foreign films'
pos_pro = prior_pos
neg_pro = prior_neg... | pos = {'I': 0.09, 'always': 0.07, 'like': 0.29, 'foreign': 0.04, 'films': 0.08}
neg = {'I': 0.16, 'always': 0.06, 'like': 0.06, 'foreign': 0.15, 'films': 0.11}
prior_pos = 0.4
prior_neg = 0.6
sentence = 'I always like foreign films'
pos_pro = prior_pos
neg_pro = prior_neg
for word in sentence.split():
pos_pro *= po... |
# -*- coding: utf-8 -*-
class RequestException(RuntimeError):
"""There was an exception that occurred while handling the request."""
class Timeout(RequestException):
"""The request timed out."""
class URLRequired(RequestException):
"""A valid URL is required to make a request."""
class TooManyRedire... | class Requestexception(RuntimeError):
"""There was an exception that occurred while handling the request."""
class Timeout(RequestException):
"""The request timed out."""
class Urlrequired(RequestException):
"""A valid URL is required to make a request."""
class Toomanyredirects(RequestException):
""... |
#!/usr/bin/env python3
""" Node Class file """
class Node:
""" Node class """
def __init__(self, initdata, next=None):
self.data = initdata
self.next = next
def get_data(self):
""" Returns data """
return self.data
def get_next(self):
""" Gets next node """
... | """ Node Class file """
class Node:
""" Node class """
def __init__(self, initdata, next=None):
self.data = initdata
self.next = next
def get_data(self):
""" Returns data """
return self.data
def get_next(self):
""" Gets next node """
return self.next
... |
coordinator_a = int(input())
coordinator_b = int(input())
if 1 < coordinator_a < 8 and 1 < coordinator_b < 8:
print('8')
elif (coordinator_a == 1 and coordinator_b == 1) or (coordinator_a == 8 and coordinator_b == 8):
print('3')
elif (coordinator_a == 1 and coordinator_b == 8) or (coordinator_a == 8 and coordi... | coordinator_a = int(input())
coordinator_b = int(input())
if 1 < coordinator_a < 8 and 1 < coordinator_b < 8:
print('8')
elif coordinator_a == 1 and coordinator_b == 1 or (coordinator_a == 8 and coordinator_b == 8):
print('3')
elif coordinator_a == 1 and coordinator_b == 8 or (coordinator_a == 8 and coordinator... |
"""
Demonstrates global variables
"""
#Declares a variable named g_variable and assigns it
#the value "I'm a global variable"
g_variable = "I'm a global variable"
def main() :
#Prints the value of g_variable
print(g_variable)
#Calls the localtest function
localtest()
#Attempts to print the value of the ... | """
Demonstrates global variables
"""
g_variable = "I'm a global variable"
def main():
print(g_variable)
localtest()
print(local_var)
def localtest():
print('In local_test function')
print(g_variable)
local_var = "I'm a local variable"
print(local_var)
main() |
double = "She said, \"that's a greate tasting apple!\""
print (double)
single = 'she said, "that\'s a great tasting apple!"'
print (single)
print (' i ' + 'eat ' + 'you') #concatenation
first = "I"
second = "EAT"
third = "python"
sentence = first + ' ' + second +' ' + third
print(sentence)
print ('-' * 50) # ha... | double = 'She said, "that\'s a greate tasting apple!"'
print(double)
single = 'she said, "that\'s a great tasting apple!"'
print(single)
print(' i ' + 'eat ' + 'you')
first = 'I'
second = 'EAT'
third = 'python'
sentence = first + ' ' + second + ' ' + third
print(sentence)
print('-' * 50)
happines = 'happy ' * 3
print(h... |
file_read = open("input.txt", "r")
line = file_read.readline()
freq = 0
while line:
number = int(line[1:])
if line[0] == '-':
freq -= int(number)
else:
freq += int(number)
line = file_read.readline()
print(f'Current freq = {freq}')
| file_read = open('input.txt', 'r')
line = file_read.readline()
freq = 0
while line:
number = int(line[1:])
if line[0] == '-':
freq -= int(number)
else:
freq += int(number)
line = file_read.readline()
print(f'Current freq = {freq}') |
def part1(image):
return image
def part2(lines):
return 0
if __name__ == '__main__':
with open('input.txt', 'r') as f:
image = f.read().splitlines()
print(part1(image))
print(part2(image))
| def part1(image):
return image
def part2(lines):
return 0
if __name__ == '__main__':
with open('input.txt', 'r') as f:
image = f.read().splitlines()
print(part1(image))
print(part2(image)) |
code = "set"
answer = ""
for index in range(1, 3):
answer = answer + code[index] + "ab"
print(answer)
| code = 'set'
answer = ''
for index in range(1, 3):
answer = answer + code[index] + 'ab'
print(answer) |
text = input()
arr = text.split()
last_list =[]
for i in range(0,len(arr)):
if (i%2 ==0):
last_list.append(arr[i])
print(*last_list)
| text = input()
arr = text.split()
last_list = []
for i in range(0, len(arr)):
if i % 2 == 0:
last_list.append(arr[i])
print(*last_list) |
class Spaceship:
SPACESHIP_FULL = "Spaceship is full"
ASTRONAUT_EXISTS = "Astronaut {} Exists"
ASTRONAUT_NOT_FOUND = "Astronaut Not Found"
ASTRONAUT_ADD = "Added astronaut {}"
ASTRONAUT_REMOVED = "Removed {}"
ZERO_CAPACITY = 0
def __init__(self, name: str, capacity: int):
self.name ... | class Spaceship:
spaceship_full = 'Spaceship is full'
astronaut_exists = 'Astronaut {} Exists'
astronaut_not_found = 'Astronaut Not Found'
astronaut_add = 'Added astronaut {}'
astronaut_removed = 'Removed {}'
zero_capacity = 0
def __init__(self, name: str, capacity: int):
self.name ... |
class InvalidEnvelopeError(Exception):
"""Input envelope is not callable and instance of BaseEnvelope"""
class InvalidModelTypeError(Exception):
"""Input data model does not implement BaseModel"""
| class Invalidenvelopeerror(Exception):
"""Input envelope is not callable and instance of BaseEnvelope"""
class Invalidmodeltypeerror(Exception):
"""Input data model does not implement BaseModel""" |
first_value = ' FIRST challenge '
second_value = '- second challenge -'
third_value = 'tH IR D-C HALLE NGE'
fourth_value = 'fourth'
fifth_value = 'fifth'
sixth_value = 'sixth'
# First challenge
first_value = ' ' + (first_value.strip()).title()
# Second challenge
second_value = ((second_value.replace... | first_value = ' FIRST challenge '
second_value = '- second challenge -'
third_value = 'tH IR D-C HALLE NGE'
fourth_value = 'fourth'
fifth_value = 'fifth'
sixth_value = 'sixth'
first_value = ' ' + first_value.strip().title()
second_value = second_value.replace('-', ' ').strip().capitalize()
third_value ... |
# --- Day 15: Rambunctious Recitation ---
# You catch the airport shuttle and try to book a new flight to your vacation island. Due to the storm, all direct flights have been cancelled, but a route is available to get around the storm. You take it.
#
# While you wait for your flight, you decide to check in with the Elv... | data = {18: [1], 8: [2], 0: [3], 5: [4], 4: [5], 1: [6], 20: [7]}
spoken = 20
for turn in range(8, 30000001):
if len(data[spoken]) < 2:
spoken = 0
if 0 not in data:
data[0] = [turn]
else:
data[0].append(turn)
else:
spoken = data[spoken][-1] - data[spoken][... |
def jwt_response_payload_handler(token, user, request):
return {
"token": token,
"user": str(user.username),
"active": user.is_active
}
| def jwt_response_payload_handler(token, user, request):
return {'token': token, 'user': str(user.username), 'active': user.is_active} |
# Exemplary development configuration for a public site
SECRET_KEY = b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
SESSION_COOKIE_SECURE = True
SQLALCHEMY_DATABASE_URI = 'postgresql+psycopg2://byceps:boioioing@127.0.0.1/byceps'
REDIS_URL = 'redis://127.0.0.1:6379... | secret_key = b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
session_cookie_secure = True
sqlalchemy_database_uri = 'postgresql+psycopg2://byceps:boioioing@127.0.0.1/byceps'
redis_url = 'redis://127.0.0.1:6379/0'
app_mode = 'site'
site_id = 'example-site'
mail_debug =... |
"""\
wxChoice widget configuration
@copyright: 2016 Carsten Grohmann
@license: MIT (see LICENSE.txt) - THIS PROGRAM COMES WITH NO WARRANTY
"""
config = {
'wxklass': 'wxChoice',
'style_defs': {
'wxCB_SORT': {
'desc': _('Sorts the entries alphabetically.'),
'supported_by': ('wx3'... | """wxChoice widget configuration
@copyright: 2016 Carsten Grohmann
@license: MIT (see LICENSE.txt) - THIS PROGRAM COMES WITH NO WARRANTY
"""
config = {'wxklass': 'wxChoice', 'style_defs': {'wxCB_SORT': {'desc': _('Sorts the entries alphabetically.'), 'supported_by': ('wx3',)}}, 'style_list': ['wxCB_SORT'], 'events': {... |
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# The MIT License (MIT)
#
# Copyright (c) 2015 Bartosz Janda
#
# 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 w... | nsjson_reading_mutable_containers = 0
nsjson_reading_mutable_leaves = 1
nsjson_reading_allow_fragments = 4
nsjson_writing_pretty_printed = 1
def get_json_reading_options_text(value):
"""
Returns NSJSONSerialization reading option.
:param int value: NSJSONReadingOptions
:return: NSJSONSerialization rea... |
fname = input("Enter file name: ")
ff=open(fname)
for line in ff:
line=line.rstrip()
print(line.upper())
| fname = input('Enter file name: ')
ff = open(fname)
for line in ff:
line = line.rstrip()
print(line.upper()) |
class Solution:
def rob(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
s = Solution()
print(s.rob([1, 2, 3, 1])) # 4
print(s.rob([2, 7, 9, 3, 1])) # 12
| class Solution:
def rob(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
s = solution()
print(s.rob([1, 2, 3, 1]))
print(s.rob([2, 7, 9, 3, 1])) |
print ('hello world')
print("Hello, CS1301")
print("This is line 1")
print("This is line 2")
print("This is line 3")
print("This is line 4")
#pritn("This is line 5")
#Line 9 will not run, as there is a function error. "pritn does not exist"
#General errors in Python begin with "Traceback"
#File "/Users/jstorey/github/... | print('hello world')
print('Hello, CS1301')
print('This is line 1')
print('This is line 2')
print('This is line 3')
print('This is line 4') |
load("@rules_jvm_external//:defs.bzl", "artifact")
load("//java/private:library.bzl", "java_test")
load("//java/private:package.bzl", "get_package_name")
"""Dependencies typically required by JUnit 5 tests.
See `java_junit5_test` for more details.
"""
JUNIT5_DEPS = [
artifact("org.junit.jupiter:junit-jupiter-engi... | load('@rules_jvm_external//:defs.bzl', 'artifact')
load('//java/private:library.bzl', 'java_test')
load('//java/private:package.bzl', 'get_package_name')
'Dependencies typically required by JUnit 5 tests.\n\nSee `java_junit5_test` for more details.\n'
junit5_deps = [artifact('org.junit.jupiter:junit-jupiter-engine'), a... |
class Solution:
def maxSubArray(self, nums):
for q in range(1, len(nums)):
if nums[q - 1] > 0:
nums[q] += nums[q - 1]
return max(nums) | class Solution:
def max_sub_array(self, nums):
for q in range(1, len(nums)):
if nums[q - 1] > 0:
nums[q] += nums[q - 1]
return max(nums) |
"""
Provides functions to support (optionally) passing the MyPy configuration file
to this integration.
"""
def _create_config_impl(ctx):
if ctx.attr.config_filepath:
user_mypy_config_contents = ctx.read(ctx.attr.config_filepath)
else:
user_mypy_config_contents = "[mypy]"
ctx.file(
... | """
Provides functions to support (optionally) passing the MyPy configuration file
to this integration.
"""
def _create_config_impl(ctx):
if ctx.attr.config_filepath:
user_mypy_config_contents = ctx.read(ctx.attr.config_filepath)
else:
user_mypy_config_contents = '[mypy]'
ctx.file('mypy.ini... |
# This helps pylint find all subcommands.
__all__ = ["aws_batch_init", "aws_batch_submit", "init", \
"import_uhgg", "annotate_genome", "build_pangenome", \
"infer_markers", "build_markerdb", "generate_dbmisc", \
"midas_run_species", "midas_run_genes", "midas_run_snps", \
... | __all__ = ['aws_batch_init', 'aws_batch_submit', 'init', 'import_uhgg', 'annotate_genome', 'build_pangenome', 'infer_markers', 'build_markerdb', 'generate_dbmisc', 'midas_run_species', 'midas_run_genes', 'midas_run_snps', 'midas_merge_species', 'midas_merge_snps', 'midas_merge_genes', 'build_bowtie2_indexes', 'download... |
somadorA = 0
somadorB = 0
somadorC = 0
somadorD = 0
desnivel_A = 0
desnivel_B = 0
desnivel_C = 0
desnivel_D = 0
linhas, colunas = [int(z) for z in input().split()]
matriz = []
for z in range(linhas):
linha = [int(x) for x in input().split()]
matriz.append(linha)
lin, col = [int(z) for z in input().split()]
to... | somador_a = 0
somador_b = 0
somador_c = 0
somador_d = 0
desnivel_a = 0
desnivel_b = 0
desnivel_c = 0
desnivel_d = 0
(linhas, colunas) = [int(z) for z in input().split()]
matriz = []
for z in range(linhas):
linha = [int(x) for x in input().split()]
matriz.append(linha)
(lin, col) = [int(z) for z in input().split... |
for x in range(16):
with open(f'..\\data\\cpu\\functions\\opcode_switch\\opcode_fx33\\opcode_fx33_{x}.mcfunction', 'w') as f:
f.write(f'scoreboard players operation Global memory_value = Global V{hex(x)[2:].upper()}\n'
'scoreboard players operation Global copy_1 = Global memory_value... | for x in range(16):
with open(f'..\\data\\cpu\\functions\\opcode_switch\\opcode_fx33\\opcode_fx33_{x}.mcfunction', 'w') as f:
f.write(f'scoreboard players operation Global memory_value = Global V{hex(x)[2:].upper()}\nscoreboard players operation Global copy_1 = Global memory_value\nscoreboard players operat... |
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(S):
# write your code in Python 3.6
if len(S) == 0:
return 1
stack = []
for c in S:
if c == '(':
stack.append(c)
elif c == ')':
if len(stack) == 0:
... | def solution(S):
if len(S) == 0:
return 1
stack = []
for c in S:
if c == '(':
stack.append(c)
elif c == ')':
if len(stack) == 0:
return 0
last_char = stack[-1]
if last_char == '(':
stack.pop()
return ... |
# Kenny Sprite Sheet Slicer
# Error.py
# Copyright Will Blankenship 2015
class Error(Exception):
def __init__(self, message):
self.message = message
| class Error(Exception):
def __init__(self, message):
self.message = message |
# Golden Nimbus Cloud Mount Permanent Coupon (2435372)
mount = 80011350
if sm.hasSkill(mount):
sm.chat("You already have the 'Golden Nimbus Cloud' mount.")
else:
sm.consumeItem()
sm.giveSkill(mount)
sm.chat("Successfully added the 'Golden Nimbus Cloud' mount.")
| mount = 80011350
if sm.hasSkill(mount):
sm.chat("You already have the 'Golden Nimbus Cloud' mount.")
else:
sm.consumeItem()
sm.giveSkill(mount)
sm.chat("Successfully added the 'Golden Nimbus Cloud' mount.") |
# https://www.codewars.com/kata/530e15517bc88ac656000716/train/python
def rot13(message):
string = []
for letter in message:
if(ord(letter) <= 122 and ord(letter) >= 65):
letter = ord(letter) + 13
if(letter >= 110 and letter > 122 or letter < 110 and letter > 90):
... | def rot13(message):
string = []
for letter in message:
if ord(letter) <= 122 and ord(letter) >= 65:
letter = ord(letter) + 13
if letter >= 110 and letter > 122 or (letter < 110 and letter > 90):
letter -= 26
string.append(chr(letter))
else:
... |
# Copyright 2019 The Jetstack cert-manager contributors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable l... | load('@io_k8s_repo_infra//defs:go.bzl', 'go_genrule')
def generated_crds(name, go_prefix, paths, out, visibility=[], deps=[]):
go_genrule(name=name, tools=['@io_k8s_sigs_controller_tools//cmd/controller-gen', '@go_sdk//:bin/go'], cmd=' '.join(['go=$$(pwd)/$(location @go_sdk//:bin/go);', 'export PATH=$$(dirname "$$... |
# easy O(n) time and O(n?) space solution
def solve(seq, stop):
mem = {seq[i]: i+1 for i in range(len(seq)-1)}
i = len(seq)
cur = seq[-1]
while i < stop:
next_cur = 0
if cur in mem:
next_cur = i - mem[cur]
mem[cur] = i
cur = next_cur
i += 1
return cur
if __name__ == '__main_... | def solve(seq, stop):
mem = {seq[i]: i + 1 for i in range(len(seq) - 1)}
i = len(seq)
cur = seq[-1]
while i < stop:
next_cur = 0
if cur in mem:
next_cur = i - mem[cur]
mem[cur] = i
cur = next_cur
i += 1
return cur
if __name__ == '__main__':
seq... |
def printMenu():
print("************************************")
print("**EDTODO****************************")
print("************************************")
print("Seleccione una opcion")
print("* 1. Agregar tarea")
print("* 2. Editar tarea")
print("* 3. Marcar como hecha")
print("* 4 Borrar tarea... | def print_menu():
print('************************************')
print('**EDTODO****************************')
print('************************************')
print('Seleccione una opcion')
print('* 1. Agregar tarea')
print('* 2. Editar tarea')
print('* 3. Marcar como hecha')
print('* 4 Bor... |
class Solution:
def superPow(self, a: int, b: List[int]) -> int:
res = 1
for x in b:
res = self.pow(res, 10) * self.pow(a, x) % 1337
return res
def pow(self, a, b):
if b == 0 or a == 1: return 1
if b % 2:
return a * self.pow(a, b - 1) % 1337
... | class Solution:
def super_pow(self, a: int, b: List[int]) -> int:
res = 1
for x in b:
res = self.pow(res, 10) * self.pow(a, x) % 1337
return res
def pow(self, a, b):
if b == 0 or a == 1:
return 1
if b % 2:
return a * self.pow(a, b - 1... |
"""
File: boggle.py
Name: Allen Lee
----------------------------------------
TODO:
"""
# This is the file name of the dictionary txt file
# we will be checking if a word exists by searching through it
FILE = 'dictionary.txt'
# Global variables
dictionary = {}
def main():
"""
TODO:
"""
read_dictionary()
num = ... | """
File: boggle.py
Name: Allen Lee
----------------------------------------
TODO:
"""
file = 'dictionary.txt'
dictionary = {}
def main():
"""
TODO:
"""
read_dictionary()
num = 0
letter_lst = []
ans_lst = []
ans = ''
ch_index_lst = []
current_index = ()
while True:
num += ... |
class Solution:
def shortestCompletingWord(self, licensePlate: str, words: List[str]) -> str:
l=list(re.sub(r'\s|[0-9]+', '', licensePlate).lower())
#print(l)
words=sorted(words, key=len)
for i in words:
i_l=list(i)
#print(i_l)
for k in l:
... | class Solution:
def shortest_completing_word(self, licensePlate: str, words: List[str]) -> str:
l = list(re.sub('\\s|[0-9]+', '', licensePlate).lower())
words = sorted(words, key=len)
for i in words:
i_l = list(i)
for k in l:
flag = 1
... |
TEST_ENTRY_MUTATION = '''
mutation {
createEntry(content: "this is a test entry") {
id
content
postedBy {
username
}
}
}
'''
TEST_DELETE_MUTATION = lambda id: '''
mutation {
deleteEntry(id: %d) {
id
... | test_entry_mutation = '\n mutation {\n createEntry(content: "this is a test entry") {\n id\n content\n postedBy {\n username\n }\n }\n }\n'
test_delete_mutation = lambda id: '\n mutation {\n deleteEntry(id: %d) {\n id\n ... |
'''
set_paramters.py : set gp_dla_detection default parameters for cddf module
'''
# physical constants
lya_wavelength = 1215.6701
lyb_wavelength = 1025.7223
lyman_limit = 911.7633
speed_of_light = 299792458
# oscillator strengths
lya_oscillator_strength = 0.416400
lyb_oscillator_strength = 0.079120
# all transit... | """
set_paramters.py : set gp_dla_detection default parameters for cddf module
"""
lya_wavelength = 1215.6701
lyb_wavelength = 1025.7223
lyman_limit = 911.7633
speed_of_light = 299792458
lya_oscillator_strength = 0.4164
lyb_oscillator_strength = 0.07912
all_transition_wavelengths = [1.2156701e-05, 1.0257223e-05, 9.7253... |
#
# PySNMP MIB module DELL-NETWORKING-TRAP-EVENT-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/DELL-NETWORKING-TRAP-EVENT-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 18:22:47 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python ... | (integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, value_size_constraint, constraints_union, value_range_constraint, constraints_intersection) ... |
print("NOTE: NumberCrunch is not a random number generator.")
print("NumberCrunch")
while 0 == 0:
number = input("Enter in a number to crunch: ")
print("Crunching...")
number = int(number)
number2 = (((number * number) * 2) - number + (number * 2)) * number * (number * number) - (number * number - numbe... | print('NOTE: NumberCrunch is not a random number generator.')
print('NumberCrunch')
while 0 == 0:
number = input('Enter in a number to crunch: ')
print('Crunching...')
number = int(number)
number2 = (number * number * 2 - number + number * 2) * number * (number * number) - (number * number - number * (n... |
# prompt
word_one = input("Word 1: ")
word_two = input("Word 2: ")
# response
print("{0}{1}".format(word_one, word_two) * 4)
| word_one = input('Word 1: ')
word_two = input('Word 2: ')
print('{0}{1}'.format(word_one, word_two) * 4) |
#
# PySNMP MIB module HPN-ICF-MPLS-BGP-VPN-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HPN-ICF-MPLS-BGP-VPN-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 19:28:07 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.... | (object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constraint, value_size_constraint, constraints_intersection, single_value_constraint, constraints_union) ... |
"""The WaveBlocks Project
This file contains some ready made potentials with up to five
separate energy levels. This is a pure data file without any
code. To load the potentials, use the ``PotentialFactory``.
@author: R. Bourquin
@copyright: Copyright (C) 2010, 2011 R. Bourquin
@license: Modified BSD License
"""
# P... | """The WaveBlocks Project
This file contains some ready made potentials with up to five
separate energy levels. This is a pure data file without any
code. To load the potentials, use the ``PotentialFactory``.
@author: R. Bourquin
@copyright: Copyright (C) 2010, 2011 R. Bourquin
@license: Modified BSD License
"""
free... |
# problem 17
# Project Euler
__author__ = 'Libao Jin'
__date__ = 'July 14, 2015'
def oneDigitTransform(number):
if number == 1:
numberInString = 'one'
elif number == 2:
numberInString = 'two'
elif number == 3:
numberInString = 'three'
elif number == 4:
numberInString = 'four'
elif number == 5:
numberIn... | __author__ = 'Libao Jin'
__date__ = 'July 14, 2015'
def one_digit_transform(number):
if number == 1:
number_in_string = 'one'
elif number == 2:
number_in_string = 'two'
elif number == 3:
number_in_string = 'three'
elif number == 4:
number_in_string = 'four'
elif numb... |
string = input()
set = set()
for i in string:
set.add(i)
ll = [x for x in set]
for j in sorted(ll):
print(f'{j}: {string.count(j)} time/s') | string = input()
set = set()
for i in string:
set.add(i)
ll = [x for x in set]
for j in sorted(ll):
print(f'{j}: {string.count(j)} time/s') |
src = Split('''
service_manager.c
''')
component = aos_component('alink', src)
dependencis = Split('''
framework/connectivity/wsf
utility/digest_algorithm
utility/cjson
utility/base64
utility/hashtable
utility/log
kernel/yloop
kernel/modules/fs/kv
framewo... | src = split('\n service_manager.c\n')
component = aos_component('alink', src)
dependencis = split('\n framework/connectivity/wsf \n utility/digest_algorithm \n utility/cjson \n utility/base64 \n utility/hashtable \n utility/log \n kernel/yloop \n kernel/modules/fs/kv \n framework/cloud \n ... |
"""
Example: Given a smaller string s and a bigger string b,
design an algorithm to find all permutations of the shorter
string within the longer one. Print the location of each permutation.
"""
""" constraints
len(s) < len(b)
"""
"string abbacabbaabbabaabaaabaaabbaababaaabaa"
"substr abba"
"sorted(string[i:len(a... | """
Example: Given a smaller string s and a bigger string b,
design an algorithm to find all permutations of the shorter
string within the longer one. Print the location of each permutation.
"""
' constraints\nlen(s) < len(b)\n'
'string abbacabbaabbabaabaaabaaabbaababaaabaa'
'substr abba'
'sorted(string[i:len(abba))... |
# -*- coding: utf-8 -*-
class Singleton(object):
def __new__(type):
if not '_the_instance' in type.__dict__:
type._the_instance = object.__new__(type)
return type._the_instance
if __name__ == "__main__":
a = Singleton()
a.hw = 'hello world'
b = Singleton()
print(b.hw)... | class Singleton(object):
def __new__(type):
if not '_the_instance' in type.__dict__:
type._the_instance = object.__new__(type)
return type._the_instance
if __name__ == '__main__':
a = singleton()
a.hw = 'hello world'
b = singleton()
print(b.hw)
print(hex(id(a)))
... |
__AUTHOR__="Goichi (Iisaka) Yukawa"
__VERSION__="0.2.3"
__LICENSE__="MIT"
__MYPROG__="sphinx-express"
| __author__ = 'Goichi (Iisaka) Yukawa'
__version__ = '0.2.3'
__license__ = 'MIT'
__myprog__ = 'sphinx-express' |
"""The code template to supply to the front end. This is what the user will
be asked to complete and submit for grading.
Do not include any imports.
This is not a REPL environment so include explicit 'print' statements
for any outputs you want to be displayed back to the user.
Use triple single q... | """The code template to supply to the front end. This is what the user will
be asked to complete and submit for grading.
Do not include any imports.
This is not a REPL environment so include explicit 'print' statements
for any outputs you want to be displayed back to the user.
Use triple single q... |
# 6. Write a program that takes a user input string and outputs every second word.
n = str(input("Please enter a sentence: "))
print (n.split()[0])
print (n.split()[2])
print (n.split()[4])
print (n.split()[6])
| n = str(input('Please enter a sentence: '))
print(n.split()[0])
print(n.split()[2])
print(n.split()[4])
print(n.split()[6]) |
# When you become mighty at math, you'll find it a lot less stressful!
# might + math = happy
for ia in range(1, 10):
for ib in range(0, 10):
for ic in range(0, 10):
for id in range(1, 10):
for ie in range(0, 10):
for ig in range(0, 10):
... | for ia in range(1, 10):
for ib in range(0, 10):
for ic in range(0, 10):
for id in range(1, 10):
for ie in range(0, 10):
for ig in range(0, 10):
for ih in range(0, 10):
for ii in range(0, 10):
... |
# -*- coding: utf-8 -*-
"""
Created on Wed May 22 22:46:51 2019
@author: Sagar
"""
text = "%%$@_$^__#)^)&!_+]!*@&^}@[@%]()%+$&[(_@%+%$*^@$^!+]!&_#)_*}{}}!}_]$[%}@[{_@#_^{*@##&{#&{&)*%(]{{([*}@[@&]+!!*{)!}{%+{))])[!^})+)$]#{*+^((@^@}$[**$&^{$!@#$%)!@(&+^!{%_$&@^!}$_${)$_#)!({@!)(^}!*^&!$%_&&}&_#&@{)]{+)%*{&*%*&@%$+]!*... | """
Created on Wed May 22 22:46:51 2019
@author: Sagar
"""
text = '%%$@_$^__#)^)&!_+]!*@&^}@[@%]()%+$&[(_@%+%$*^@$^!+]!&_#)_*}{}}!}_]$[%}@[{_@#_^{*@##&{#&{&)*%(]{{([*}@[@&]+!!*{)!}{%+{))])[!^})+)$]#{*+^((@^@}$[**$&^{$!@#$%)!@(&+^!{%_$&@^!}$_${)$_#)!({@!)(^}!*^&!$%_&&}&_#&@{)]{+)%*{&*%*&@%$+]!*__(#!*){%&@++!_)^$&&%#+)}... |
n = int(input("Enter a number: "))
s = ""
for i in range(n):
if (i + 1) % 3 == 0 and (i + 1) % 5 == 0:
s = "FizzBuzz"
elif (i + 1) % 3 == 0:
s = "Fizz"
elif (i + 1) % 5 ==0:
s = "Buzz"
else:
s = i + 1
print(s)
i += 1
| n = int(input('Enter a number: '))
s = ''
for i in range(n):
if (i + 1) % 3 == 0 and (i + 1) % 5 == 0:
s = 'FizzBuzz'
elif (i + 1) % 3 == 0:
s = 'Fizz'
elif (i + 1) % 5 == 0:
s = 'Buzz'
else:
s = i + 1
print(s)
i += 1 |
"""
Singly Linked List data structure implemented:
--------------------------------
add : add element to list
remove : remove element from list
search : search for value in list
size : return size of list
Time Complexity: O(N)
"""
class Node:
def __init__(self, data=None, next=None):
... | """
Singly Linked List data structure implemented:
--------------------------------
add : add element to list
remove : remove element from list
search : search for value in list
size : return size of list
Time Complexity: O(N)
"""
class Node:
def __init__(self, data=None, next=None):
... |
#percent error wrt to first argument with default accuracy of 2 decimal places
def err_percent(baseline, final, acc = 2):
reduction = round(((final - baseline)/ baseline) * 100, acc)
print('Error percentage change : {} %'.format(reduction))
| def err_percent(baseline, final, acc=2):
reduction = round((final - baseline) / baseline * 100, acc)
print('Error percentage change : {} %'.format(reduction)) |
letters = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]
points = [1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 4, 1, 3, 10, 1, 1, 1, 1, 4, 4, 8, 4, 10]
letters += [letter.lower()
for letter in letters]
points *= 2
letter_to_points = {key:va... | letters = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
points = [1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 4, 1, 3, 10, 1, 1, 1, 1, 4, 4, 8, 4, 10]
letters += [letter.lower() for letter in letters]
points *= 2
letter_to_points = {key: va... |
def validate_users(users):
if len(users)>=3:
print(users + " is valid")
else:
print(users + " is invalid")
validate_users("purplecat")
| def validate_users(users):
if len(users) >= 3:
print(users + ' is valid')
else:
print(users + ' is invalid')
validate_users('purplecat') |
# functions of list in python
myCourses = ["Python", "Kotlin", "Java", "JavaScript"]
myCourses2 = ["VueJs", "JQuary"]
print(myCourses)
print("----------------------")
myCourses.append("Blander")
print(myCourses)
print(len(myCourses))
myCourses.append(myCourses2)
print(myCourses)
print(len(myCour... | my_courses = ['Python', 'Kotlin', 'Java', 'JavaScript']
my_courses2 = ['VueJs', 'JQuary']
print(myCourses)
print('----------------------')
myCourses.append('Blander')
print(myCourses)
print(len(myCourses))
myCourses.append(myCourses2)
print(myCourses)
print(len(myCourses))
myCourses.extend(['Asp.net', 'C#'])
print(myCo... |
def main():
zeros = 0
negatives = 0
positives = 0
for step in range(10):
number = float(input(f"Number {step + 1}: "))
if number > 0:
positives += 1
elif number < 0:
negatives += 1
else:
zeros += 1
print(f"Number of zeros: {zeros}")... | def main():
zeros = 0
negatives = 0
positives = 0
for step in range(10):
number = float(input(f'Number {step + 1}: '))
if number > 0:
positives += 1
elif number < 0:
negatives += 1
else:
zeros += 1
print(f'Number of zeros: {zeros}')... |
N,M = map(int, input().split())
connect = [[0,0,0]]
on_off = [0]*(N+1)
result = 0
for _ in range(M):
k = list(map(int, input().split()))
connect.append(k[1:])
p = list(map(int, input().split()))
for cnt in range(0,2**N):
bin_str = list(format(cnt, 'b'))
i = len(on_off)-len(bin_str)
for ... | (n, m) = map(int, input().split())
connect = [[0, 0, 0]]
on_off = [0] * (N + 1)
result = 0
for _ in range(M):
k = list(map(int, input().split()))
connect.append(k[1:])
p = list(map(int, input().split()))
for cnt in range(0, 2 ** N):
bin_str = list(format(cnt, 'b'))
i = len(on_off) - len(bin_str)
for... |
class Foo(object):
def no_arg(self):
pass
def one_arg(arg):
return arg
| class Foo(object):
def no_arg(self):
pass
def one_arg(arg):
return arg |
# -*- coding: utf-8 -*-
__version__ = '{{cookiecutter.project_version}}'
__description__ = '{{cookiecutter.project_description}}.'
__author__ = 'rgb-24bit'
__author_email__ = 'rgb-24bit@foxmail.com'
__license__ = '{{cookiecutter.license}}'
__copyright__ = 'Copyright 2019 rgb-24bit'
| __version__ = '{{cookiecutter.project_version}}'
__description__ = '{{cookiecutter.project_description}}.'
__author__ = 'rgb-24bit'
__author_email__ = 'rgb-24bit@foxmail.com'
__license__ = '{{cookiecutter.license}}'
__copyright__ = 'Copyright 2019 rgb-24bit' |
a = [1, 2, 5]
b = [
[1, 2, 3],
[4, 5, 6],
[7, 8, 9],
]
c = {
"firstname": "John",
"lastname": "Doe",
"age": 42,
"children": [
{
"name": "Sara",
"age": 4,
},
],
}
print(a[1])
print(b[0][1])
print(c["firstname"], c["lastname"])
ch = c["children"][... | a = [1, 2, 5]
b = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
c = {'firstname': 'John', 'lastname': 'Doe', 'age': 42, 'children': [{'name': 'Sara', 'age': 4}]}
print(a[1])
print(b[0][1])
print(c['firstname'], c['lastname'])
ch = c['children'][0]
print(ch['name'], ch['age']) |
#!/usr/bin/env python3
_v4_len = 32
_v6_len = 128
def eng_exponent(n):
return len(("{:,d}".format(n)).split(",")) - 1
def num_addresses(prefix_length, address_length):
return 2 ** (address_length - prefix_length)
if __name__ == "__main__":
prefix = int(input("Network prefix length: "), 10)
network =... | _v4_len = 32
_v6_len = 128
def eng_exponent(n):
return len('{:,d}'.format(n).split(',')) - 1
def num_addresses(prefix_length, address_length):
return 2 ** (address_length - prefix_length)
if __name__ == '__main__':
prefix = int(input('Network prefix length: '), 10)
network = input('IP version (4 or 6)... |
n = input()
arr = list(map(int, input().split()))
def podziel(arr, start, end):
pivot = arr[end]
low = start
high = end - 1
while True:
while low <= high and arr[low] <= pivot:
low += 1
while low <= high and arr[high] >= pivot:
high -= 1
if low <= hig... | n = input()
arr = list(map(int, input().split()))
def podziel(arr, start, end):
pivot = arr[end]
low = start
high = end - 1
while True:
while low <= high and arr[low] <= pivot:
low += 1
while low <= high and arr[high] >= pivot:
high -= 1
if low <= high:
... |
def fib(x):
if(x == 0):
return 0
ant = 1
atual = 1
prox = ant + atual
for x in range(2, x):
prox = ant + atual
ant = atual
atual = prox
return atual
vezes = int(input())
for z in range(0, vezes):
i = int(input())
print('Fib(%d) = %d' %(i, fib(i)))
| def fib(x):
if x == 0:
return 0
ant = 1
atual = 1
prox = ant + atual
for x in range(2, x):
prox = ant + atual
ant = atual
atual = prox
return atual
vezes = int(input())
for z in range(0, vezes):
i = int(input())
print('Fib(%d) = %d' % (i, fib(i))) |
#!/usr/bin/python3
with open('04_input', 'r') as f:
lines = f.readlines()
num_list = [int(n) for n in lines[0].strip().split(',')]
lines = lines[2:]
class Board:
def __init__(self, lines):
self.called = [[False for i in range(5)] for j in range(5)]
self.remaining = set()
se... | with open('04_input', 'r') as f:
lines = f.readlines()
num_list = [int(n) for n in lines[0].strip().split(',')]
lines = lines[2:]
class Board:
def __init__(self, lines):
self.called = [[False for i in range(5)] for j in range(5)]
self.remaining = set()
self.pos_map = dict()
for... |
'''
Created on 2014-03-31
@author: Nich
'''
class VisibleThingsSystem(object):
'''
Attach all the things that a person can see to that person so that the parser knows what's available
'''
def __init__(self, node_factory):
self.node_factory = node_factory
def get_nodes(s... | """
Created on 2014-03-31
@author: Nich
"""
class Visiblethingssystem(object):
"""
Attach all the things that a person can see to that person so that the parser knows what's available
"""
def __init__(self, node_factory):
self.node_factory = node_factory
def get_nodes(self):
node... |
# Copyright 2017 Real Kinetic, LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable la... | """
A collected package of generic "providers". A provider is nothing but a service
that takes some FTP information and moves a file from an FTP server to another
service accessible from app engine.
An example is a generic HTTP provider that simply communicates with an external
service that moves a file from an FTP s... |
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Implementation of Rainman2's cli
"""
__author__ = 'Ari Saha (arisaha@icloud.com), Mingyang Liu(liux3941@umn.edu)'
__date__ = 'Wednesday, February 14th 2018, 11:42:20 am'
| """
Implementation of Rainman2's cli
"""
__author__ = 'Ari Saha (arisaha@icloud.com), Mingyang Liu(liux3941@umn.edu)'
__date__ = 'Wednesday, February 14th 2018, 11:42:20 am' |
class Policy(object):
def __init__(self, action=""):
self.action = action
def get_action(self, state):
return self.action | class Policy(object):
def __init__(self, action=''):
self.action = action
def get_action(self, state):
return self.action |
def is_prime(n):
if n % 2 == 0:
return False
for i in range(3, int(n**0.5) + 1, 2):
if n % i == 0:
return False
return True
input = int(input("Enter a number: "))
factors = [1]
if input % 2 == 0:
factors.append(2)
for x in range(3, int(input / 2) + 1):
if input % x == 0:
if is_prime(x) ... | def is_prime(n):
if n % 2 == 0:
return False
for i in range(3, int(n ** 0.5) + 1, 2):
if n % i == 0:
return False
return True
input = int(input('Enter a number: '))
factors = [1]
if input % 2 == 0:
factors.append(2)
for x in range(3, int(input / 2) + 1):
if input % x == 0... |
''' .strip returms a copy and removes the whitespace
replace() searchs for a string and then replaces it
greet = 'Hello Bob'
nstr = greet.replace('Bob', 'Jane' )
print(nstr)
nstr = greet.replace('o', 'X' )
print(nstr)
'''
'''facy format operator
camels = 42
camCount = 'I have spotted %d camels' % camels
print(camCoun... | """ .strip returms a copy and removes the whitespace
replace() searchs for a string and then replaces it
greet = 'Hello Bob'
nstr = greet.replace('Bob', 'Jane' )
print(nstr)
nstr = greet.replace('o', 'X' )
print(nstr)
"""
"facy format operator\ncamels = 42 \ncamCount = 'I have spotted %d camels' % camels\nprint(camCou... |
REQ_TITLES = {
'1.1': 'Transport Layer Security Validation',
'1.2': 'HSTS Validation',
'2': 'Cache Control',
'3': 'Validity of Domain Registration and TLS Certificates',
'4': 'Domain and Subdomain Takeover',
'5': 'Authentication and Authorization of Application Resources',
'6': 'Authenticati... | req_titles = {'1.1': 'Transport Layer Security Validation', '1.2': 'HSTS Validation', '2': 'Cache Control', '3': 'Validity of Domain Registration and TLS Certificates', '4': 'Domain and Subdomain Takeover', '5': 'Authentication and Authorization of Application Resources', '6': 'Authentication and Authorization of Store... |
# Use this with GIMP
# Copy and paste into the terminal
# Last time i tested it didn't work
# But sometimes it does
def save_mod(filename):
img = pdb.gimp_file_load(filename, filename)
img.scale(41,26)
new_filename = '/'.join(filename.split('/')[0:-1]) + "/medium/" + filename.split('/')[-1]
pdb.gimp_file_save(img... | def save_mod(filename):
img = pdb.gimp_file_load(filename, filename)
img.scale(41, 26)
new_filename = '/'.join(filename.split('/')[0:-1]) + '/medium/' + filename.split('/')[-1]
pdb.gimp_file_save(img, img.layers[0], new_filename, new_filename)
img = pdb.gimp_file_load(filename, filename)
img.sca... |
largest = -1
print("Starting now: ", largest)
for i in [5, 9, 12, 28, 74, 41, 55]:
if i > largest:
largest = i
print("Largest now: ", largest)
print("Finally: ", largest) | largest = -1
print('Starting now: ', largest)
for i in [5, 9, 12, 28, 74, 41, 55]:
if i > largest:
largest = i
print('Largest now: ', largest)
print('Finally: ', largest) |
a = 1
b = 2
acc = 0
while a < 4000000 or b < 4000000:
if a < 4000000 and not a%2: acc += a
if b < 4000000 and not b%2: acc += b
a += b
b += a
print(acc)
| a = 1
b = 2
acc = 0
while a < 4000000 or b < 4000000:
if a < 4000000 and (not a % 2):
acc += a
if b < 4000000 and (not b % 2):
acc += b
a += b
b += a
print(acc) |
"""
42. Trapping Rain Water
Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.
The above elevation map is represented by array [0,1,0,2,1,0,1,3,2,1,2,1]. In this case, 6 units of rain water (blue section) are being tra... | """
42. Trapping Rain Water
Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.
The above elevation map is represented by array [0,1,0,2,1,0,1,3,2,1,2,1]. In this case, 6 units of rain water (blue section) are being tra... |
class HttpError(Exception):
"""If a downloader was able to download a URL, but the result was not a 200 or 304"""
def __init__(self, message, code):
self.code = code
super(HttpError, self).__init__(message)
def __str__(self):
return self.args[0]
| class Httperror(Exception):
"""If a downloader was able to download a URL, but the result was not a 200 or 304"""
def __init__(self, message, code):
self.code = code
super(HttpError, self).__init__(message)
def __str__(self):
return self.args[0] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.