content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
def forward_index(): """ Called when the char '>' is found moves forward one index in the cell list """ pass def back_index(): """ Called when char '<' is found moves back one index in the cell list """ pass def plus_cell(): """ Called when the '+' char is found a...
def forward_index(): """ Called when the char '>' is found moves forward one index in the cell list """ pass def back_index(): """ Called when char '<' is found moves back one index in the cell list """ pass def plus_cell(): """ Called when the '+' char is found add...
# @Time : 2019/8/3 14:44 # @Author : shakespere # @FileName: Maximal Square.py ''' Input: 1 0 1 0 0 1 0 1 1 1 1 1 1 1 1 1 0 0 1 0 Output: 4 ''' class Solution(object): def maximalSquare(self, matrix): if not matrix: return 0 y = len(matrix) x = len(matrix[0]) dp =...
""" Input: 1 0 1 0 0 1 0 1 1 1 1 1 1 1 1 1 0 0 1 0 Output: 4 """ class Solution(object): def maximal_square(self, matrix): if not matrix: return 0 y = len(matrix) x = len(matrix[0]) dp = [[0] * x for _ in range(y)] for i in range(x): dp[0][i] = int(m...
class Solution(object): def minimumSwap(self, s1, s2): """ :type s1: str :type s2: str :rtype: int """ def test_minimum_swap(): s = Solution() assert 1 == s.minimumSwap("xx", "yy") assert 2 == s.minimumSwap("xy", "yx") assert -1 == s.minimumSwap("xx", "xy") ...
class Solution(object): def minimum_swap(self, s1, s2): """ :type s1: str :type s2: str :rtype: int """ def test_minimum_swap(): s = solution() assert 1 == s.minimumSwap('xx', 'yy') assert 2 == s.minimumSwap('xy', 'yx') assert -1 == s.minimumSwap('xx', 'xy')...
s = "abcdcbea" #enter string here pal = 1 for i in range(0 , len(s)//2): if s[i] != s[-(i+1)]: pal = 0 if pal == 1:print("pal") else:print("not pal")
s = 'abcdcbea' pal = 1 for i in range(0, len(s) // 2): if s[i] != s[-(i + 1)]: pal = 0 if pal == 1: print('pal') else: print('not pal')
termos=int(input('quantidade de termos: ')) t1=0 t2=1 print('{}->{}'.format(t1,t2),end='-> ') contador=3 while contador<=termos: t3=t1+t2 print('{}'.format(t3),end='-> ') t1=t2 t2=t3 contador=contador+1
termos = int(input('quantidade de termos: ')) t1 = 0 t2 = 1 print('{}->{}'.format(t1, t2), end='-> ') contador = 3 while contador <= termos: t3 = t1 + t2 print('{}'.format(t3), end='-> ') t1 = t2 t2 = t3 contador = contador + 1
class MimeTypeNotSupported(Exception): """Mimetype is not supported from the package""" pass class MimeTypeNotDetectable(Exception): pass class ManipulatedFileError(Exception): pass
class Mimetypenotsupported(Exception): """Mimetype is not supported from the package""" pass class Mimetypenotdetectable(Exception): pass class Manipulatedfileerror(Exception): pass
# -*- coding: utf-8 -*- COUNTRIES_LIST = [(u'Afghanistan', u'AF', u'AFG', 4, u'ISO 3166-2:AF'), (u'\xc5land Islands', u'AX', u'ALA', 248, u'ISO 3166-2:AX'), (u'Albania', u'AL', u'ALB', 8, u'ISO 3166-2:AL'), (u'Algeria', u'DZ', u'DZA', 12, u'ISO 3166-2:DZ'), (u'American Samoa', u'AS', u'ASM', 16, u'ISO 3166-2:AS'),...
countries_list = [(u'Afghanistan', u'AF', u'AFG', 4, u'ISO 3166-2:AF'), (u'Åland Islands', u'AX', u'ALA', 248, u'ISO 3166-2:AX'), (u'Albania', u'AL', u'ALB', 8, u'ISO 3166-2:AL'), (u'Algeria', u'DZ', u'DZA', 12, u'ISO 3166-2:DZ'), (u'American Samoa', u'AS', u'ASM', 16, u'ISO 3166-2:AS'), (u'Andorra', u'AD', u'AND', 20,...
#!/usr/bin/env python3.6 def create_user(first_name,last_name,contact,user_name,email,password): ''' Function to create a new user ''' new_user = User(first_name,last_name,contact,user_name,email,password) return new_user def save_users(user): ''' Function to save user ''' user.sav...
def create_user(first_name, last_name, contact, user_name, email, password): """ Function to create a new user """ new_user = user(first_name, last_name, contact, user_name, email, password) return new_user def save_users(user): """ Function to save user """ user.save_user() def de...
class User: 'Stores user information' def __init__(self, name, image, location, angellist_url, twitter_url, github_url, facebook_url, linkedin_url, what_ive_built, criteria, bio, blog_url, investor, skills): self.name = name self.image = image self.location = location self.angell...
class User: """Stores user information""" def __init__(self, name, image, location, angellist_url, twitter_url, github_url, facebook_url, linkedin_url, what_ive_built, criteria, bio, blog_url, investor, skills): self.name = name self.image = image self.location = location self.a...
""" Datos de salida hemoglobina-->hm-->float sexo-->sx-->string edad-->ed-->int Datos de entrada anemia-->anm-->string """ #Entrada hm=int(input("Ingrese el nivel de hemoglobina: ")) sx=int(input("Ingrese su sexo (1 para femenino y 2 para masculino): ")) ed=int(input("Ingrese su edad en meses: ")) #Caja negra anemia=""...
""" Datos de salida hemoglobina-->hm-->float sexo-->sx-->string edad-->ed-->int Datos de entrada anemia-->anm-->string """ hm = int(input('Ingrese el nivel de hemoglobina: ')) sx = int(input('Ingrese su sexo (1 para femenino y 2 para masculino): ')) ed = int(input('Ingrese su edad en meses: ')) anemia = '' if (ed >= 0 ...
class TopologyClipError(Exception): """Raised when GeoPandas clip() fails because of topology errors""" pass class TensorShapeError(Exception): """Raised when tensor shapes do not match""" pass
class Topologycliperror(Exception): """Raised when GeoPandas clip() fails because of topology errors""" pass class Tensorshapeerror(Exception): """Raised when tensor shapes do not match""" pass
# # Solution to Project Euler problem 116 # Copyright (c) Project Nayuki. All rights reserved. # # https://www.nayuki.io/page/project-euler-solutions # https://github.com/nayuki/Project-Euler-solutions # def compute(): LENGTH = 50 return str(sum(count_ways(LENGTH, i) for i in range(2, 5))) # How many ways can ...
def compute(): length = 50 return str(sum((count_ways(LENGTH, i) for i in range(2, 5)))) def count_ways(length, m): ways = [1] + [0] * length for n in range(1, len(ways)): ways[n] += ways[n - 1] if n >= m: ways[n] += ways[n - m] return ways[-1] - 1 if __name__ == '__main...
# Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. HTML_TOP = ''' <!-- Copyright (c) 2012 The Chromium Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can...
html_top = '\n<!--\n Copyright (c) 2012 The Chromium Authors. All rights reserved.\n Use of this source code is governed by a BSD-style license that can be\n found in the LICENSE file.\n-->\n\n<!DOCTYPE html>\n<html>\n<head>\n<style type="text/css">\ndt {\n font-weight: bold;\n}\ndd {\n margin-bottom: 12pt;\n wid...
print('to go on this trip you must be older than') print('18 but under 31 and provide your name') name = input('Type name here: ') age = int(input('Type age here: ')) if 18 <= age < 31: print(f'Well go get ready {name}, were leaving in an hour!') else: print(f'Sorry {name} you cant come this time.')
print('to go on this trip you must be older than') print('18 but under 31 and provide your name') name = input('Type name here: ') age = int(input('Type age here: ')) if 18 <= age < 31: print(f'Well go get ready {name}, were leaving in an hour!') else: print(f'Sorry {name} you cant come this time.')
vehicles = [ { "Year": 2020, "Make": "Audi", "Model": "Q3", "Category": "SUV" }, { "Year": 2020, "Make": "Chevrolet", "Model": "Malibu", "Category": "Sedan" }, { "Year": 2020, "Make": "Cadillac", "Model": "Escalade ESV", "Category": "SUV" }, { "Year": 20...
vehicles = [{'Year': 2020, 'Make': 'Audi', 'Model': 'Q3', 'Category': 'SUV'}, {'Year': 2020, 'Make': 'Chevrolet', 'Model': 'Malibu', 'Category': 'Sedan'}, {'Year': 2020, 'Make': 'Cadillac', 'Model': 'Escalade ESV', 'Category': 'SUV'}, {'Year': 2020, 'Make': 'Chevrolet', 'Model': 'Corvette', 'Category': 'Coupe, Converti...
#compiler for Farm programing language class infinitelist(object): #allows a list to be accessed infinitely, where indexes beyond it's length are reduced to match an index. def __init__(self, lst): self.lst = lst def __repr__(self): return str(self.lst) def __len__(self): return...
class Infinitelist(object): def __init__(self, lst): self.lst = lst def __repr__(self): return str(self.lst) def __len__(self): return len(self.lst) def __getitem__(self, i): if i == len(self.lst): return self.lst[i % len(self.lst)] elif i > len(se...
n = int(input()) # print("= [%d] samples" % n) for i in range(n): # print("== sample [%d/%d]" % (i + 1, n)) l = int(input()) # print("length [%d]" % l) h = 1 + (l >> 1) # print("half+1 [%d]" % h) s = input() # print("strips [%s]" % s) a = map(int, s.split()) if l % 2 == 0: ...
n = int(input()) for i in range(n): l = int(input()) h = 1 + (l >> 1) s = input() a = map(int, s.split()) if l % 2 == 0: print('no') continue x = 1 t = 0 valid = True for v in a: if x == 1 and v != 1: valid = False break if x <=...
server1 = 4 server2 = 4 server3 = 4 server4 = 4 server5 = 4 mode1 = 3 mode2 = 3 mode3 = 3 mode4 = 3 mode5 = 3 waittime = 240
server1 = 4 server2 = 4 server3 = 4 server4 = 4 server5 = 4 mode1 = 3 mode2 = 3 mode3 = 3 mode4 = 3 mode5 = 3 waittime = 240
def get_log_groups(logs_client): """ Generates every log group in the current AWS account. """ paginator = logs_client.get_paginator("describe_log_groups") for page in paginator.paginate(): yield from page["logGroups"] def get_log_streams(logs_client, *, log_group_name): """ Gener...
def get_log_groups(logs_client): """ Generates every log group in the current AWS account. """ paginator = logs_client.get_paginator('describe_log_groups') for page in paginator.paginate(): yield from page['logGroups'] def get_log_streams(logs_client, *, log_group_name): """ Generat...
# + def iterateInner(distance, tour, length, cities, i): for j in range(i + 2, cities): newTour = twoOptSwap(i, j, tour) newLength = findTourLength(newTour, distance) if (newLength < length): curTour = newTour bestLength = newLength return curTour, bestLen...
def iterate_inner(distance, tour, length, cities, i): for j in range(i + 2, cities): new_tour = two_opt_swap(i, j, tour) new_length = find_tour_length(newTour, distance) if newLength < length: cur_tour = newTour best_length = newLength return (curTour, bes...
houses = [int(x) for x in input().split("@")] command = input() index = 0 while command != "Love!": command = command.split(" ") order = command[0] length = int(command[1]) index += length if 0 <= index < len(houses): if houses[index] == 0: print(f"Place {index} already had V...
houses = [int(x) for x in input().split('@')] command = input() index = 0 while command != 'Love!': command = command.split(' ') order = command[0] length = int(command[1]) index += length if 0 <= index < len(houses): if houses[index] == 0: print(f"Place {index} already had Valen...
# Name : Exercise7-1.py # Author : Ryan Carr # Date : 02/03/19 # Purpose : Open a file, convert all text to uppercase # and print result to screen # Text files are stored in the data folder one level up filename = '../data/mbox-short.txt' fh = open(filename,'r') for line in fh: print(line.strip()...
filename = '../data/mbox-short.txt' fh = open(filename, 'r') for line in fh: print(line.strip().upper()) fh.close()
# 7. calculate the strength of the supports or resistances # 7.1 remove repeated values def lowest_highest_candle_price(dataframe, number_of_rows, candle_i, tolerance): lowest_candle_price = dataframe["low"][number_of_rows - candle_i] - tolerance highest_candle_price = dataframe["high"][number_of_rows - candl...
def lowest_highest_candle_price(dataframe, number_of_rows, candle_i, tolerance): lowest_candle_price = dataframe['low'][number_of_rows - candle_i] - tolerance highest_candle_price = dataframe['high'][number_of_rows - candle_i] + tolerance return (lowest_candle_price, highest_candle_price) def resistances_h...
sh = input("Enter hours: ") su = input("Enter rate: ") try: #Dangerous zone, here you put the try to handle the error fh = float(sh) #Transform fh to a float value fr = float(su) #Transform fr to a float value except: print("Please enter a numeric value") quit() # print (fr, fh) if fh > 40 : #print(...
sh = input('Enter hours: ') su = input('Enter rate: ') try: fh = float(sh) fr = float(su) except: print('Please enter a numeric value') quit() if fh > 40: reg = fr * fh otp = (fh - 40.0) * (fr * 0.5) xp = reg + otp else: xp = fh * fr print('Pay:', xp)
class Rectangle: def __init__(self, width, height): self.width = width self.height = height def set_width(self, width): self.width = width def set_height(self, height): self.height = height def get_area(self): return self.width * self.height def get_perimeter(self): return 2 * se...
class Rectangle: def __init__(self, width, height): self.width = width self.height = height def set_width(self, width): self.width = width def set_height(self, height): self.height = height def get_area(self): return self.width * self.height def get_perim...
def demo_filter(): num_list = list( range(1, 11) ) ## Example_#1: # pick even number result = list( filter( lambda x:x%2==0, num_list) ) # [2, 4, 6, 8, 10] print( result ) ## Example_#2: # pick odd number result = list( filter( lambda x:x%2==1, num_list) ) # [1, 3, 5, 7, 9...
def demo_filter(): num_list = list(range(1, 11)) result = list(filter(lambda x: x % 2 == 0, num_list)) print(result) result = list(filter(lambda x: x % 2 == 1, num_list)) print(result) result = list(filter(lambda x: x % 3 == 0, num_list)) print(result) str_list = ['Apple', 'Banana', 'cat...
courses = { "js": "JavaScript 101", "python": ["Python 101", "Python 201"], "html": "HTML 101" } # print(courses.get("css", "CSS 101")) if courses.get("css", None): print("You are enrolled in CSS 101")
courses = {'js': 'JavaScript 101', 'python': ['Python 101', 'Python 201'], 'html': 'HTML 101'} if courses.get('css', None): print('You are enrolled in CSS 101')
def instance_name_check(test, resource, key, value): if test == "ISBAD": if resource[key].startswith(value): return True else: return False else: return False
def instance_name_check(test, resource, key, value): if test == 'ISBAD': if resource[key].startswith(value): return True else: return False else: return False
''' Given a list A of numbers (integers), you have to print those numbers which are not multiples of 5. >>Input Format: The first line contains the numbers of list A separated by a space. >>Output Format: Print the numbers in a single line separated by a space which are not multiples of 5. >>Example: Input: 1 2 ...
""" Given a list A of numbers (integers), you have to print those numbers which are not multiples of 5. >>Input Format: The first line contains the numbers of list A separated by a space. >>Output Format: Print the numbers in a single line separated by a space which are not multiples of 5. >>Example: Input: 1 2 ...
GOOGLEAPIS_BUILD_FILE = """ filegroup( name = "annotations_protos", srcs = [ "google/api/annotations.proto", "google/api/http.proto", ], visibility = ["//visibility:public"] ) """ DEPS = { "com_github_grpc_ecosystem_grpc_gateway": { "rule": "go_repository", "importpath": "github.co...
googleapis_build_file = '\nfilegroup(\n name = "annotations_protos",\n srcs = [\n "google/api/annotations.proto",\n "google/api/http.proto",\n ],\n visibility = ["//visibility:public"]\n)\n' deps = {'com_github_grpc_ecosystem_grpc_gateway': {'rule': 'go_repository', 'importpath': 'github.com/grpc-ecosystem/gr...
class Solution: def solve(self, nums, k): if not nums: return 0 if nums.count(0) <= k: return len(nums) locs = [-1]+[i for i in range(len(nums)) if nums[i] == 0]+[len(nums)] ans = -1 for i in range(k,len(locs)-1): ans = max(ans, locs[i+1]-locs[i-k]-1) r...
class Solution: def solve(self, nums, k): if not nums: return 0 if nums.count(0) <= k: return len(nums) locs = [-1] + [i for i in range(len(nums)) if nums[i] == 0] + [len(nums)] ans = -1 for i in range(k, len(locs) - 1): ans = max(ans, loc...
# Error Messages ENTRY_ALREADY_EXISTS = 'Help entry already exists for tag "{}".' NO_ENTRY = 'No help entry for tag "{}".' NO_FILE_AT_PROVIDED_PATH = 'No file found at provided path: {}' # Success Messages ADD_SUCCESS_NO_SEED_FILE = 'Successfully added help entry "{}".' ADD_SUCCESS_WITH_SEED_FILE = 'Successfully added...
entry_already_exists = 'Help entry already exists for tag "{}".' no_entry = 'No help entry for tag "{}".' no_file_at_provided_path = 'No file found at provided path: {}' add_success_no_seed_file = 'Successfully added help entry "{}".' add_success_with_seed_file = 'Successfully added help entry "{}" from seed file "{}"....
list = [('abc.es','HTTP/1.1 200',0,0,0,0,0), ('abcnews.go.com','HTTP/1.1 200',2,0,0,0,'/'), ('about.me','HTTP/1.1 200',5,1,1,'Lax','/'), ('abril.com.br','HTTP/1.1 301',1,1,1,0,'/'), ('alibaba.com','HTTP/1.1 200',1,0,0,0,'/'), ('ap.org','HTTP/1.1 200',0,0,0,0,0), ('biblegateway.com','HTTP/1.1 200',0,0,0,0,0), ('b...
list = [('abc.es', 'HTTP/1.1 200', 0, 0, 0, 0, 0), ('abcnews.go.com', 'HTTP/1.1 200', 2, 0, 0, 0, '/'), ('about.me', 'HTTP/1.1 200', 5, 1, 1, 'Lax', '/'), ('abril.com.br', 'HTTP/1.1 301', 1, 1, 1, 0, '/'), ('alibaba.com', 'HTTP/1.1 200', 1, 0, 0, 0, '/'), ('ap.org', 'HTTP/1.1 200', 0, 0, 0, 0, 0), ('biblegateway.com', ...
def super_func(*args): total = sum(args) print(total) super_func(1, 2, 3, 4) def super_func2(**kwargs): total = 0 for value in kwargs.values(): total += value print(total) super_func2(num1 = 1, num2 = 2, num3 = 3, num4 = 4)
def super_func(*args): total = sum(args) print(total) super_func(1, 2, 3, 4) def super_func2(**kwargs): total = 0 for value in kwargs.values(): total += value print(total) super_func2(num1=1, num2=2, num3=3, num4=4)
"""Module for defining constants""" FASTA = 'fasta' FASTQ = 'fastq'
"""Module for defining constants""" fasta = 'fasta' fastq = 'fastq'
46 1280 7 800 13 3000 5000 50000
46 1280 7 800 13 3000 5000 50000
class PushException(Exception): pass class PushAuthException(PushException): pass class PushInvalidTokenException(PushException): pass class PushInvalidDataException(PushException): pass class PushServerException(PushException): pass
class Pushexception(Exception): pass class Pushauthexception(PushException): pass class Pushinvalidtokenexception(PushException): pass class Pushinvaliddataexception(PushException): pass class Pushserverexception(PushException): pass
#!/usr/bin/python class RLFNodeColoring1: """Recursive Largest First (RLF) algorithm for node coloring.""" def __init__(self, graph): """The algorithm initialization.""" if graph.is_directed(): raise ValueError("the graph is directed") self.graph = graph self.color ...
class Rlfnodecoloring1: """Recursive Largest First (RLF) algorithm for node coloring.""" def __init__(self, graph): """The algorithm initialization.""" if graph.is_directed(): raise value_error('the graph is directed') self.graph = graph self.color = dict(((node, Non...
FONT = 'Tahoma 12' PAUSE = 0.15 TIMES_SEPARATOR = '-' CASE_SEPARATOR = '#' DAY = slice(None, 2) MONTH = slice(3, 5) YEAR = slice(6, None) HOUR = slice(None, 2) MINUTE = slice(3, None)
font = 'Tahoma 12' pause = 0.15 times_separator = '-' case_separator = '#' day = slice(None, 2) month = slice(3, 5) year = slice(6, None) hour = slice(None, 2) minute = slice(3, None)
CHALLENGE_PERIOD = 20 PLASMA_BLOCK_INTERVAL = 10 MAX_TREE_DEPTH = 8
challenge_period = 20 plasma_block_interval = 10 max_tree_depth = 8
# -*- coding:utf-8 -*- """ db_config.py ~~~~~~~~~~~~ database config info. """ # my mysql config info = { 'host': '127.0.0.1', 'port': 3306, 'user': 'root', 'password': '', 'database': 'zhihu', 'charset': 'utf8' }
""" db_config.py ~~~~~~~~~~~~ database config info. """ info = {'host': '127.0.0.1', 'port': 3306, 'user': 'root', 'password': '', 'database': 'zhihu', 'charset': 'utf8'}
""" attr_dict.py Implements AttrDict class for defining an attribute dictionary that allows us to address keys as if they were attributes. Idea taken from: https://danijar.com/patterns-for-fast-prototyping-with-tensorflow/ Author: Sam Foreman Date: 04/09/2019 """ class AttrDict(dict): """A dict which is ac...
""" attr_dict.py Implements AttrDict class for defining an attribute dictionary that allows us to address keys as if they were attributes. Idea taken from: https://danijar.com/patterns-for-fast-prototyping-with-tensorflow/ Author: Sam Foreman Date: 04/09/2019 """ class Attrdict(dict): """A dict which is acc...
r""" Logo ---- Uses :mod:`dummy` backend. File: `\\examples\\withDummy\\logo_xrt.py` :mod:`xrt` logo (on the right, in two versions) created from a "flat" python logo (on the left). |ini_image| --------------> |logo_image| |logo_image_inv| .. |ini_image| imagezoom:: _images/logo-python.* :scale: 50 % .. ...
""" Logo ---- Uses :mod:`dummy` backend. File: `\\\\examples\\\\withDummy\\\\logo_xrt.py` :mod:`xrt` logo (on the right, in two versions) created from a "flat" python logo (on the left). |ini_image| --------------> |logo_image| |logo_image_inv| .. |ini_image| imagezoom:: _images/logo-python.* :scale: 50 %...
pensil_box = ["pen","pensil","eraser","candy","gum"] print(pensil_box) pensil_box.append("betmen_statue") print(pensil_box)
pensil_box = ['pen', 'pensil', 'eraser', 'candy', 'gum'] print(pensil_box) pensil_box.append('betmen_statue') print(pensil_box)
def add(x, y): """ Add two numbers and return their sum""" return x+y def subtract(x, y): """ Subtract to numbers and return their results""" return x-y
def add(x, y): """ Add two numbers and return their sum""" return x + y def subtract(x, y): """ Subtract to numbers and return their results""" return x - y
l = [] s = '0123456789' counter = 0 while counter < 1000000: for a in s: s0 = s.replace(a, '') for b in s0: s1 = s.replace(b, '') for c in s1: s2 = s.replace(c, '') for d in s2: s3 = s.replace(d, '') ...
l = [] s = '0123456789' counter = 0 while counter < 1000000: for a in s: s0 = s.replace(a, '') for b in s0: s1 = s.replace(b, '') for c in s1: s2 = s.replace(c, '') for d in s2: s3 = s.replace(d, '') for ...
# CodeWars Kata/Digital Root def digital_root(n): if len(str(n)) == 1: return n else: return digital_root(digit_sum(n)) def digit_sum(num): return sum([int(char) for char in str(num)])
def digital_root(n): if len(str(n)) == 1: return n else: return digital_root(digit_sum(n)) def digit_sum(num): return sum([int(char) for char in str(num)])
input = """ num(2). node(a). p(N) :- num(N), #count{Y:node(Y)} = N1, N<=N1. """ output = """ num(2). node(a). p(N) :- num(N), #count{Y:node(Y)} = N1, N<=N1. """
input = '\nnum(2).\nnode(a).\np(N) :- num(N), #count{Y:node(Y)} = N1, N<=N1.\n' output = '\nnum(2).\nnode(a).\np(N) :- num(N), #count{Y:node(Y)} = N1, N<=N1.\n'
age = 37 name = 'Bob' gender = 'male' hobby = 'cycling' timeofday = 'at night' typeofbike = 'giant' country = 'ireland' sizeofwheels = '700' print('{} {} {} was {} when he was {}'.format(timeofday,gender,name,hobby,age)) print('the sun is shining in the sky during the day') print('{} flew to {} then bough...
age = 37 name = 'Bob' gender = 'male' hobby = 'cycling' timeofday = 'at night' typeofbike = 'giant' country = 'ireland' sizeofwheels = '700' print('{} {} {} was {} when he was {}'.format(timeofday, gender, name, hobby, age)) print('the sun is shining in the sky during the day') print('{} flew to {} then bought a {} bik...
# Source : https://leetcode.com/problems/course-schedule-ii/ # Author : henrytine # Date : 2020-08-09 ##################################################################################################### # # There are a total of n courses you have to take, labeled from 0 to n-1. # # Some courses may have prerequisit...
class Solution: def find_order(self, numCourses: int, prerequisites: List[List[int]]) -> List[int]: dic = [0 for i in range(numCourses)] neighbor = collections.defaultdict(set) for (i, j) in prerequisites: dic[i] += 1 neighbor[j].add(i) stack = [i for i in ra...
""" The Generalized Balanced Symbols Problem. https://bradfieldcs.com/algos/stacks/balanced-parentheses/ Given a string of opening and closing symbols, how to tell if they're balanced? --- ((({}[]))) -> true ((())) -> true (()) -> true () -> true ()()() -> true ()[]{} -> true ([{}]) -> true --- ()) -> false ))(( ...
""" The Generalized Balanced Symbols Problem. https://bradfieldcs.com/algos/stacks/balanced-parentheses/ Given a string of opening and closing symbols, how to tell if they're balanced? --- ((({}[]))) -> true ((())) -> true (()) -> true () -> true ()()() -> true ()[]{} -> true ([{}]) -> true --- ()) -> false ))(( ...
# Enter your code for "Costly cake!" here. c1sl = input("Cake 1 side length (cm): ") c1c = input("Cake 1 cost ($): ") c2sl = input("Cake 2 side length (cm): ") c2c = input("Cake 2 cost ($): ") c1sa = float(c1sl) ** 2 c2sa = float(c2sl) ** 2 c1cp = float(c1c) / c1sa c2cp = float(c2c) / c2sa print ("Cake 1 costs $%.2...
c1sl = input('Cake 1 side length (cm): ') c1c = input('Cake 1 cost ($): ') c2sl = input('Cake 2 side length (cm): ') c2c = input('Cake 2 cost ($): ') c1sa = float(c1sl) ** 2 c2sa = float(c2sl) ** 2 c1cp = float(c1c) / c1sa c2cp = float(c2c) / c2sa print('Cake 1 costs $%.2f per cm2 for %d cm2' % (c1cp, c1sa)) print('Cak...
""" Entradas d-->int Salidas a-->int b-->int c-->int """ a=int(input("Digite el valor de a: ")) b=int(input("Digite el valor de b: ")) c=int(input("Digite el valor de c: ")) d=int(input("Digite el valor de d: ")) if (d==0) : e=(a-c)**2 print("el valor de b sera de :" +str(e)) elif (d>0): e=(a-b)**2/d print("el v...
""" Entradas d-->int Salidas a-->int b-->int c-->int """ a = int(input('Digite el valor de a: ')) b = int(input('Digite el valor de b: ')) c = int(input('Digite el valor de c: ')) d = int(input('Digite el valor de d: ')) if d == 0: e = (a - c) ** 2 print('el valor de b sera de :' + str(e)) elif d > 0: e = (...
class UVGridlineType(Enum, IComparable, IFormattable, IConvertible): """ A choice between U-gridlines or V-gridlines of a divided surface U Gridlines V Gridlines enum UVGridlineType,values: U (0),V (1) """ def __eq__(self, *args): """ x.__eq__(y) <==> x==yx.__eq__(y) <==>...
class Uvgridlinetype(Enum, IComparable, IFormattable, IConvertible): """ A choice between U-gridlines or V-gridlines of a divided surface U Gridlines V Gridlines enum UVGridlineType,values: U (0),V (1) """ def __eq__(self, *args): """ x.__eq__(y) <==> x==yx.__eq__(y) <==> x==yx.__eq__(...
# https://leetcode.com/problems/find-minimum-in-rotated-sorted-array-ii/ # Suppose an array of length n sorted in ascending order is rotated between 1 and # n times. For example, the array nums = [0,1,4,4,5,6,7] might become: # Notice that rotating an array [a[0], a[1], a[2], ..., a[n-1]] 1 time results in # the arra...
class Solution: def find_min(self, nums: List[int]) -> int: (left, right) = (0, len(nums) - 1) while left + 1 < right: mid = left + (right - left) // 2 if nums[mid] > nums[right]: left = mid elif nums[mid] < nums[right]: right = mi...
# day 16 challenge 2 # actually figure things out # can ignore everything prior to line 26 (25 when 0 indexed) when getting nearby raw = [] with open('input.txt', mode='r') as file: for line in file.readlines()[25:]: raw.append([int(num) for num in line.strip().split(',')]) # grab our own ticket, too with...
raw = [] with open('input.txt', mode='r') as file: for line in file.readlines()[25:]: raw.append([int(num) for num in line.strip().split(',')]) with open('input.txt', mode='r') as file: mine = [int(num) for num in file.readlines()[22].strip().split(',')] vld_ranges = [] with open('input.txt', mode='r') ...
N, a, b, c = int(input()), int(input()), int(input()), int(input()) ans = 0 if b - c < a and N >= b: ans += (N - b) // (b - c) + 1 N = (N - b) % (b - c) + c print(ans + N // a)
(n, a, b, c) = (int(input()), int(input()), int(input()), int(input())) ans = 0 if b - c < a and N >= b: ans += (N - b) // (b - c) + 1 n = (N - b) % (b - c) + c print(ans + N // a)
DISTRICTS_TO_PROVINCE = dict(s.split("\t") for s in """ DC10 EC DC10 EC DC10 EC DC12 EC DC12 EC DC13 EC DC13 EC DC14 EC DC14 EC DC15 EC DC15 EC DC15 EC DC15 EC DC15 EC DC44 EC DC16 FS DC16 FS DC16 FS DC18 FS DC18 FS DC18 FS DC18 FS DC18 FS DC19 FS DC19 FS DC19 FS DC19 FS DC19 FS DC19 FS DC20 FS DC20 FS DC20 FS DC20 FS ...
districts_to_province = dict((s.split('\t') for s in '\nDC10\tEC\nDC10\tEC\nDC10\tEC\nDC12\tEC\nDC12\tEC\nDC13\tEC\nDC13\tEC\nDC14\tEC\nDC14\tEC\nDC15\tEC\nDC15\tEC\nDC15\tEC\nDC15\tEC\nDC15\tEC\nDC44\tEC\nDC16\tFS\nDC16\tFS\nDC16\tFS\nDC18\tFS\nDC18\tFS\nDC18\tFS\nDC18\tFS\nDC18\tFS\nDC19\tFS\nDC19\tFS\nDC19\tFS\nDC19...
class DBRouter: def db_for_read(self, model, **hints): if model._meta.app_label == 'thirdapp': return 'custom' return None def db_for_write(self, model, **hints): if model._meta.app_label == 'thirdapp': return 'custom' return None def allow_relation(self, obj1, obj2, **...
class Dbrouter: def db_for_read(self, model, **hints): if model._meta.app_label == 'thirdapp': return 'custom' return None def db_for_write(self, model, **hints): if model._meta.app_label == 'thirdapp': return 'custom' return None def allow_relation(self, obj1, obj2, *...
# -*- coding: utf-8 -*- #============================================================================== # uniq #============================================================================== def uniq(seq): seen = set() seen_add = seen.add return [x for x in seq if x not in seen and not seen_add(x)]
def uniq(seq): seen = set() seen_add = seen.add return [x for x in seq if x not in seen and (not seen_add(x))]
def hanoi(pegs, start, target, n): assert len(pegs[start]) >= n, 'not enough disks on peg' if n == 1: pegs[target].append(pegs[start].pop()) print ('%i -> %i: %s' % (start, target, pegs)) else: aux = 3 - start - target # start + target + aux = 3 hanoi(pegs, start, aux, n-1) ...
def hanoi(pegs, start, target, n): assert len(pegs[start]) >= n, 'not enough disks on peg' if n == 1: pegs[target].append(pegs[start].pop()) print('%i -> %i: %s' % (start, target, pegs)) else: aux = 3 - start - target hanoi(pegs, start, aux, n - 1) hanoi(pegs, start, ...
def help_(_, update): update.message.reply_text( 'This bot can remember stickers to help you find them more easily.\n' '\n' 'To add a sticker, just send it to me in private. To manage sticker\'s' ' tags, reply to a sticker with commands /add_tags or /delete_tag.' )
def help_(_, update): update.message.reply_text("This bot can remember stickers to help you find them more easily.\n\nTo add a sticker, just send it to me in private. To manage sticker's tags, reply to a sticker with commands /add_tags or /delete_tag.")
class Entertainment: ''' Sources class to define Sources Objects ''' def __init__(self,idNumber,name,description,publishedAt,source_url): self.idNumber = idNumber self.name = name self.description = description self.publishedAt = publishedAt self.source_url = source_url
class Entertainment: """ Sources class to define Sources Objects """ def __init__(self, idNumber, name, description, publishedAt, source_url): self.idNumber = idNumber self.name = name self.description = description self.publishedAt = publishedAt self.source_url ...
n = int(input()) l = [] for i in range(n): a = list(map(int,input().split(sep=" ", maxsplit=n))) l.append(a) sum_1 = 0 sum_2 = 0 for i in range(n): sum_1 = sum_1 + l[i][i] sum_2 = sum_2 + l[i][n-1-i] diff = sum_1 - sum_2 if diff >=0: print(diff) else: print(-diff)
n = int(input()) l = [] for i in range(n): a = list(map(int, input().split(sep=' ', maxsplit=n))) l.append(a) sum_1 = 0 sum_2 = 0 for i in range(n): sum_1 = sum_1 + l[i][i] sum_2 = sum_2 + l[i][n - 1 - i] diff = sum_1 - sum_2 if diff >= 0: print(diff) else: print(-diff)
with open('backup/name1.txt', 'r') as file1: c1 = set(file1.readlines()) with open('backup/name2.txt', 'r') as file2: c2 = set(file2.readlines()) c3 = list(c1.union(c2)) c4=[] for i in c3: c4.append(i.strip('\n')) with open('backup/merge.txt', 'w') as file3: file3.write(' '.join(c4))
with open('backup/name1.txt', 'r') as file1: c1 = set(file1.readlines()) with open('backup/name2.txt', 'r') as file2: c2 = set(file2.readlines()) c3 = list(c1.union(c2)) c4 = [] for i in c3: c4.append(i.strip('\n')) with open('backup/merge.txt', 'w') as file3: file3.write(' '.join(c4))
encoding_size = 3 model = nn.Sequential(nn.Linear(input_size, int(input_size/2)), nn.PReLU(), nn.Linear(int(input_size/2), encoding_size*32), nn.PReLU(), nn.Linear(encoding_size*32, encoding_size), nn.PReLU(),...
encoding_size = 3 model = nn.Sequential(nn.Linear(input_size, int(input_size / 2)), nn.PReLU(), nn.Linear(int(input_size / 2), encoding_size * 32), nn.PReLU(), nn.Linear(encoding_size * 32, encoding_size), nn.PReLU(), normalize_layer(), nn.Linear(encoding_size, encoding_size * 32), nn.PReLU(), nn.Linear(encoding_size *...
def main() -> None: n = int(input()) a = list(map(int, input().split())) a.sort() for i in range(n): if a[i] == i + 1: continue print("No") return print("Yes") if __name__ == "__main__": main()
def main() -> None: n = int(input()) a = list(map(int, input().split())) a.sort() for i in range(n): if a[i] == i + 1: continue print('No') return print('Yes') if __name__ == '__main__': main()
#from . import module3a # ok but pylint makes an error: Attempted relative import beyond top-level package (relative-beyond-top-level) def func3b(): print('3b') #module3a.func3a()
def func3b(): print('3b')
# The frequently used ranges RANGE3 = range(3) RANGE9 = range(9) RANGE81 = range(81) CANDIDATES_RANGE = range(1, 10) # This divider is printed to separate the parts DIVIDER = "-------+-------+-------" # These are the constants used to group "chunks" or areas in Sudoku # These areas are the ones where the constraints ...
range3 = range(3) range9 = range(9) range81 = range(81) candidates_range = range(1, 10) divider = '-------+-------+-------' triples = [[offset * 3 + i for i in RANGE3] for offset in RANGE3] rows = [[i * 9 + j for j in RANGE9] for i in RANGE9] cols = [[i * 9 + j for i in RANGE9] for j in RANGE9] sub_squares = [[i * 9 + ...
# Belajar Numeric Types # Ada 3 Jenis yaitu : # 1. Integer # 2. Float # 3. Complex --> ada angka real dan angka imaginer angka = 5 angka2 = 5.5 total = angka + angka2 print("data :", angka, type(angka)) print("data :", total, type(total)) print(10/2) # menggunakan operasi matematika pe...
angka = 5 angka2 = 5.5 total = angka + angka2 print('data :', angka, type(angka)) print('data :', total, type(total)) print(10 / 2)
class Solution: def maxSubArray(self, nums): """ :type nums: List[int] :rtype: int """ curr = 0 largest = -float('inf') for n in nums: curr += n if n > curr: curr = n largest = max((...
class Solution: def max_sub_array(self, nums): """ :type nums: List[int] :rtype: int """ curr = 0 largest = -float('inf') for n in nums: curr += n if n > curr: curr = n largest = max((curr, largest)) ...
"""Kata url: https://www.codewars.com/kata/597754ba62f8a19c98000030.""" def vowel_change(txt: str, vow: str) -> str: return txt.translate(str.maketrans('aeiou', vow * 5))
"""Kata url: https://www.codewars.com/kata/597754ba62f8a19c98000030.""" def vowel_change(txt: str, vow: str) -> str: return txt.translate(str.maketrans('aeiou', vow * 5))
''' A collection of html templates used by biothings APIs ''' HTML_OUT_TEMPLATE = ''' <html> <head> <link href="https://cdn.rawgit.com/josdejong/jsoneditor/v5.11.0/dist/jsoneditor.min.css" rel="stylesheet" type="text/css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1....
""" A collection of html templates used by biothings APIs """ html_out_template = '\n <html>\n <head>\n <link href="https://cdn.rawgit.com/josdejong/jsoneditor/v5.11.0/dist/jsoneditor.min.css" rel="stylesheet" type="text/css">\n <script src="https://ajax.googleapis.com/ajax/libs/jquery/1...
# -*- encoding: utf-8 -*- # allowdebugfeatures def breakline(line, width): index = line.rfind(' ', 0, width + 1) if index == -1: return return line[:index], line[index+1:] def breaklines(text, width, baseindentation): if len(text) <= width or ' ' not in text: return lines = [...
def breakline(line, width): index = line.rfind(' ', 0, width + 1) if index == -1: return return (line[:index], line[index + 1:]) def breaklines(text, width, baseindentation): if len(text) <= width or ' ' not in text: return lines = [] while len(text) > width: index = tex...
class IncompleteVoteError(Exception): pass class NoWinnerError(Exception): pass class InvalidVoteError(Exception): pass class FailedElectionError(Exception): pass
class Incompletevoteerror(Exception): pass class Nowinnererror(Exception): pass class Invalidvoteerror(Exception): pass class Failedelectionerror(Exception): pass
""" * Module Name: ErrorHandle * Module Purpose: Define and handle all error messages for requests """
""" * Module Name: ErrorHandle * Module Purpose: Define and handle all error messages for requests """
"""Dadata client settings""" TIMEOUT_SEC = 3 SUGGESTION_COUNT = 10
"""Dadata client settings""" timeout_sec = 3 suggestion_count = 10
s = 'hdbobbbobobobobobobooboobobobob' count = i = 0 while True: j = s.find('bob', i) if j == -1 : break count += 1 i = j + 1 print('Number of times bob occurs is: '+str(count))
s = 'hdbobbbobobobobobobooboobobobob' count = i = 0 while True: j = s.find('bob', i) if j == -1: break count += 1 i = j + 1 print('Number of times bob occurs is: ' + str(count))
class ProgressSend(): def __init__(self, task): self.task = task self.description = "" self.percentage = 0 self.subProgress = [] self.header = "" def send_progress(self, percentage=None, subProgress=[], description="", header=""): state = 'PROGRESS' ...
class Progresssend: def __init__(self, task): self.task = task self.description = '' self.percentage = 0 self.subProgress = [] self.header = '' def send_progress(self, percentage=None, subProgress=[], description='', header=''): state = 'PROGRESS' if per...
x = [] for i in range(10): if i % 2 == 0: x.append(dask.delayed(square)(i)) else: x.append(dask.delayed(add)(i, i)) y = dask.delayed(sum)(x) # use `y.visualize()` to visualize the graph and `y.compute()` to execute it.
x = [] for i in range(10): if i % 2 == 0: x.append(dask.delayed(square)(i)) else: x.append(dask.delayed(add)(i, i)) y = dask.delayed(sum)(x)
# Author: Sanket Dalvi # Question Link: https://leetcode.com/problems/restore-ip-addresses/ class Solution: def __init__(self): super().__init__() self.ipList = [] def getList(self, level, A, suffix): if level > 3: if len(suffix)-4 == len(A) and suffix[1:] not in self.ipList...
class Solution: def __init__(self): super().__init__() self.ipList = [] def get_list(self, level, A, suffix): if level > 3: if len(suffix) - 4 == len(A) and suffix[1:] not in self.ipList: self.ipList.append(suffix[1:]) return temp = [] ...
class streaming_service_type: netflix = "netflix" amazon = "amazon" youtube = "youtube" other = "other"
class Streaming_Service_Type: netflix = 'netflix' amazon = 'amazon' youtube = 'youtube' other = 'other'
w = int(input()) n = int(input()) s = 0 for i in range(n): a, b = map(int, input().split()) s += a * b print(s//w)
w = int(input()) n = int(input()) s = 0 for i in range(n): (a, b) = map(int, input().split()) s += a * b print(s // w)
# -*- coding: utf-8 -*- __title__ = "huvr_client" __description__ = "Python Client for HUVRdata" __url__ = "https://www.huvrdata.com" __version__ = "0.2.8" __build__ = 0x022200 __author__ = "HUVRdata" __author_email__ = "api@huvrdata.com" __license__ = "BSD 2.0" __copyright__ = "Copyright 2019 HUVRdata LLC"
__title__ = 'huvr_client' __description__ = 'Python Client for HUVRdata' __url__ = 'https://www.huvrdata.com' __version__ = '0.2.8' __build__ = 139776 __author__ = 'HUVRdata' __author_email__ = 'api@huvrdata.com' __license__ = 'BSD 2.0' __copyright__ = 'Copyright 2019 HUVRdata LLC'
#!/bin/python3 class MessageHandler: __message_type = ['Error', 'Information', 'Warning', 'Debug'] def __init__(self, date_format): self.date_format = date_format def new_message(message, message_code, message_type='Information'): if message_type not in self.__message_type: raise Exception('Un...
class Messagehandler: __message_type = ['Error', 'Information', 'Warning', 'Debug'] def __init__(self, date_format): self.date_format = date_format def new_message(message, message_code, message_type='Information'): if message_type not in self.__message_type: raise exception('U...
#!/usr/bin/env python3 def main(msg="Hello, World!"): print(f"\x1b[32m{msg}\x1b[0m") if __name__ == '__main__': args = __import__('sys').argv[1:] if len(args) >= 1: args = ' '.join(args) if args: main(args) else: main()
def main(msg='Hello, World!'): print(f'\x1b[32m{msg}\x1b[0m') if __name__ == '__main__': args = __import__('sys').argv[1:] if len(args) >= 1: args = ' '.join(args) if args: main(args) else: main()
# bubble sort algorithm # O(n^2) time complexity # O(1) space complexity def bubblesort(list, comp): for x in range(len(list) - 1): for y in range(len(list) - (x + 1)): curr = list[y] adj = list[y + 1] if (comp(curr, adj) > 0): list[y + 1] = curr ...
def bubblesort(list, comp): for x in range(len(list) - 1): for y in range(len(list) - (x + 1)): curr = list[y] adj = list[y + 1] if comp(curr, adj) > 0: list[y + 1] = curr list[y] = adj return list
class Employee: def __init__(self, name, payRate): self.name = name self.pay = payRate def __str__(self): return 'EmpName: ' + self.name + 'EmpPay: ' + str(self.pay) def grossPay(self, hoursWorked): return self.pay * hoursWorked class M...
class Employee: def __init__(self, name, payRate): self.name = name self.pay = payRate def __str__(self): return 'EmpName: ' + self.name + 'EmpPay: ' + str(self.pay) def gross_pay(self, hoursWorked): return self.pay * hoursWorked class Manager(Employee): def __init__...
def add_values(a, b, c=0, d=0): print(a + b + c + d) add_values(2, 3) add_values(2, 3, 4) add_values(2, 3, d=7) print("Ala ma kota", end=". \n") print("A kotek jest bury")
def add_values(a, b, c=0, d=0): print(a + b + c + d) add_values(2, 3) add_values(2, 3, 4) add_values(2, 3, d=7) print('Ala ma kota', end='. \n') print('A kotek jest bury')
# -*- coding: utf-8 -*- """ Author: Rafael R. L. Benevides Date: 15/11/2021 """ __version__ = '0.1.dev0' __author__ = 'Rafael R. L. Benevides' __email__ = 'rafaeluz821@gmail.com' __description__ = "Math tools for engineering" __url__ = 'https://github.com/RafaelLuz/jerimoon'
""" Author: Rafael R. L. Benevides Date: 15/11/2021 """ __version__ = '0.1.dev0' __author__ = 'Rafael R. L. Benevides' __email__ = 'rafaeluz821@gmail.com' __description__ = 'Math tools for engineering' __url__ = 'https://github.com/RafaelLuz/jerimoon'
card, sel_sum=map(int, input().split()) card_num=list(map(int, input().split())) max_count=0 for i in range(card): count=card_num[i] for j in range(i+1,card): j_count=count+card_num[j] for k in range(j+1,card): if j_count+card_num[k]>sel_sum: continue else...
(card, sel_sum) = map(int, input().split()) card_num = list(map(int, input().split())) max_count = 0 for i in range(card): count = card_num[i] for j in range(i + 1, card): j_count = count + card_num[j] for k in range(j + 1, card): if j_count + card_num[k] > sel_sum: c...
#!/usr/bin/python name = 'arkady' str1 = str(input('Please add first string: ')) str2 = str(input('Please add second string: ')) num = int(input('Please add number between 1 and 3 :')) while int(num < 0 or num > 3): if num > 3: print("Number is bigger then 3") else: print("Number is l...
name = 'arkady' str1 = str(input('Please add first string: ')) str2 = str(input('Please add second string: ')) num = int(input('Please add number between 1 and 3 :')) while int(num < 0 or num > 3): if num > 3: print('Number is bigger then 3') else: print('Number is lower then 0') num = int(i...
# https://www.codechef.com/problems/CHEFARRP for T in range(int(input())): n,c=int(input()),0 l=list(map(int,input().split())) for i in range(1,n): s,p=0,1 for j in range(i,-1,-1): s,p=s+l[j],p*l[j] if(s==p): c+=1 print(c+1)
for t in range(int(input())): (n, c) = (int(input()), 0) l = list(map(int, input().split())) for i in range(1, n): (s, p) = (0, 1) for j in range(i, -1, -1): (s, p) = (s + l[j], p * l[j]) if s == p: c += 1 print(c + 1)
name = input("What is your name? ") age = input("How old are you? ") city = input("Where are you live? ") print("This is {0}.".format(name)) print("It is {0}.".format(age)) print("S(he) live in {0}.".format(city))
name = input('What is your name? ') age = input('How old are you? ') city = input('Where are you live? ') print('This is {0}.'.format(name)) print('It is {0}.'.format(age)) print('S(he) live in {0}.'.format(city))
class Node(object): def __init__(self, data=None, next=None): self.data_ = data self.next_ = next def get_data(self): return self.data_ def set_data(self, data): self.data_ = data def get_next(self): return self.next_ def set_next(self, next)...
class Node(object): def __init__(self, data=None, next=None): self.data_ = data self.next_ = next def get_data(self): return self.data_ def set_data(self, data): self.data_ = data def get_next(self): return self.next_ def set_next(self, next): sel...
class SessionService: SESSION_LAST_SET_DUT_COMPANY_ID = 'last_set_dut_company_id' SESSION_LAST_SET_DUT_CATEGORY_ID = 'last_set_dut_category_id' SESSION_LAST_SET_DUT_LOCATION_ID = 'last_set_dut_location_id' SESSION_LAST_SET_TEMPLATE_COMPANY_ID = 'last_set_template_company_id' SESSION_LAST_SET_TEMPLA...
class Sessionservice: session_last_set_dut_company_id = 'last_set_dut_company_id' session_last_set_dut_category_id = 'last_set_dut_category_id' session_last_set_dut_location_id = 'last_set_dut_location_id' session_last_set_template_company_id = 'last_set_template_company_id' session_last_set_templat...
left={"w":4, "p":3, "b":2, "s":1} right={"m":4, "q":3, "d":2, "z":1} def alphabet_war(fight): if len(fight)==1: return "Left side wins!" if fight in "wpbs" else "Right side wins!" if fight in "mqdz" else "Let's fight again!" res="" for i,j in enumerate(fight): if j=="*": continue...
left = {'w': 4, 'p': 3, 'b': 2, 's': 1} right = {'m': 4, 'q': 3, 'd': 2, 'z': 1} def alphabet_war(fight): if len(fight) == 1: return 'Left side wins!' if fight in 'wpbs' else 'Right side wins!' if fight in 'mqdz' else "Let's fight again!" res = '' for (i, j) in enumerate(fight): if j == '*'...
# # Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: # # 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... # # By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued ter...
numbers = [1, 2] pairs = [] new = int() while new < 4000000: new = numbers[-1] + numbers[-2] if new > 4000000: break numbers.append(new) for i in numbers: if i % 2 == 0: pairs.append(i) print(sum(pairs))
# automatically generated by the FlatBuffers compiler, do not modify # namespace: enums class Frequency(object): Annual = 0 Bimonthly = 1 Biweekly = 2 Daily = 3 EveryFourthMonth = 4 EveryFourthWeek = 5 Monthly = 6 NoFrequency = 7 Once = 8 OtherFrequency = 9 Quarterly = 10 ...
class Frequency(object): annual = 0 bimonthly = 1 biweekly = 2 daily = 3 every_fourth_month = 4 every_fourth_week = 5 monthly = 6 no_frequency = 7 once = 8 other_frequency = 9 quarterly = 10 semiannual = 11 weekly = 12
text = input() result_string = [] digits = [int(i) for i in text if i.isdigit()] non_digits = [i for i in text if not i.isdigit()] take_list = [num for idx, num in enumerate(digits) if idx % 2 == 0] skip_list = [num for idx, num in enumerate(digits) if idx % 2 != 0] take_skip_list = list(zip(take_list, skip_list)) s...
text = input() result_string = [] digits = [int(i) for i in text if i.isdigit()] non_digits = [i for i in text if not i.isdigit()] take_list = [num for (idx, num) in enumerate(digits) if idx % 2 == 0] skip_list = [num for (idx, num) in enumerate(digits) if idx % 2 != 0] take_skip_list = list(zip(take_list, skip_list)) ...