content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
"""This program takes a score between 0.0 and 1.0 and returns an appropriate grade for score inputted""" try: grade = float(input('Enter your score: ')) if grade < 0.6: print('Your score', grade, 'is F') elif 0.6 <= grade <= 0.7: print('Your score', grade, 'is D') elif 0.7 <= grade <= 0....
"""This program takes a score between 0.0 and 1.0 and returns an appropriate grade for score inputted""" try: grade = float(input('Enter your score: ')) if grade < 0.6: print('Your score', grade, 'is F') elif 0.6 <= grade <= 0.7: print('Your score', grade, 'is D') elif 0.7 <= grade <= 0....
# You can gen a bcrypt hash here: ## http://bcrypthashgenerator.apphb.com/ pwhash = 'bcrypt' # You can generate salts and other secrets with openssl # For example: # $ openssl rand -hex 16 # 1ca632d8567743f94352545abe2e313d salt = "141202e6b20aa53596a339a0d0b92e79" secret_key = 'fe65757e00193b8bc2e18444fa51d87...
pwhash = 'bcrypt' salt = '141202e6b20aa53596a339a0d0b92e79' secret_key = 'fe65757e00193b8bc2e18444fa51d873' mongo_db = 'mydatabase' mongo_host = 'localhost' mongo_port = 27017 user_enable_registration = True user_enable_tracking = True user_from_email = 'noreply@yoursite.com' user_register_email_subject = 'Thank you fo...
#!/usr/bin/env python3 # -*- coding: utf-8 -*- def shell_sort(list_: list) -> list: """Returns a sorted list, by shell sort method :param list_: The list to be sorted :type list_: list :rtype: list :return: Sorted list, by shell sort method """ half = len(list_) // 2 while half > 0: ...
def shell_sort(list_: list) -> list: """Returns a sorted list, by shell sort method :param list_: The list to be sorted :type list_: list :rtype: list :return: Sorted list, by shell sort method """ half = len(list_) // 2 while half > 0: for i in range(half, len(list_)): ...
sbox = [ 0x63, 0x7C, 0x77, 0x7B, 0xF2, 0x6B, 0x6F, 0xC5, 0x30, 0x01, 0x67, 0x2B, 0xFE, 0xD7, 0xAB, 0x76, 0xCA, 0x82, 0xC9, 0x7D, 0xFA, 0x59, 0x47, 0xF0, 0xAD, 0xD4, 0xA2, 0xAF, 0x9C, 0xA4, 0x72, 0xC0, 0xB7, 0xFD, 0x93, 0x26, 0x36, 0x3F, 0xF7, 0xCC, 0x34, 0xA5, 0xE5, 0xF1, 0x71, 0xD8, 0x31, 0x15, 0x04, 0xC7, 0x23, 0...
sbox = [99, 124, 119, 123, 242, 107, 111, 197, 48, 1, 103, 43, 254, 215, 171, 118, 202, 130, 201, 125, 250, 89, 71, 240, 173, 212, 162, 175, 156, 164, 114, 192, 183, 253, 147, 38, 54, 63, 247, 204, 52, 165, 229, 241, 113, 216, 49, 21, 4, 199, 35, 195, 24, 150, 5, 154, 7, 18, 128, 226, 235, 39, 178, 117, 9, 131, 44, 26,...
""" Syntax Scoring https://adventofcode.com/2021/day/10 """ MATCHES = { '<': '>', '(': ')', '{': '}', '[': ']' } ERROR_SCORE = { ')': 3, ']': 57, '}': 1197, '>': 25137, } AUTOCOMPLETE_SCORE = { ')': 1, ']': 2, '}': 3, '>': 4, } def find_error(line): """returns ...
""" Syntax Scoring https://adventofcode.com/2021/day/10 """ matches = {'<': '>', '(': ')', '{': '}', '[': ']'} error_score = {')': 3, ']': 57, '}': 1197, '>': 25137} autocomplete_score = {')': 1, ']': 2, '}': 3, '>': 4} def find_error(line): """returns error score and remaining stack""" stack = [] for ch...
TAG_TYPE = "#type" TAG_XML = "#xml" TAG_VERSION = "@version" TAG_UIVERSION = "@uiVersion" TAG_NAMESPACE = "@xmlns" TAG_NAME = "@name" TAG_META = "meta" TAG_FORM = 'form' ATTACHMENT_NAME = "form.xml" MAGIC_PROPERTY = 'xml_submission_file' RESERVED_WORDS = [TAG_TYPE, TAG_XML, TAG_VERSION, TAG_UIVERSION, TAG_NAMESPA...
tag_type = '#type' tag_xml = '#xml' tag_version = '@version' tag_uiversion = '@uiVersion' tag_namespace = '@xmlns' tag_name = '@name' tag_meta = 'meta' tag_form = 'form' attachment_name = 'form.xml' magic_property = 'xml_submission_file' reserved_words = [TAG_TYPE, TAG_XML, TAG_VERSION, TAG_UIVERSION, TAG_NAMESPACE, TA...
def Merge_Sort(list): n= len(list) if n > 1 : mid = int(n/2) left =list[0:mid] right = list[mid:n] Merge_Sort(left) Merge_Sort(right) Merge (left, right, list) return list def Merge(left, right, list): i = 0 j = 0 k = 0 while i < len(left) a...
def merge__sort(list): n = len(list) if n > 1: mid = int(n / 2) left = list[0:mid] right = list[mid:n] merge__sort(left) merge__sort(right) merge(left, right, list) return list def merge(left, right, list): i = 0 j = 0 k = 0 while i < len(left...
#!python def merge(items1, items2): """Merge given lists of items, each assumed to already be in sorted order, and return a new list containing all items in sorted order. TODO: Running time: ??? Why and under what conditions? TODO: Memory usage: ??? Why and under what conditions?""" merge_list = ...
def merge(items1, items2): """Merge given lists of items, each assumed to already be in sorted order, and return a new list containing all items in sorted order. TODO: Running time: ??? Why and under what conditions? TODO: Memory usage: ??? Why and under what conditions?""" merge_list = [] index...
def default_copts(ignored = []): opts = [ "-std=c++20", "-Wall", "-Werror", "-Wextra", "-Wno-ignored-qualifiers", "-Wvla", ] ignored_map = {opt: opt for opt in ignored} return [opt for opt in opts if ignored_map.get(opt) == None]
def default_copts(ignored=[]): opts = ['-std=c++20', '-Wall', '-Werror', '-Wextra', '-Wno-ignored-qualifiers', '-Wvla'] ignored_map = {opt: opt for opt in ignored} return [opt for opt in opts if ignored_map.get(opt) == None]
{ "targets": [ { "target_name": "usb", "conditions": [ [ "OS==\"win\"", { "sources": [ "third_party/usb/src/win.cc" ], "librarie...
{'targets': [{'target_name': 'usb', 'conditions': [['OS=="win"', {'sources': ['third_party/usb/src/win.cc'], 'libraries': ['-lhid']}], ['OS=="linux"', {'sources': ['third_party/usb/src/linux.cc'], 'libraries': ['-ludev']}], ['OS=="mac"', {'sources': ['third_party/usb/src/mac.cc'], 'LDFLAGS': ['-framework IOKit', '-fram...
# Challenge 4 : Create a function named movie_review() that has one parameter named rating. # If rating is less than or equal to 5, return "Avoid at all costs!". # If rating is between 5 and 9, return "This one was fun.". # If rating is 9 or above, return "Outstanding!" # Date...
def movie_review(rating): if rating <= 5: return 'Avoid at all costs!' elif rating >= 5 and rating <= 9: return 'This one was fun.' elif rating >= 9: return 'Outstanding!' print(movie_review(9)) print(movie_review(4)) print(movie_review(6))
colors = {"clean": "\033[m", "red": "\033[31m", "green": "\033[32m", "yellow": "\033[33m", "blue": "\033[34m", "purple": "\033[35m", "cian": "\033[36m"} msg = "Hello World!!!" print("{}{}".format(colors["cian"], msg))
colors = {'clean': '\x1b[m', 'red': '\x1b[31m', 'green': '\x1b[32m', 'yellow': '\x1b[33m', 'blue': '\x1b[34m', 'purple': '\x1b[35m', 'cian': '\x1b[36m'} msg = 'Hello World!!!' print('{}{}'.format(colors['cian'], msg))
def difference(a, b): c = [] for el in a: if el not in b: c.append(el) return c ll = [1, 2, 3, 4, 5] ll2 = [4, 5, 6, 7, 8] # print(difference(ll, ll2)) # = CTRL + / set1 = {1, 2, 3, 4, 5} set2 = {4, 5, 6, 7, 8} set_difference = set1.difference(set2) # print(set_difference) # print(d...
def difference(a, b): c = [] for el in a: if el not in b: c.append(el) return c ll = [1, 2, 3, 4, 5] ll2 = [4, 5, 6, 7, 8] set1 = {1, 2, 3, 4, 5} set2 = {4, 5, 6, 7, 8} set_difference = set1.difference(set2)
# -- # File: a1000_consts.py # # Copyright (c) ReversingLabs Inc 2016-2018 # # This unpublished material is proprietary to ReversingLabs Inc. # All rights reserved. # Reproduction or distribution, in whole # or in part, is forbidden except by express written permission # of ReversingLabs Inc. # # -- A1000_JSON_BASE_UR...
a1000_json_base_url = 'base_url' a1000_json_task_id = 'task_id' a1000_json_api_key = 'api_key' a1000_json_malware = 'malware' a1000_json_task_id = 'id' a1000_json_vault_id = 'vault_id' a1000_json_url = 'url' a1000_json_hash = 'hash' a1000_json_platform = 'platform' a1000_json_poll_timeout_mins = 'timeout' a1000_err_una...
# Provided by Dr. Marzieh Ahmadzadeh & Nick Cheng. Edited by Yufei Cui class DNode(object): '''represents a node as a building block of a double linked list''' def __init__(self, element, prev_node=None, next_node=None): '''(Node, obj, Node, Node) -> NoneType construct a Dnode as building blo...
class Dnode(object): """represents a node as a building block of a double linked list""" def __init__(self, element, prev_node=None, next_node=None): """(Node, obj, Node, Node) -> NoneType construct a Dnode as building block of a double linked list""" self._element = element sel...
a = 256 b = 256 print(a is b) """ output:True """ c = 257 d = 257 print(id(c),id(d))
a = 256 b = 256 print(a is b) '\noutput:True\n' c = 257 d = 257 print(id(c), id(d))
class ProductLabels(object): def __init__(self, labels, labels_tags, labels_fr): self.Labels = labels self.LabelsTags = labels_tags self.LabelsFr = labels_fr def __str__(self): return self .Labels
class Productlabels(object): def __init__(self, labels, labels_tags, labels_fr): self.Labels = labels self.LabelsTags = labels_tags self.LabelsFr = labels_fr def __str__(self): return self.Labels
def dds_insert(d, s, p, o): if d.get(s) is None: d[s] = {} if d[s].get(p) is None: d[s][p] = set() d[s][p].add(o) def dds_remove(d, s, p, o): if d.get(s) is not None and d[s].get(p) is not None: d[s][p].remove(o) if not d[s][p]: del d[s][p] if not d[s]: del d[s] class JsonL...
def dds_insert(d, s, p, o): if d.get(s) is None: d[s] = {} if d[s].get(p) is None: d[s][p] = set() d[s][p].add(o) def dds_remove(d, s, p, o): if d.get(s) is not None and d[s].get(p) is not None: d[s][p].remove(o) if not d[s][p]: del d[s][p] if not...
# BGR colors WHITE = (255, 255, 255) BLACK = (0, 0, 0) GRAY25 = (64, 64, 64) GRAY50 = (128, 128, 128) GRAY75 = (192, 192, 192) GRAY33 = (85, 85, 85) GRAY66 = (170, 170, 170) BLUE = (255, 0, 0) GREEN = (0, 255, 0) RED = (0, 0, 255) CYAN = (255, 255, 0) MAGENTA = (255, 0, 255) YELLOW = (0, 255, 255) ORANGE = (0, 12...
white = (255, 255, 255) black = (0, 0, 0) gray25 = (64, 64, 64) gray50 = (128, 128, 128) gray75 = (192, 192, 192) gray33 = (85, 85, 85) gray66 = (170, 170, 170) blue = (255, 0, 0) green = (0, 255, 0) red = (0, 0, 255) cyan = (255, 255, 0) magenta = (255, 0, 255) yellow = (0, 255, 255) orange = (0, 128, 255) purple = (2...
class Node(object): value = None left_child = None right_child = None def __init__(self, value, left=None, right=None): self.value = value if left: self.left_child = left if right: self.right_child = right def __str__(self): return self.value...
class Node(object): value = None left_child = None right_child = None def __init__(self, value, left=None, right=None): self.value = value if left: self.left_child = left if right: self.right_child = right def __str__(self): return self.value...
# START LAB EXERCISE 04 print('Lab Exercise 04 \n') # SETUP city_state = ["Detroit|MI", "Philadelphia|PA", "Hollywood|CA", "Oakland|CA", "Boston|MA", "Atlanta|GA", "Phoenix|AZ", "Birmingham|AL", "Houston|TX", "Tampa|FL"] # END SETUP # PROBLEM 1.0 (5 Points) # PROBLEM 2.0 (5 Points) # PROBL...
print('Lab Exercise 04 \n') city_state = ['Detroit|MI', 'Philadelphia|PA', 'Hollywood|CA', 'Oakland|CA', 'Boston|MA', 'Atlanta|GA', 'Phoenix|AZ', 'Birmingham|AL', 'Houston|TX', 'Tampa|FL']
# -*- coding: utf-8 -*- string1 = "Becomes" string2 = "becomes" string3 = "BEAR" string4 = " bEautiful" string1 = string1.lower() # (string2 will pass unmodified) string3 = string3.lower() string4 = string4.strip().lower() print(string1.startswith("be")) print(string2.startswith("be")) print(string3.startswith("be")) p...
string1 = 'Becomes' string2 = 'becomes' string3 = 'BEAR' string4 = ' bEautiful' string1 = string1.lower() string3 = string3.lower() string4 = string4.strip().lower() print(string1.startswith('be')) print(string2.startswith('be')) print(string3.startswith('be')) print(string4.startswith('be'))
class Node(object): def __init__(self, data=None, left=None, right=None): self.data = data self.left = left self.right = right class BinarySearchTree(object): def __init__(self, root=None): self.root = root def get_root(self): return self.root def insert(self,...
class Node(object): def __init__(self, data=None, left=None, right=None): self.data = data self.left = left self.right = right class Binarysearchtree(object): def __init__(self, root=None): self.root = root def get_root(self): return self.root def insert(self...
input = """af AND ah -> ai NOT lk -> ll hz RSHIFT 1 -> is NOT go -> gp du OR dt -> dv x RSHIFT 5 -> aa at OR az -> ba eo LSHIFT 15 -> es ci OR ct -> cu b RSHIFT 5 -> f fm OR fn -> fo NOT ag -> ah v OR w -> x g AND i -> j an LSHIFT 15 -> ar 1 AND cx -> cy jq AND jw -> jy iu RSHIFT 5 -> ix gl AND gm -> go NOT bw -> bx jp...
input = 'af AND ah -> ai\nNOT lk -> ll\nhz RSHIFT 1 -> is\nNOT go -> gp\ndu OR dt -> dv\nx RSHIFT 5 -> aa\nat OR az -> ba\neo LSHIFT 15 -> es\nci OR ct -> cu\nb RSHIFT 5 -> f\nfm OR fn -> fo\nNOT ag -> ah\nv OR w -> x\ng AND i -> j\nan LSHIFT 15 -> ar\n1 AND cx -> cy\njq AND jw -> jy\niu RSHIFT 5 -> ix\ngl AND gm -> go...
# -*- coding: utf-8 -*- # Copyright 2021 Cohesity Inc. class CentrifySchemaEnum(object): """Implementation of the 'CentrifySchema' enum. Specifies the schema of this Centrify zone. The below list of schemas and their values are taken from the document Centrify Server Suite 2016 Windows API Programmer...
class Centrifyschemaenum(object): """Implementation of the 'CentrifySchema' enum. Specifies the schema of this Centrify zone. The below list of schemas and their values are taken from the document Centrify Server Suite 2016 Windows API Programmer's Guide https://docs.centrify.com/en/css/suite2016/c...
def ask_question(): print("Who is the founder of Facebook?") option=["Mark Zuckerberg","Bill Gates","Steve Jobs","Larry Page"] for i in option: print(i) ask_question() i=0 while i<100: ask_question() i+=1 def say_hello(name): print ("Hello ", name) print ("Aap kaise ho?") say_hello("jai") def a...
def ask_question(): print('Who is the founder of Facebook?') option = ['Mark Zuckerberg', 'Bill Gates', 'Steve Jobs', 'Larry Page'] for i in option: print(i) ask_question() i = 0 while i < 100: ask_question() i += 1 def say_hello(name): print('Hello ', name) print('Aap kaise ho?') s...
input_file = open("input.txt","r") lines = input_file.readlines() count = 0 answers = set() for line in lines: if line == "\n": count += len(answers) print(answers) answers.clear() for character in line: #print(character) if character != "\n": answers.add(cha...
input_file = open('input.txt', 'r') lines = input_file.readlines() count = 0 answers = set() for line in lines: if line == '\n': count += len(answers) print(answers) answers.clear() for character in line: if character != '\n': answers.add(character) count += len(answe...
class BankAccount: def __init__(self): self.accountNum = 0 self.accountOwner = "" self.accountBalance = 0.00 def ModifyAccount(self, id, name, balance): self.accountNum = id self.accountOwner = name self.accountBalance = balance account = BankAccount() acco...
class Bankaccount: def __init__(self): self.accountNum = 0 self.accountOwner = '' self.accountBalance = 0.0 def modify_account(self, id, name, balance): self.accountNum = id self.accountOwner = name self.accountBalance = balance account = bank_account() account....
# Tai Sakuma <tai.sakuma@gmail.com> ##__________________________________________________________________|| def expand_path_cfg(path_cfg, alias_dict={ }, overriding_kargs={ }): """expand a path config Args: path_cfg (str, tuple, dict): a config for path alias_dict (dict): a dict for aliases ...
def expand_path_cfg(path_cfg, alias_dict={}, overriding_kargs={}): """expand a path config Args: path_cfg (str, tuple, dict): a config for path alias_dict (dict): a dict for aliases overriding_kargs (dict): to be used for recursive call """ if isinstance(path_cfg, str): ...
class Solution: def maxDepth(self, root): if root is None: return 0 return 1 + max(self.maxDepth(root.left), self.maxDepth(root.right))
class Solution: def max_depth(self, root): if root is None: return 0 return 1 + max(self.maxDepth(root.left), self.maxDepth(root.right))
""" Extension 3 (ext3) Used primarily for concurrent Linux systems (ext2 + journalling) """
""" Extension 3 (ext3) Used primarily for concurrent Linux systems (ext2 + journalling) """
lis = [] for i in range (10): num = int(input()) lis.append(num) print(lis) for i in range (len(lis)): print(lis[i])
lis = [] for i in range(10): num = int(input()) lis.append(num) print(lis) for i in range(len(lis)): print(lis[i])
n = int(input('enter number to find the factorial: ')) fact=1; for i in range(1,n+1,1): fact=fact*i print(fact)
n = int(input('enter number to find the factorial: ')) fact = 1 for i in range(1, n + 1, 1): fact = fact * i print(fact)
"""Configuration package. This package handle all information that could be given to pycodeanalyzer in the configuration. """
"""Configuration package. This package handle all information that could be given to pycodeanalyzer in the configuration. """
Automoviles=['Dodge Challeger', 'VW Gti', 'Jeep Rubicon', 'Alfa Romeo Quadro', 'Ford ST', 'Dodge RAM', 'Ford FX4'] M1="Me gustaria compar un " + Automoviles[0].title()+"." M2="Mi vecino choco su nuevo " + Automoviles[1].title() + "." M3="El nuevo " + Automoviles[2].title()+ " es mucho mas economico." M4="Hay una gran d...
automoviles = ['Dodge Challeger', 'VW Gti', 'Jeep Rubicon', 'Alfa Romeo Quadro', 'Ford ST', 'Dodge RAM', 'Ford FX4'] m1 = 'Me gustaria compar un ' + Automoviles[0].title() + '.' m2 = 'Mi vecino choco su nuevo ' + Automoviles[1].title() + '.' m3 = 'El nuevo ' + Automoviles[2].title() + ' es mucho mas economico.' m4 = 'H...
class Stock: def __init__(self, symbol, name): self.__name = name self.__symbol = symbol self.__stockPlate = [] self.__carePlate = [] @property def name(self): return self.__name @property def symbol(self): return self.__symbol @property def...
class Stock: def __init__(self, symbol, name): self.__name = name self.__symbol = symbol self.__stockPlate = [] self.__carePlate = [] @property def name(self): return self.__name @property def symbol(self): return self.__symbol @property de...
#Programa para evaluar si un numero es feliz numero_a_evaluar = input("Introduce el numero a evaluar: ") n = numero_a_evaluar suma = 2 primer_digito = 0 segundo_digito = 0 tercer_digito = 0 cuarto_digito = 0 while suma > 1: primer_digito = numero_a_evaluar[0] primer_digito = int(primer_digito) print(prim...
numero_a_evaluar = input('Introduce el numero a evaluar: ') n = numero_a_evaluar suma = 2 primer_digito = 0 segundo_digito = 0 tercer_digito = 0 cuarto_digito = 0 while suma > 1: primer_digito = numero_a_evaluar[0] primer_digito = int(primer_digito) print(primer_digito) try: segundo_digito = num...
# -*- coding: utf-8 -*- # Copyright 2018, IBM. # # This source code is licensed under the Apache License, Version 2.0 found in # the LICENSE.txt file in the root directory of this source tree. """ A property set is maintained by the PassManager to keep information about the current state of the circuit """ class Pr...
""" A property set is maintained by the PassManager to keep information about the current state of the circuit """ class Propertyset(dict): """ A default dictionary-like object """ def __missing__(self, key): return None
def read_label_pbtxt(label_path: str) -> dict: with open(label_path, "r") as label_file: lines = label_file.readlines() labels = {} for row, content in enumerate(lines): labels[row] = {"id": row, "name": content.strip()} return labels
def read_label_pbtxt(label_path: str) -> dict: with open(label_path, 'r') as label_file: lines = label_file.readlines() labels = {} for (row, content) in enumerate(lines): labels[row] = {'id': row, 'name': content.strip()} return labels
co2 = input("Please input air quality value: ") co2 = int(co2) if co2 > 399 and co2 < 698: print("Excelent") elif co2 > 699 and co2 < 898: print("Good") elif co2 > 899 and co2 < 1098: print("Fair") elif co2 > 1099 and co2 < 1598: print("Mediocre, contaminated indoor air") elif co2 > 1599 and c...
co2 = input('Please input air quality value: ') co2 = int(co2) if co2 > 399 and co2 < 698: print('Excelent') elif co2 > 699 and co2 < 898: print('Good') elif co2 > 899 and co2 < 1098: print('Fair') elif co2 > 1099 and co2 < 1598: print('Mediocre, contaminated indoor air') elif co2 > 1599 and co2 < 2101:...
# AUTOGENERATED BY NBDEV! DO NOT EDIT! __all__ = ["index", "modules", "custom_doc_links", "git_url"] index = {"GH_HOST": "00_core.ipynb", "GhApi": "00_core.ipynb", "date2gh": "00_core.ipynb", "gh2date": "00_core.ipynb", "print_summary": "00_core.ipynb", "GhApi.delete_relea...
__all__ = ['index', 'modules', 'custom_doc_links', 'git_url'] index = {'GH_HOST': '00_core.ipynb', 'GhApi': '00_core.ipynb', 'date2gh': '00_core.ipynb', 'gh2date': '00_core.ipynb', 'print_summary': '00_core.ipynb', 'GhApi.delete_release': '00_core.ipynb', 'GhApi.upload_file': '00_core.ipynb', 'GhApi.create_release': '0...
def wypisz(par1, par2): print('{0} {1}'.format(par1, par2)) def sprawdz(arg1, arg2): if arg1 > arg2: return True else: return False
def wypisz(par1, par2): print('{0} {1}'.format(par1, par2)) def sprawdz(arg1, arg2): if arg1 > arg2: return True else: return False
ce,nll=input("<<") lx=ce*(nll/1200) print("The interest is",lx)
(ce, nll) = input('<<') lx = ce * (nll / 1200) print('The interest is', lx)
class Edge: def __init__(self, src, dst, line): self.src = src self.dst = dst self.line = line assert src != dst, f"Source and destination are the same!" def reverse(self): return Edge(self.dst, self.src, self.line.reverse()) def to_dict(self): return { ...
class Edge: def __init__(self, src, dst, line): self.src = src self.dst = dst self.line = line assert src != dst, f'Source and destination are the same!' def reverse(self): return edge(self.dst, self.src, self.line.reverse()) def to_dict(self): return {'src...
def to_url_representation(path: str) -> str: """Convert path to a representation that can be used in urls/queries""" return path.replace("_", "-_-").replace("/", "__") def from_url_representation(url_rep: str) -> str: """Reconvert url representation of path to actual path""" return url_rep.replace("__...
def to_url_representation(path: str) -> str: """Convert path to a representation that can be used in urls/queries""" return path.replace('_', '-_-').replace('/', '__') def from_url_representation(url_rep: str) -> str: """Reconvert url representation of path to actual path""" return url_rep.replace('__'...
with open('log', 'r') as logfile: for line in logfile: if line.__contains__('LOG'): print(line) #pvahdatn@cs-arch-20:~/git/dandelion-lib$ sbt "testOnly dataflow.test03Tester" > log
with open('log', 'r') as logfile: for line in logfile: if line.__contains__('LOG'): print(line)
''' Write a function to delete a node (except the tail) in a singly linked list, given only access to that node. Given linked list -- head = [4,5,1,9], which looks like following: Example 1: Input: head = [4,5,1,9], node = 5 Output: [4,1,9] Explanation: You are given the second node with value 5, the linked list s...
""" Write a function to delete a node (except the tail) in a singly linked list, given only access to that node. Given linked list -- head = [4,5,1,9], which looks like following: Example 1: Input: head = [4,5,1,9], node = 5 Output: [4,1,9] Explanation: You are given the second node with value 5, the linked list s...
class SortStrategy: def sort(self, dataset): pass class BubbleSortStrategy(SortStrategy): def sort(self, dataset): print('Sorting using bubble sort') return dataset class QuickSortStrategy(SortStrategy): def sort(self, dataset): print('Sorting using quick sort') re...
class Sortstrategy: def sort(self, dataset): pass class Bubblesortstrategy(SortStrategy): def sort(self, dataset): print('Sorting using bubble sort') return dataset class Quicksortstrategy(SortStrategy): def sort(self, dataset): print('Sorting using quick sort') ...
''' BF C(n,k)*n O(n!) LeetCode 516 DP find the longest palindrome sequence O(n^2) ''' class Solution: def isValidPalindrome(self, s: str, k: int) -> bool: n = len(str) dp = [[0]*n for _ in range(n)] for i in range(n-2, -1, -1): dp[i][i] = 1 for j in range(i+1, n)...
""" BF C(n,k)*n O(n!) LeetCode 516 DP find the longest palindrome sequence O(n^2) """ class Solution: def is_valid_palindrome(self, s: str, k: int) -> bool: n = len(str) dp = [[0] * n for _ in range(n)] for i in range(n - 2, -1, -1): dp[i][i] = 1 for j in range(i...
def calcula_se_um_numero_eh_par(numero): if type(numero) == int: if numero % 2 == 0: return True return False
def calcula_se_um_numero_eh_par(numero): if type(numero) == int: if numero % 2 == 0: return True return False
class StompError(Exception): def __init__(self, message, detail): super(StompError, self).__init__(message) self.detail = detail class StompDisconnectedError(Exception): pass class ExceededRetryCount(Exception): pass
class Stomperror(Exception): def __init__(self, message, detail): super(StompError, self).__init__(message) self.detail = detail class Stompdisconnectederror(Exception): pass class Exceededretrycount(Exception): pass
""" BiNode: Consider a simple data structure called BiNode, which has pointers to two other nodes. The data structure BiNode could be used to represent both a binary tree (where nodel is the left node and node2 is the right node) or a doubly linked list (where nodel is the previous node and node2 is the next node)....
""" BiNode: Consider a simple data structure called BiNode, which has pointers to two other nodes. The data structure BiNode could be used to represent both a binary tree (where nodel is the left node and node2 is the right node) or a doubly linked list (where nodel is the previous node and node2 is the next node). Imp...
class ParticleDataAccessor(object): """ This class provides access to the underlying data model. """ LINE_STYLE_SOLID = 0 LINE_STYLE_DASH = 1 LINE_STYLE_WAVE = 2 LINE_STYLE_SPIRAL = 3 LINE_VERTEX = 4 def id(self, object): """ Returns an id to identify given object. ...
class Particledataaccessor(object): """ This class provides access to the underlying data model. """ line_style_solid = 0 line_style_dash = 1 line_style_wave = 2 line_style_spiral = 3 line_vertex = 4 def id(self, object): """ Returns an id to identify given object. ...
description = 'setup for the NICOS collector' group = 'special' devices = dict( CacheKafka=device( 'nicos_ess.devices.cache_kafka_forwarder.CacheKafkaForwarder', dev_ignore=['space', 'sample'], brokers=configdata('config.KAFKA_BROKERS'), output_topic="nicos_cache", update_int...
description = 'setup for the NICOS collector' group = 'special' devices = dict(CacheKafka=device('nicos_ess.devices.cache_kafka_forwarder.CacheKafkaForwarder', dev_ignore=['space', 'sample'], brokers=configdata('config.KAFKA_BROKERS'), output_topic='nicos_cache', update_interval=10.0), Collector=device('nicos.services....
class Solution: def kLengthApart(self, nums: List[int], k: int) -> bool: if 1 not in nums: return True start, end = nums.index(1), nums.index(1)+1 while end < len(nums): if nums[start] == 1 and nums[end] == 1 and end - start <= k: return False elif num...
class Solution: def k_length_apart(self, nums: List[int], k: int) -> bool: if 1 not in nums: return True (start, end) = (nums.index(1), nums.index(1) + 1) while end < len(nums): if nums[start] == 1 and nums[end] == 1 and (end - start <= k): return Fal...
""" This module contains all notification payload objects.""" class BaseMsg(dict): """The BaseClass of all objects in notification payload.""" apns_keys = [] def __init__(self, custom_fields={}, **apn_args): super(BaseMsg, self).__init__(custom_fields, **apn_args) if custom_fields: ...
""" This module contains all notification payload objects.""" class Basemsg(dict): """The BaseClass of all objects in notification payload.""" apns_keys = [] def __init__(self, custom_fields={}, **apn_args): super(BaseMsg, self).__init__(custom_fields, **apn_args) if custom_fields: ...
# Copyright https://www.globaletraining.com/ # List comprehensions provide a concise way to create lists. my_list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] def main(): final_list = [] for n in my_list: final_list.append(n + 10) print(final_list) # TODO: Using Comprehension final_list_comp1 = [n...
my_list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] def main(): final_list = [] for n in my_list: final_list.append(n + 10) print(final_list) final_list_comp1 = [n + 10 for n in my_list] print(final_list_comp1) final_list_comp2 = [n + 10 for n in my_list if n % 2 == 0] print(final_list_comp2)...
"""Win animation frames for Mystery Mansion. Animation from: http://www.angelfire.com/ca/mathcool/fireworks.html """ win_animation = [ """ .| | | |'| ._____ ___ | | |. |' .---"| _ .-' ...
"""Win animation frames for Mystery Mansion. Animation from: http://www.angelfire.com/ca/mathcool/fireworks.html """ win_animation = ['\n\n\n\n\n .|\n | |\n |\'| ._____\n ___ | | |. |\' .---"|\n _ ....
#!/usr/local/bin/python3 def main(): for i in range(1, 8): print("============================") print("Towers of Hanoi: {} Disks".format(i)) towers_of_hanoi(i) print("Number of moves: {}".format(2**i - 1)) print("============================") return 0 def towers_of...
def main(): for i in range(1, 8): print('============================') print('Towers of Hanoi: {} Disks'.format(i)) towers_of_hanoi(i) print('Number of moves: {}'.format(2 ** i - 1)) print('============================') return 0 def towers_of_hanoi(n, s='source', t='ta...
def domino(): """Imprime todas las fichas de domino""" a = 0 b = 0 for k in range (0,7): a = k for i in range (a, 7): b = i print (a, b)
def domino(): """Imprime todas las fichas de domino""" a = 0 b = 0 for k in range(0, 7): a = k for i in range(a, 7): b = i print(a, b)
# -*- coding: utf-8 -*- """PACKAGE INFO This module provides some basic information about the package. """ # Set the package release version version_info = (0, 0, 0) __version__ = '.'.join(str(c) for c in version_info) # Set the package details __author__ = 'Jonah Crawford' __email__ = 'jonah.crawford@icloud.com' ...
"""PACKAGE INFO This module provides some basic information about the package. """ version_info = (0, 0, 0) __version__ = '.'.join((str(c) for c in version_info)) __author__ = 'Jonah Crawford' __email__ = 'jonah.crawford@icloud.com' __year__ = '2019' __url__ = 'https://github.com/minskmaz/dckrclstrpanic' __descriptio...
# generated from genmsg/cmake/pkg-genmsg.context.in messages_str = "/home/tekmen0/meturone_egitim/src/meturone_egitim/msg/Dummy.msg;/home/tekmen0/meturone_egitim/src/meturone_egitim/msg/answer.msg" services_str = "" pkg_name = "meturone_egitim" dependencies_str = "std_msgs" langs = "gencpp;geneus;genlisp;gennodejs;gen...
messages_str = '/home/tekmen0/meturone_egitim/src/meturone_egitim/msg/Dummy.msg;/home/tekmen0/meturone_egitim/src/meturone_egitim/msg/answer.msg' services_str = '' pkg_name = 'meturone_egitim' dependencies_str = 'std_msgs' langs = 'gencpp;geneus;genlisp;gennodejs;genpy' dep_include_paths_str = 'meturone_egitim;/home/te...
XK_Greek_ALPHAaccent = 0x7a1 XK_Greek_EPSILONaccent = 0x7a2 XK_Greek_ETAaccent = 0x7a3 XK_Greek_IOTAaccent = 0x7a4 XK_Greek_IOTAdiaeresis = 0x7a5 XK_Greek_OMICRONaccent = 0x7a7 XK_Greek_UPSILONaccent = 0x7a8 XK_Greek_UPSILONdieresis = 0x7a9 XK_Greek_OMEGAaccent = 0x7ab XK_Greek_accentdieresis = 0x7ae XK_Greek...
xk__greek_alph_aaccent = 1953 xk__greek_epsilo_naccent = 1954 xk__greek_et_aaccent = 1955 xk__greek_iot_aaccent = 1956 xk__greek_iot_adiaeresis = 1957 xk__greek_omicro_naccent = 1959 xk__greek_upsilo_naccent = 1960 xk__greek_upsilo_ndieresis = 1961 xk__greek_omeg_aaccent = 1963 xk__greek_accentdieresis = 1966 xk__greek...
#moveable_player class MoveablePlayer: def __init__(self, x=2, y=2, dir="FORWARD", color="170"): self.x = x self.y = y self.direction = dir self.color = color
class Moveableplayer: def __init__(self, x=2, y=2, dir='FORWARD', color='170'): self.x = x self.y = y self.direction = dir self.color = color
# ============================================================================================= # # ============================================================================================= # # 2 16 20 3 4 21 # GPIO Pin number # | | | | | | # --...
digits = [2, 3, 4, 17] one = [2] two = [3] three = [4] four = [17]
# -*- coding: utf-8 -*- class Trial(object): ''' Created Fri 2 Aug 2013 - ajl Last edited: Sun 4 Aug 2013 - ajl This class contains all variables and methods associated with a single trial ''' def __init__(self, trialid = 0, staircaseid = 0, conditi...
class Trial(object): """ Created Fri 2 Aug 2013 - ajl Last edited: Sun 4 Aug 2013 - ajl This class contains all variables and methods associated with a single trial """ def __init__(self, trialid=0, staircaseid=0, condition=0, stimval=0, interval=1): """ Constr...
## Q2: What is the time complexity of ## O(n), porque es un for de i=n hasta i=1 # Algoritmo # for (i = n; i > 0; i--) { # n # statement; # 1 # } n = 5 for i in range(n, 0, -1): # n print(i); # 1
n = 5 for i in range(n, 0, -1): print(i)
# pylint: disable=redefined-outer-name,protected-access # pylint: disable=missing-function-docstring,missing-module-docstring,missing-class-docstring def test_can_construct_author(author): assert isinstance(author.name, str) assert isinstance(author.url, str) assert isinstance(author.github_url, str)...
def test_can_construct_author(author): assert isinstance(author.name, str) assert isinstance(author.url, str) assert isinstance(author.github_url, str) assert isinstance(author.github_avatar_url, str) assert str(author) == author.name assert repr(author) == author.name assert author._repr_ht...
# ------------------------------------------------------------------------------ # Program: The LDAR Simulator (LDAR-Sim) # File: LDAR-Sim input mapper sample # Purpose: Example input mapper # # Copyright (C) 2018-2021 Intelligent Methane Monitoring and Management System (IM3S) Group # # This program is...
def input_mapper_v1(parameters): """Function to perform all input mapping from version 1.0 parameter files to presently compliant parameter files. This is necessary to ensure reverse compatibility - to allow older parameter files to run properly. **** THIS IS AN EXAMPLE FILE THAT IS PROVIDED AS A TEMPL...
#%% VARIABLES 'Variables' # var1 = 10 # var2 = "Hello World" # var3 = None # var4 = 3.5 # if 0: # print ("hello world 0") #el 0 fnciona como Falsey # if 1: # print ("hello world 1") #el 1 funciona como Truthy # x1 = 100 # x2 = 20 # x3 = -5 # y = x1 + x2 + x3 # z = x1 - x2 * x3 # w = (x1+x2+x3) - (x1-...
"""Variables""" 'Actividad 1' a = 50 b = 6 c = 8 d = 2 * a + 1 / (b - 5 * c) d1 = ((a * b + c) / (2 - a) + ((a * b + c) / (2 - a) + 2) / (c + b)) * (1 + (a * b + c) / (2 - a)) 'Actividad 2' word0 = 'Mars' word1 = 'Earth' word2 = 'round' word3 = 'round' word4 = word0 + ' is like the ' + word1 + ', it goes ' + word2 + ' ...
# Given inorder and postorder traversal of a tree, construct the binary tree. # Note: # You may assume that duplicates do not exist in the tree. # For example, given # inorder = [9,3,15,20,7] # postorder = [9,15,7,20,3] # Return the following binary tree: # 3 # / \ # 9 20 # / \ # 15 7 # Definit...
class Solution(object): def build_tree(self, inorder, postorder): """ :type inorder: List[int] :type postorder: List[int] :rtype: TreeNode """ if not inorder or not postorder or len(inorder) == 0 or (len(postorder) == 0): return None else: ...
# Copyright 2015 Google Inc. 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 law or ...
""" Help text and other strings used in the Drive module. """ __author__ = ['nretallack@google.com (Nick Retallack)'] service_account_json_description = '\nCreate a service account in Google App Engine and paste the JSON here.\n' service_account_json_parse_failure = '\nThe JSON is invalid. Make sure you copy the whole...
# Time: O(m * n) # Space: O(1) class Solution(object): def findDiagonalOrder(self, matrix): """ :type matrix: List[List[int]] :rtype: List[int] """ if not matrix or not matrix[0]: return [] result = [] row, col, d = 0, 0, 0 dirs = [(-1, ...
class Solution(object): def find_diagonal_order(self, matrix): """ :type matrix: List[List[int]] :rtype: List[int] """ if not matrix or not matrix[0]: return [] result = [] (row, col, d) = (0, 0, 0) dirs = [(-1, 1), (1, -1)] for i ...
class PingPacket: def __init__(self): self.type = "PING" self.serial = 0 def read(self, reader): self.serial = reader.readInt32()
class Pingpacket: def __init__(self): self.type = 'PING' self.serial = 0 def read(self, reader): self.serial = reader.readInt32()
n = int(input()) for teste in range(n): m = int(input()) lista = [int(x) for x in input().split()] impares = [] for x in lista: if x%2 == 1: impares.append(x) impares.sort() laercio = [] while len(impares) > 0: laercio.append(impares.pop()) i...
n = int(input()) for teste in range(n): m = int(input()) lista = [int(x) for x in input().split()] impares = [] for x in lista: if x % 2 == 1: impares.append(x) impares.sort() laercio = [] while len(impares) > 0: laercio.append(impares.pop()) impares.rever...
# -------------------------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # --------------------------------------------------------------------...
class Projectfailed(object): def __init__(self, message): self.valid = False self.message = message
"""Define nodejs and yarn dependencies""" load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( name = "build_bazel_rules_nodejs", sha256 = "a09edc4ba3931a856a5ac6836f248c302d55055d35d36e390a0549799c33145b", urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download...
"""Define nodejs and yarn dependencies""" load('@bazel_tools//tools/build_defs/repo:http.bzl', 'http_archive') http_archive(name='build_bazel_rules_nodejs', sha256='a09edc4ba3931a856a5ac6836f248c302d55055d35d36e390a0549799c33145b', urls=['https://github.com/bazelbuild/rules_nodejs/releases/download/5.0.0/rules_nodejs-5...
class Matrix: def __init__(self, *args, **kwargs): if len(args) > 0: if isinstance(args[0], Matrix): m = args[0].copy() else: m = {'vals': [], 'w': 0, 'h': 0} self.vals = m.vals self.w = m.w self.h = m.h def copy(self): new_m = Matrix() for i in self.vals: new...
class Matrix: def __init__(self, *args, **kwargs): if len(args) > 0: if isinstance(args[0], Matrix): m = args[0].copy() else: m = {'vals': [], 'w': 0, 'h': 0} self.vals = m.vals self.w = m.w self.h = m.h def copy(self): ne...
# # @lc app=leetcode id=67 lang=python3 # # [67] Add Binary # # @lc code=start class Solution: def addBinary(self, a: str, b: str) -> str: m = len(a) n = len(b) i = m - 1 j = n - 1 extra = 0 res = '' while i >=0 or j >= 0: if i < 0: ...
class Solution: def add_binary(self, a: str, b: str) -> str: m = len(a) n = len(b) i = m - 1 j = n - 1 extra = 0 res = '' while i >= 0 or j >= 0: if i < 0: x = int(b[j]) + extra elif j < 0: x = int(a[i])...
def test(): # if an assertion fails, the message will be displayed # --> must have the output in a comment assert "Mean: 5.0" in __solution__, "Did you record the correct program output as a comment?" # --> must have the output in a comment assert "Mean: 4.0" in __solution__, "Did you record the cor...
def test(): assert 'Mean: 5.0' in __solution__, 'Did you record the correct program output as a comment?' assert 'Mean: 4.0' in __solution__, 'Did you record the correct program output as a comment?' assert 'mean(numbers_one)' in __solution__, 'Did you call the mean function with numbers_one as input?' ...
# 17. Distinct strings in the first column # Find distinct strings (a set of strings) of the first column of the file. Confirm the result by using cut, sort, and uniq commands. def removeDuplicates(list): newList = [] for i in list: if not(i in newList): newList.append(i) return...
def remove_duplicates(list): new_list = [] for i in list: if not i in newList: newList.append(i) return newList with open('popular-names.txt') as f: first_column = [] lines = f.readlines() for i in lines: line_array = i.split('\t') firstColumn.append(lineArray...
name = input("Enter your name: ") date = input("Enter a date: ") adjective = input("Enter an adjective: ") noun = input("Enter a noun: ") verb = input("Enter a verb in past tense: ") adverb = input("Enter an adverb: ") adjective = input("Enter another adjective: ") noun = input("Enter another noun: ") noun = input("Ent...
name = input('Enter your name: ') date = input('Enter a date: ') adjective = input('Enter an adjective: ') noun = input('Enter a noun: ') verb = input('Enter a verb in past tense: ') adverb = input('Enter an adverb: ') adjective = input('Enter another adjective: ') noun = input('Enter another noun: ') noun = input('Ent...
input=__import__('sys').stdin.readline n,m=map(int,input().split());g=[list(input()) for _ in range(n)];c=[[0]*m for _ in range(n)] q=__import__('collections').deque();q.append((0,0));c[0][0]=1 while q: x,y=q.popleft() for nx,ny in (x+1,y),(x-1,y),(x,y+1),(x,y-1): if 0<=nx<n and 0<=ny<m and g[nx][ny]=='...
input = __import__('sys').stdin.readline (n, m) = map(int, input().split()) g = [list(input()) for _ in range(n)] c = [[0] * m for _ in range(n)] q = __import__('collections').deque() q.append((0, 0)) c[0][0] = 1 while q: (x, y) = q.popleft() for (nx, ny) in ((x + 1, y), (x - 1, y), (x, y + 1), (x, y - 1)): ...
# normalize data 0-1 def normalize(data): normalized = [] for i in range(len(data[0])): col_min = min([item[i] for item in data]) col_max = max([item[i] for item in data]) for q, item in enumerate([item[i] for item in data]): if len(normalized) > q: normal...
def normalize(data): normalized = [] for i in range(len(data[0])): col_min = min([item[i] for item in data]) col_max = max([item[i] for item in data]) for (q, item) in enumerate([item[i] for item in data]): if len(normalized) > q: normalized[q].append((item - ...
''' You are given a linked list with one pointer of each node pointing to the next node just like the usual. Every node, however, also has a second pointer that can point to any node in the list. Now write a program to deep copy this list. Solution 1: First backup all the nodes' next pointers node to another array. n...
""" You are given a linked list with one pointer of each node pointing to the next node just like the usual. Every node, however, also has a second pointer that can point to any node in the list. Now write a program to deep copy this list. Solution 1: First backup all the nodes' next pointers node to another array. n...
class PointCloudObject(RhinoObject): # no doc def DuplicatePointCloudGeometry(self): """ DuplicatePointCloudGeometry(self: PointCloudObject) -> PointCloud """ pass PointCloudGeometry=property(lambda self: object(),lambda self,v: None,lambda self: None) """Get: PointCloudGeometry(self: PointCloudObject) ->...
class Pointcloudobject(RhinoObject): def duplicate_point_cloud_geometry(self): """ DuplicatePointCloudGeometry(self: PointCloudObject) -> PointCloud """ pass point_cloud_geometry = property(lambda self: object(), lambda self, v: None, lambda self: None) 'Get: PointCloudGeometry(self: PointC...
''' Kattis - lineup Compare list with the sorted version of the list. Time: O(n log n), Space: O(n) ''' n = int(input()) arr = [input() for _ in range(n)] if arr == sorted(arr): print("INCREASING") elif arr == sorted(arr, reverse=True): print("DECREASING") else: print("NEITHER")
""" Kattis - lineup Compare list with the sorted version of the list. Time: O(n log n), Space: O(n) """ n = int(input()) arr = [input() for _ in range(n)] if arr == sorted(arr): print('INCREASING') elif arr == sorted(arr, reverse=True): print('DECREASING') else: print('NEITHER')
""" quick_sort.py Implementation of quick sort on a list and returns a sorted list. Quick Sort Overview: ------------------------ Uses partitioning to recursively divide and sort the list Time Complexity: O(n**2) worst case Space Complexity: O(n**2) this version Stable: No Psue...
""" quick_sort.py Implementation of quick sort on a list and returns a sorted list. Quick Sort Overview: ------------------------ Uses partitioning to recursively divide and sort the list Time Complexity: O(n**2) worst case Space Complexity: O(n**2) this version Stable: No Psue...
# coding=utf-8 def test_method(param): """ Should not show up :param param: any param :return: None """ return None
def test_method(param): """ Should not show up :param param: any param :return: None """ return None
#program to find the single element appears once in a list where every element # appears four times except for one. class Solution_once: def singleNumber(self, arr): ones, twos = 0, 0 for x in arr: ones, twos = (ones ^ x) & ~twos, (ones & x) | (twos & ~x) assert twos == 0 ...
class Solution_Once: def single_number(self, arr): (ones, twos) = (0, 0) for x in arr: (ones, twos) = ((ones ^ x) & ~twos, ones & x | twos & ~x) assert twos == 0 return ones class Solution_Twice: def single_number(arr): (ones, twos, threes) = (0, 0, 0) ...
''' Given a collection of numbers that might contain duplicates, return all possible unique permutations. For example, [1,1,2] have the following unique permutations: [1,1,2], [1,2,1], and [2,1,1]. ''' class Solution(object): def permuteUnique(self, nums): """ :type nums: List[int] ...
""" Given a collection of numbers that might contain duplicates, return all possible unique permutations. For example, [1,1,2] have the following unique permutations: [1,1,2], [1,2,1], and [2,1,1]. """ class Solution(object): def permute_unique(self, nums): """ :type nums: List[int] :rtyp...
class Bank: def __init__(self,owner,balance): self.owner=owner self.balance=balance def deposit(self,d): self.balance=d+self.balance print("amount : {}".format(d)) print("deposit accepted!!") return self.balance def withdraw(self,w): ...
class Bank: def __init__(self, owner, balance): self.owner = owner self.balance = balance def deposit(self, d): self.balance = d + self.balance print('amount : {}'.format(d)) print('deposit accepted!!') return self.balance def withdraw(self, w): if ...
""" Various constants used to build bazel-diff """ DEFAULT_JVM_EXTERNAL_TAG = "3.3" RULES_JVM_EXTERNAL_SHA = "d85951a92c0908c80bd8551002d66cb23c3434409c814179c0ff026b53544dab" BUILD_PROTO_MESSAGE_SHA = "50b79faec3c4154bed274371de5678b221165e38ab59c6167cc94b922d9d9152" BAZEL_DIFF_MAVEN_ARTIFACTS = [ "junit:junit...
""" Various constants used to build bazel-diff """ default_jvm_external_tag = '3.3' rules_jvm_external_sha = 'd85951a92c0908c80bd8551002d66cb23c3434409c814179c0ff026b53544dab' build_proto_message_sha = '50b79faec3c4154bed274371de5678b221165e38ab59c6167cc94b922d9d9152' bazel_diff_maven_artifacts = ['junit:junit:4.12', '...
# # @lc app=leetcode id=206 lang=python3 # # [206] Reverse Linked List # # https://leetcode.com/problems/reverse-linked-list/description/ # # algorithms # Easy (65.21%) # Likes: 6441 # Dislikes: 123 # Total Accepted: 1.3M # Total Submissions: 2M # Testcase Example: '[1,2,3,4,5]' # # Given the head of a singly li...
class Solution: def reverse_list(self, head: ListNode) -> ListNode: prev = None curr = head while curr: next = curr.next curr.next = prev prev = curr curr = next return prev
# Bubble Sort # # Time Complexity: O(n*log(n)) # Space Complexity: O(1) class Solution: def bubbleSort(self, array: [int]) -> [int]: dirty = False for i in range(len(array)): for j in range(0, len(array) - 1 - i): if array[j] > array[j + 1]: di...
class Solution: def bubble_sort(self, array: [int]) -> [int]: dirty = False for i in range(len(array)): for j in range(0, len(array) - 1 - i): if array[j] > array[j + 1]: dirty = True (array[j], array[j + 1]) = (array[j + 1], array...
#!/usr/bin/env python # -*- coding: utf-8 -*- ''' ***************************************** Author: zhlinh Email: zhlinhng@gmail.com Version: 0.0.1 Created Time: 2016-03-07 Last_modify: 2016-03-07 ****************************************** ''' ''' Given a **singly linked list** where eleme...
""" ***************************************** Author: zhlinh Email: zhlinhng@gmail.com Version: 0.0.1 Created Time: 2016-03-07 Last_modify: 2016-03-07 ****************************************** """ '\nGiven a **singly linked list** where elements are\nsorted in ascending order, convert it t...
# -*- coding: utf-8 -*- """ repoclone.exceptions ----------------------- All exceptions used in the repoclone code base are defined here. """ class RepocloneException(Exception): """ Base exception class. All Cookiecutter-specific exceptions should subclass this class. """
""" repoclone.exceptions ----------------------- All exceptions used in the repoclone code base are defined here. """ class Repocloneexception(Exception): """ Base exception class. All Cookiecutter-specific exceptions should subclass this class. """
inputFile = str(input("Input file")) f = open(inputFile,"r") data = f.readlines() f.close() runningFuelSum = 0 for line in data: line = line.replace("\n","") mass = int(line) fuelNeeded = (mass//3)-2 runningFuelSum += fuelNeeded while(fuelNeeded > 0): fuelNeeded = (fuelNeeded//3)-2 ...
input_file = str(input('Input file')) f = open(inputFile, 'r') data = f.readlines() f.close() running_fuel_sum = 0 for line in data: line = line.replace('\n', '') mass = int(line) fuel_needed = mass // 3 - 2 running_fuel_sum += fuelNeeded while fuelNeeded > 0: fuel_needed = fuelNeeded // 3 -...
class Settings: def __init__(self): self.screen_width, self.screen_height = 800, 300 self.bg_color = (225, 225, 225)
class Settings: def __init__(self): (self.screen_width, self.screen_height) = (800, 300) self.bg_color = (225, 225, 225)
class Solution: def sortColors(self, nums: List[int]) -> None: zero = -1 one = -1 two = -1 for num in nums: if num == 0: two += 1 one += 1 zero += 1 nums[two] = 2 nums[one] = 1 nums[zero] = 0 elif num == 1: two += 1 one += 1 ...
class Solution: def sort_colors(self, nums: List[int]) -> None: zero = -1 one = -1 two = -1 for num in nums: if num == 0: two += 1 one += 1 zero += 1 nums[two] = 2 nums[one] = 1 ...