content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
# Ship build window new_design = 170,130 autogen= 60, 700 combat_report = 530, 290, 860, 500 load_list = [(1280, 515+50*i) for i in range(7)] load_selected = 1480, 860 #Builder Menu #Corvettes vette_type = 670, 65
new_design = (170, 130) autogen = (60, 700) combat_report = (530, 290, 860, 500) load_list = [(1280, 515 + 50 * i) for i in range(7)] load_selected = (1480, 860) vette_type = (670, 65)
S = input() for i in range(ord("a"), ord("z") + 1): if chr(i) not in S: print(chr(i)) break else: print("None")
s = input() for i in range(ord('a'), ord('z') + 1): if chr(i) not in S: print(chr(i)) break else: print('None')
# Program that asks for a number and informs the prime numbers that precede it. a = int(input("Enter a number: ")) for num in range(a): div = 0 for x in range(1, num + 1): rest = num % x # print(x, rest) if rest == 0: div += 1 if div == 2: print(num) # a = int(in...
a = int(input('Enter a number: ')) for num in range(a): div = 0 for x in range(1, num + 1): rest = num % x if rest == 0: div += 1 if div == 2: print(num)
# {team} -> Name of team # {name} -> Name of person who supports team teamMatchStarted: list[str] = [ "Come on {team} !!", "{team} are the greatest team in the world", ] drawing: list[str] = [ "{team} winning this match, morally", "{team} should still win this", "{team} still clearly the best team...
team_match_started: list[str] = ['Come on {team} !!', '{team} are the greatest team in the world'] drawing: list[str] = ['{team} winning this match, morally', '{team} should still win this', '{team} still clearly the best team'] team_lead_by_one: list[str] = ['{team} take the lead, deserved, obviously', 'That was a fuc...
s = input() print(any(i.isalpha() for i in s)) print(any(i.isupper() for i in s)) print(any(i.islower() for i in s)) print(any(i.isdigit() for i in s)) print(any(i.isalnum() for i in s))
s = input() print(any((i.isalpha() for i in s))) print(any((i.isupper() for i in s))) print(any((i.islower() for i in s))) print(any((i.isdigit() for i in s))) print(any((i.isalnum() for i in s)))
with open('data/nm_test.txt') as testfile: for line in testfile: print(line) # classification = ApplicantClassifier.classify(applicant) # test.append(applicant, classification) # # print(test[:10]) # # with open('data/nm_test_result.csv', 'w', encoding=file_encoding) as write_file: # wri...
with open('data/nm_test.txt') as testfile: for line in testfile: print(line)
def isLowerChar(c): return ord(c) >= 97 and ord(c) <= 122 def isUpperChar(c): return ord(c) >= 65 and ord(c) <= 90 def isNumber(c): return ord(c) >= 48 and ord(c) <= 57 S = input() K = int(input()) R = "" for c in S: if(isLowerChar(c)): R += chr(((ord(c) - 97 + K) % 26) + 97) eli...
def is_lower_char(c): return ord(c) >= 97 and ord(c) <= 122 def is_upper_char(c): return ord(c) >= 65 and ord(c) <= 90 def is_number(c): return ord(c) >= 48 and ord(c) <= 57 s = input() k = int(input()) r = '' for c in S: if is_lower_char(c): r += chr((ord(c) - 97 + K) % 26 + 97) elif is_u...
class SecurionPayException(Exception): def __init__(self, type, code, message, charge_id, blacklist_rule_id): self.type = type self.code = code self.message = message self.charge_id = charge_id self.blacklist_rule_id = blacklist_rule_id def __str__(self): return ...
class Securionpayexception(Exception): def __init__(self, type, code, message, charge_id, blacklist_rule_id): self.type = type self.code = code self.message = message self.charge_id = charge_id self.blacklist_rule_id = blacklist_rule_id def __str__(self): return...
FLATPAGE_CONFIG = { 'about': { 'url': '/about/', 'title': 'About us', 'enable_comments': False, 'template_name': 'flatpages/about.html', 'registration_required': False, }, 'contact': { 'url': '/contact/', 'title': 'Contact us', 'enable_comments...
flatpage_config = {'about': {'url': '/about/', 'title': 'About us', 'enable_comments': False, 'template_name': 'flatpages/about.html', 'registration_required': False}, 'contact': {'url': '/contact/', 'title': 'Contact us', 'enable_comments': False, 'template_name': 'flatpages/contact-us.html', 'registration_required': ...
################################################# # Test sample ################################################# file_in = "sample/dataset/dna.txt" file_out = "sample/output/dna.txt" with open(file_in) as f: data = f.read().splitlines() with open(file_out) as f: outcome = f.read().splitlines() d = {"A": 0...
file_in = 'sample/dataset/dna.txt' file_out = 'sample/output/dna.txt' with open(file_in) as f: data = f.read().splitlines() with open(file_out) as f: outcome = f.read().splitlines() d = {'A': 0, 'C': 0, 'G': 0, 'T': 0} for s in data[0]: d[s] += 1 print(*d.values()) def test_sample(): for (s1, s2) in zi...
phash = hash(input('Enter your password: ')) print('Welcome to the system.') print('list of variables: ') print(globals()) if phash == hash(input('Enter login password: ')): print('access granted') else: print('access denied')
phash = hash(input('Enter your password: ')) print('Welcome to the system.') print('list of variables: ') print(globals()) if phash == hash(input('Enter login password: ')): print('access granted') else: print('access denied')
__all__ = ['wiggle'] def wiggle(count): for i in range(0, count): print('wiggle') def waggle(count): for i in range(0, count): print('waggle')
__all__ = ['wiggle'] def wiggle(count): for i in range(0, count): print('wiggle') def waggle(count): for i in range(0, count): print('waggle')
''' STRING INTERPOLATION ''' name = "John Doe" age = 20 #These are different ways you can combine variables together #Concatenation (The one you are most familiar with) string = "Hello! My name is " + name + " and I am " + str(age) + " years old." print(string) #f-strings (Works only for Python 3.6+) # placing 'f'...
""" STRING INTERPOLATION """ name = 'John Doe' age = 20 string = 'Hello! My name is ' + name + ' and I am ' + str(age) + ' years old.' print(string) string = f'Hello! My name is {name} and I am {age} years old.' print(string) string = 'Hello! My name is {} and I am {} years old.'.format(name, age) string = 'Hello! My n...
class StatusPresenter: def convert(self, status): return { "id": str(status.id), "type": 'status', "title": status.title, } def convert_list(self, statuses): return map(self.convert, statuses)
class Statuspresenter: def convert(self, status): return {'id': str(status.id), 'type': 'status', 'title': status.title} def convert_list(self, statuses): return map(self.convert, statuses)
# float declaration floatValue = 3.14159 print("float value : {0}".format(floatValue)) # constructor floatValue = float(10.99) print("float constructor : {0}".format(floatValue)) # string to float conversion floatValue = float("10.11") print("string to float conversion : {0}".format(floatValue)) # creati...
float_value = 3.14159 print('float value : {0}'.format(floatValue)) float_value = float(10.99) print('float constructor : {0}'.format(floatValue)) float_value = float('10.11') print('string to float conversion : {0}'.format(floatValue)) print(float('inf')) print(float('-inf')) print(3.1 + 4)
class ElementType(object): def __init__(self, j): self.id_ = j['id'] self.plural_name = j['plural_name'] self.plural_name_short = j['plural_name_short'] self.singular_name = j['singular_name'] self.singular_name_short = j['singular_name_short']
class Elementtype(object): def __init__(self, j): self.id_ = j['id'] self.plural_name = j['plural_name'] self.plural_name_short = j['plural_name_short'] self.singular_name = j['singular_name'] self.singular_name_short = j['singular_name_short']
class Product: def __init__(self,id_, title, price): self.__id = id_ self.__title = title self.__price = price def get_id_title_price(self): return "ID: "+str(self.__id)+" Title:"+self.__title+" Price: "+str(self.__price) class Book(Product): def __init__(self,id_...
class Product: def __init__(self, id_, title, price): self.__id = id_ self.__title = title self.__price = price def get_id_title_price(self): return 'ID: ' + str(self.__id) + ' Title:' + self.__title + ' Price: ' + str(self.__price) class Book(Product): def __init__(self,...
# # @lc app=leetcode id=18 lang=python3 # # [18] 4Sum # # @lc code=start class Solution: def fourSum(self, nums: List[int], target: int) -> List[List[int]]: res = [] nums.sort() if len(nums) < 4: return [] for i in range(len(nums) - 3): for j in range(i + ...
class Solution: def four_sum(self, nums: List[int], target: int) -> List[List[int]]: res = [] nums.sort() if len(nums) < 4: return [] for i in range(len(nums) - 3): for j in range(i + 1, len(nums) - 2): (l, r) = (j + 1, len(nums) - 1) ...
#weights change from here def videostreaming_weights(): return {'w2_0_score':0.01, 'ppi':0.14, 'w2_0_battery':0.20, 'stb':0.22, 'weight':-0.18, 'ram':0.07, 'cap':0.04, 'grafix':0.14 } def gaming_weights(): return {'w2_0_score':0.01, 'ppi':0.17, 'w2_0_battery':0.1...
def videostreaming_weights(): return {'w2_0_score': 0.01, 'ppi': 0.14, 'w2_0_battery': 0.2, 'stb': 0.22, 'weight': -0.18, 'ram': 0.07, 'cap': 0.04, 'grafix': 0.14} def gaming_weights(): return {'w2_0_score': 0.01, 'ppi': 0.17, 'w2_0_battery': 0.19, 'stb': -0.13, 'weight': -0.17, 'ram': 0.08, 'cap': 0.05, 'graf...
# # PySNMP MIB module MERU-CONFIG-ICR-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/MERU-CONFIG-ICR-MIB # Produced by pysmi-0.3.4 at Wed May 1 14:11:22 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default...
(object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (single_value_constraint, value_size_constraint, constraints_intersection, constraints_union, value_range_constraint) ...
''' Kattis - lektira Relatively easy complete search problem. Use string slicing and reversing. Time: O(n^3), Space: O(n) ''' s = input() n = len(s) cur_min = s for i in range(1, n-1): for j in range(i+1, n): a = s[0:i] b = s[i:j] c = s[j:n] new_s = a[::-1] + b[::-1] + c[:...
""" Kattis - lektira Relatively easy complete search problem. Use string slicing and reversing. Time: O(n^3), Space: O(n) """ s = input() n = len(s) cur_min = s for i in range(1, n - 1): for j in range(i + 1, n): a = s[0:i] b = s[i:j] c = s[j:n] new_s = a[::-1] + b[::-1] + c[::-1] ...
''' Created on Aug 9, 2012 @author: Chris ''' curr_options = None SLOW_COMBAT_SPEED = 0 MED_COMBAT_SPEED = 1 FAST_COMBAT_SPEED = 2 class Options(object): def __init__(self): self.sound = True self.sound_volume = 1.0 self.music = True self.music_volume = 0.5 self.own_...
""" Created on Aug 9, 2012 @author: Chris """ curr_options = None slow_combat_speed = 0 med_combat_speed = 1 fast_combat_speed = 2 class Options(object): def __init__(self): self.sound = True self.sound_volume = 1.0 self.music = True self.music_volume = 0.5 self.own_combat...
# Copyright 2017 Hewlett Packard Enterprise Development LP # # 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...
push_power_button_press = 'press' push_power_button_press_and_hold = 'press and hold' bios_boot_mode_legacy_bios = 'legacy bios' bios_boot_mode_uefi = 'uefi' boot_source_target_cd = 'Cd' boot_source_target_pxe = 'Pxe' boot_source_target_uefi_target = 'UefiTarget' boot_source_target_hdd = 'Hdd' sriov_enabled = 'sriov en...
# No.1/2019-06-06/28 ms/13.2 MB # Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def removeNthFromEnd(self, head: ListNode, n: int) -> ListNode: l=[] if head.next: while head: ...
class Solution: def remove_nth_from_end(self, head: ListNode, n: int) -> ListNode: l = [] if head.next: while head: l.append(head) head = head.next if n == 1: l[-2].next = None elif n == len(l): retu...
class Solution: def countAndSay(self, n: int) -> str: ret = '1' for _ in range(n-1): tmp = '' cur = ret[0] nCnt = 1 for c in ret[1:]: if cur == c: nCnt += 1 else: tmp += str(nCnt) ...
class Solution: def count_and_say(self, n: int) -> str: ret = '1' for _ in range(n - 1): tmp = '' cur = ret[0] n_cnt = 1 for c in ret[1:]: if cur == c: n_cnt += 1 else: tmp += str...
class DefinitionResponseBuilder(object): def __init__(self, word, result_set, pos=None): mapped_collection = list(map(lambda el: { 'definition': el['definition'].capitalize(), 'word': el['word'].word(), 'partOfSpeech': el['word'].part_of_speech() }, result_set)) ...
class Definitionresponsebuilder(object): def __init__(self, word, result_set, pos=None): mapped_collection = list(map(lambda el: {'definition': el['definition'].capitalize(), 'word': el['word'].word(), 'partOfSpeech': el['word'].part_of_speech()}, result_set)) self._output = {'word': word.replace('...
s1 = "HELLO BEGINNERS" print(s1.casefold()) # -- CF1 s2 = "Hello Beginners" print(s2.casefold()) # -- CF2 if s1.casefold() == s2.casefold(): # -- CF3 print("Both the strings are same after conversion") else: print("Both the strings are different after conversion ")
s1 = 'HELLO BEGINNERS' print(s1.casefold()) s2 = 'Hello Beginners' print(s2.casefold()) if s1.casefold() == s2.casefold(): print('Both the strings are same after conversion') else: print('Both the strings are different after conversion ')
# Shortest Job First Program in Python # Function which implements SJF algorithm. def SJF(process, n): process = sorted(process, key=lambda x:x[1]) # Sorting process according to their Burst Time wait= 0 waitSum, turnSum = 0,0 # Initializng Sum of Wait-Time -> 0...
def sjf(process, n): process = sorted(process, key=lambda x: x[1]) wait = 0 (wait_sum, turn_sum) = (0, 0) print('Process\t Burst-Time\tWaiting-Time\tTurnaround-Time') for i in range(n): turn = wait + process[i][1] print('P' + str(process[i][0]) + '\t\t' + str(process[i][1]) + '\t\...
class NodoArbol: def __init__(self,value,left=None,rigth=None): self.data=value self.left=left self.rigth=rigth self.ban=0 def recorrido(arb): mov=[] bandera=0 lis1=[]#Nodos hoja lis2=[]#niveles while bandera==0: bandera2=0 aux=arb for ...
class Nodoarbol: def __init__(self, value, left=None, rigth=None): self.data = value self.left = left self.rigth = rigth self.ban = 0 def recorrido(arb): mov = [] bandera = 0 lis1 = [] lis2 = [] while bandera == 0: bandera2 = 0 aux = arb ...
# Manual fix tokenization issue in doc "CNN_IP_20030408.1600.04" # "JEFF GREENFIELD , CNN SR. ANALYST ( voice-over )" becomes "JEFF GREENFIELD , CNN SR. . ANALYST ( voice-over )" with open("text/CNN_IP_20030408.1600.04.split.txt", "r", encoding="utf8") as file: doc = [line.replace("SR. .", "SR.") for line in file]...
with open('text/CNN_IP_20030408.1600.04.split.txt', 'r', encoding='utf8') as file: doc = [line.replace('SR. .', 'SR.') for line in file] with open('text/CNN_IP_20030408.1600.04.split.txt', 'w', encoding='utf8') as file: file.write('\n'.join(doc))
i = 0 while i < 10: for _ in range(20): if i == 5: break i += 1 print(i)
i = 0 while i < 10: for _ in range(20): if i == 5: break i += 1 print(i)
# Input: CSV with columns pid, sid, price # Compare this (more costly/expensive using reduceByKey - 3 shuffle operations) total_price = rdd.map(lambda t: (t[1], t[2])).reduceByKey(lambda x, y: x + y) num_items = rdd.map(lambda t: (t[1], t[2])).reduceByKey(lambda x, y: 1 + y, 0) total_price.join(num_items).map(lambda t...
total_price = rdd.map(lambda t: (t[1], t[2])).reduceByKey(lambda x, y: x + y) num_items = rdd.map(lambda t: (t[1], t[2])).reduceByKey(lambda x, y: 1 + y, 0) total_price.join(num_items).map(lambda t: (t[0], t[1] / t[2])) rdd.map(lambda t: (t[1], t[2])).groupByKey().map(lambda t: (t[0], sum(t[1]) / len(t[1])))
# Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def getDecimalValue(self, head: ListNode) -> int: self.val = [] def traverse(head) -> None: if not head: ...
class Solution: def get_decimal_value(self, head: ListNode) -> int: self.val = [] def traverse(head) -> None: if not head: return self.val.append(str(head.val)) traverse(head.next) return traverse(head) return int(''.j...
def parseDictToQuery(dictionary): ''' This method parses a dictionary to convert it into field queries ''' query = "" for key in dictionary: # If the current value is a sub-dict, parse it recursively if type(dictionary[key]) == dict: query += f"{key}({parseDictToQuery(d...
def parse_dict_to_query(dictionary): """ This method parses a dictionary to convert it into field queries """ query = '' for key in dictionary: if type(dictionary[key]) == dict: query += f'{key}({parse_dict_to_query(dictionary[key])})' else: query += key ...
class Game: PLAYER_1 = 1 PLAYER_2 = -1 TIE = 0 def __init__(self): pass def board_tensor_size(self): pass def status_tensor_size(self): # None if status tensor is not used pass def starting_state(self): pass de...
class Game: player_1 = 1 player_2 = -1 tie = 0 def __init__(self): pass def board_tensor_size(self): pass def status_tensor_size(self): pass def starting_state(self): pass def current_player(self, state): pass def legal_actions(self, stat...
class Solution: def sortArrayByParity(self, A: List[int]) -> List[int]: if not A or len(A) == 1: return A i, j = 0, len(A)-1 while i < j: while i < j and A[i] % 2 == 0: i += 1 while j > -1 and A[j] % 2 != 0: j -= 1 if i >...
class Solution: def sort_array_by_parity(self, A: List[int]) -> List[int]: if not A or len(A) == 1: return A (i, j) = (0, len(A) - 1) while i < j: while i < j and A[i] % 2 == 0: i += 1 while j > -1 and A[j] % 2 != 0: j -= 1...
# Recitation Lab 1 Question 2: Program to print two lines # Author: Asmit De # Date: 01/19/2017 print("Lab assignment by:") print("Asmit De")
print('Lab assignment by:') print('Asmit De')
class Board: # The backtracking approach is to generate all possible numbers (1-9) # into the empty cells. # Try every row, column one by one until the correct solution is found. INIT_STAGE = [ [3, 0, 6, 5, 0, 8, 4, 0, 0], [5, 2, 0, 0, 0, 0, 0, 0, 0], [0, 8, 7, 0, 0, 0, 0, 3, 1],...
class Board: init_stage = [[3, 0, 6, 5, 0, 8, 4, 0, 0], [5, 2, 0, 0, 0, 0, 0, 0, 0], [0, 8, 7, 0, 0, 0, 0, 3, 1], [0, 0, 3, 0, 1, 0, 0, 8, 0], [9, 0, 0, 8, 6, 3, 0, 0, 5], [0, 5, 0, 0, 9, 0, 6, 0, 0], [1, 3, 0, 0, 0, 0, 2, 5, 0], [0, 0, 0, 0, 0, 0, 0, 7, 4], [0, 0, 5, 2, 0, 6, 3, 0, 0]] selected = None def...
# Virtualized High Performance Computing Toolkit # # Copyright (c) 2018-2019 VMware, Inc. All Rights Reserved. # # This product is licensed to you under the Apache 2.0 license (the # "License"). You may not use this product except in compliance with the # Apache 2.0 License. This product may include a number of subcomp...
__version__ = '0.2.0'
# Copyright 2015 OpenStack Foundation # Copyright (c) 2015 Hewlett-Packard Development Company, L.P. # # 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/LI...
l2_gw = 'L2GW' l2gw = 'l2gw' agent_type_l2_gateway = 'L2 Gateway agent' l2_gw_invalid_ovsdb_identifier = 101 error_dict = {L2GW_INVALID_OVSDB_IDENTIFIER: 'Invalid ovsdb_identifier in the request'} monitor = 'monitor' ovsdb_schema_name = 'hardware_vtep' ovsdb_identifier = 'ovsdb_identifier' l2_gw_agent_type = 'l2gw_agen...
def compute_feature_cross_corellation_matrix(study): print ("compute_feature_cross_corellation_matrix: " + study) return "DONE" def compute_feature_corellation(study1, study2): print ("compute_feature_corellation: " + study1 + " " + study2) return "DONE"
def compute_feature_cross_corellation_matrix(study): print('compute_feature_cross_corellation_matrix: ' + study) return 'DONE' def compute_feature_corellation(study1, study2): print('compute_feature_corellation: ' + study1 + ' ' + study2) return 'DONE'
# The Curbrock in the Grass (5499) SABITRAMA = 1061005 # NPC ID CURBROCKS_HIDEOUT = 600050000 # MAP ID CURBROCKS_ESCAPE_ROUTE = 600050030 # MAP ID sm.setSpeakerID(SABITRAMA) if sm.getFieldID() == CURBROCKS_HIDEOUT or \ sm.getFieldID() == CURBROCKS_ESCAPE_ROUTE: sm.sendSayOkay("Please leave before reaccepting...
sabitrama = 1061005 curbrocks_hideout = 600050000 curbrocks_escape_route = 600050030 sm.setSpeakerID(SABITRAMA) if sm.getFieldID() == CURBROCKS_HIDEOUT or sm.getFieldID() == CURBROCKS_ESCAPE_ROUTE: sm.sendSayOkay('Please leave before reaccepting this quest again.') else: sm.sendNext('Have you come to hear the s...
#@Author Prathamesh More #This is a comment in Python print("We love Python")
print('We love Python')
#Config settings to change behavior of the photobooth # Hardware config monitor_w = 800 # width of the display monitor monitor_h = 480 # height of the display monitor led_pin = 7 # pin for the LED btn_pin = 18 # pin for the start button debounce = 0.3 # how long to deb...
monitor_w = 800 monitor_h = 480 led_pin = 7 btn_pin = 18 debounce = 0.3 file_path = '/home/pi/Pictures/' camera_iso = 640 total_pics = 4 capture_delay = 1 prep_delay = 5 restart_delay = 10 capture_count_pics = True clear_on_startup = False hi_res_pics = True high_res_w = 1000 high_res_h = 750 black_and_white = False ov...
map = { 'node': { 'key1': 'key1value', 'key2': 'key2value', 'key3': 'key3value' } }
map = {'node': {'key1': 'key1value', 'key2': 'key2value', 'key3': 'key3value'}}
x = [2, 2.75, 4] y = [1/2, 4/11, 1/4] def largrange(x,y,xp): sum = 0 n = len(x)-1 for i in range(1, n+1): p = 1 for j in range(1, n+1): if j != i: p = p*((xp-x[j])/(x[i]-x[j])) sum = sum+y[i]*p return sum
x = [2, 2.75, 4] y = [1 / 2, 4 / 11, 1 / 4] def largrange(x, y, xp): sum = 0 n = len(x) - 1 for i in range(1, n + 1): p = 1 for j in range(1, n + 1): if j != i: p = p * ((xp - x[j]) / (x[i] - x[j])) sum = sum + y[i] * p return sum
#!/usr/bin/env python3 if __name__ == "__main__": stack = [] ops_cnt = int(input().strip()) max_elem = 0 for _ in range(ops_cnt): args = list(map(int, input().strip().split())) if args[0] == 1: max_elem = max(max_elem, args[1]) stack.append(args[1])...
if __name__ == '__main__': stack = [] ops_cnt = int(input().strip()) max_elem = 0 for _ in range(ops_cnt): args = list(map(int, input().strip().split())) if args[0] == 1: max_elem = max(max_elem, args[1]) stack.append(args[1]) if args[0] == 2: ...
# python 3 def Dijkstra(Graph, source): ''' + +---+---+ | 0 1 2 | +---+ + + | 3 4 | 5 +---+---+---+ >>> graph = ( # or ones on the diagonal ... (0,1,0,0,0,0,), ... (1,0,1,0,1,0,), ... (0,1,0,0,0,1,), ......
def dijkstra(Graph, source): """ + +---+---+ | 0 1 2 | +---+ + + | 3 4 | 5 +---+---+---+ >>> graph = ( # or ones on the diagonal ... (0,1,0,0,0,0,), ... (1,0,1,0,1,0,), ... (0,1,0,0,0,1,), ... (0,0,0,...
class HeaderSplitter: @staticmethod def split_to_kv(header_content): kv = {} for token in header_content.split(";"): k, v = token.strip().split("=") kv[k.strip()] = v.strip() return kv @staticmethod def split_to_multi_values_by_key(header_content): ...
class Headersplitter: @staticmethod def split_to_kv(header_content): kv = {} for token in header_content.split(';'): (k, v) = token.strip().split('=') kv[k.strip()] = v.strip() return kv @staticmethod def split_to_multi_values_by_key(header_content): ...
n = int(input()) a_list = list(map(int, input().split())) count = 0 l = 0 r = 0 sum_num = a_list[0] xor_num = a_list[0] while l < n and r < n: if sum_num == xor_num: count += r - l + 1 r += 1 if r < n: sum_num += a_list[r] xor_num ^= a_list[r] else: if ...
n = int(input()) a_list = list(map(int, input().split())) count = 0 l = 0 r = 0 sum_num = a_list[0] xor_num = a_list[0] while l < n and r < n: if sum_num == xor_num: count += r - l + 1 r += 1 if r < n: sum_num += a_list[r] xor_num ^= a_list[r] else: if l <...
h = float(input("Enter Hours: ")) r = float(input("Enter Rate: ")) def computepay(hrs, rate): if hrs > 40: return 40*rate + (hrs-40)*1.5*rate else: return hrs*rate pay = computepay(h, r) print(f"Pay: {pay}")
h = float(input('Enter Hours: ')) r = float(input('Enter Rate: ')) def computepay(hrs, rate): if hrs > 40: return 40 * rate + (hrs - 40) * 1.5 * rate else: return hrs * rate pay = computepay(h, r) print(f'Pay: {pay}')
x = 9 y = 3 #Arithmetic Operators print(x+y) print(x-y) print(x*y) print(x/y) print(x%y) #Modulus: provides remainder of values print(x**y) #Eponential notation x = 9.191823 #Overwrites the varaible x print(x//y) #Floor division: returns int. #removes fractional parts #x is a float...
x = 9 y = 3 print(x + y) print(x - y) print(x * y) print(x / y) print(x % y) print(x ** y) x = 9.191823 print(x // y) x = 9 x += 3 print(x) x = 9 x -= 3 print(x) x *= 3 print(x) x /= 3 print(x) x **= 3 print(x) x = 9 y = 3 print(x == y) print(x != y) print(x > y) print(x < y) print(x >= y) print(x <= y)
# coding: utf-8 def array_diff(l, *args): res = [] for i in l: for k, v in enumerate(args): if i in v: break if k == len(args) - 1: res.append(i) return res def array_diff1(arr1, *args): return set(arr1).difference(*args) if __name__ =...
def array_diff(l, *args): res = [] for i in l: for (k, v) in enumerate(args): if i in v: break if k == len(args) - 1: res.append(i) return res def array_diff1(arr1, *args): return set(arr1).difference(*args) if __name__ == '__main__': ...
class Solution: def XXX(self, nums: List[int]) -> int: ans = [] max = nums[0] for num in nums: ans.append(num) if sum(ans) > max: max = sum(ans) if sum(ans) < 0: ans = [] return max
class Solution: def xxx(self, nums: List[int]) -> int: ans = [] max = nums[0] for num in nums: ans.append(num) if sum(ans) > max: max = sum(ans) if sum(ans) < 0: ans = [] return max
# Created by MechAviv # ID :: [927020100] # Hidden Street : Final Battle sm.curNodeEventEnd(True) sm.setTemporarySkillSet(0) sm.setInGameDirectionMode(True, True, False, False) sm.playURLVideoByScript("http://nxcache.nexon.net/maplestory/video/yt/Luminous.html") # Unhandled Message [47] Packet: 2F 01 00 00 00 B0 83 ...
sm.curNodeEventEnd(True) sm.setTemporarySkillSet(0) sm.setInGameDirectionMode(True, True, False, False) sm.playURLVideoByScript('http://nxcache.nexon.net/maplestory/video/yt/Luminous.html') sm.warp(910141040, 0)
''' Print the following pattern. 1 22 333 .... nnn.. ''' rows = int(input("Enter row size:")) num = 0 for i in range(rows + 1): for j in range(i): print(num, end = '') num += 1 print("")
""" Print the following pattern. 1 22 333 .... nnn.. """ rows = int(input('Enter row size:')) num = 0 for i in range(rows + 1): for j in range(i): print(num, end='') num += 1 print('')
# The registry stores Event and listener function pairs. # # For example: # # registry = { # Event.CLICK: [some_click_listener_function, some_other_click_listener_function], # Event.KEY: [some_key_listener_function] # } registry = {}
registry = {}
def parse_html_color(color): dict={} if PRESET_COLORS.get(color.lower(), None): temp=PRESET_COLORS[color.lower()][1:] rgb=[temp[i:i+2] for i in range(0, len(temp)-1, 2)] for i,j in zip("rgb", rgb): dict[i]=int(j, 16) elif len(color)==4: dict={i:int(j+j, 16) for i,...
def parse_html_color(color): dict = {} if PRESET_COLORS.get(color.lower(), None): temp = PRESET_COLORS[color.lower()][1:] rgb = [temp[i:i + 2] for i in range(0, len(temp) - 1, 2)] for (i, j) in zip('rgb', rgb): dict[i] = int(j, 16) elif len(color) == 4: dict = {i:...
conf = { 'xtype': 'melee', 'x1.dmg': 84 / 100.0, 'x1.sp': 120, 'x1.startup': 9 / 60.0, 'x1.recovery': 41 / 60.0, 'x1.hit': 1, 'x2.dmg': 45*2 / 100.0, 'x2.sp': 240, 'x2.startup': 0, 'x2.recovery': 34 / 60.0, 'x2.hit': 2, 'x3.dmg': 108 / 100.0, 'x3.sp': 120, 'x3...
conf = {'xtype': 'melee', 'x1.dmg': 84 / 100.0, 'x1.sp': 120, 'x1.startup': 9 / 60.0, 'x1.recovery': 41 / 60.0, 'x1.hit': 1, 'x2.dmg': 45 * 2 / 100.0, 'x2.sp': 240, 'x2.startup': 0, 'x2.recovery': 34 / 60.0, 'x2.hit': 2, 'x3.dmg': 108 / 100.0, 'x3.sp': 120, 'x3.startup': 0, 'x3.recovery': 37 / 60.0, 'x3.hit': 1, 'x4.dm...
# 191. Number of 1 Bits class Solution: def hammingWeight(self, n): s = 0 while n > 0: s += n & 1 n = n >> 1 return s
class Solution: def hamming_weight(self, n): s = 0 while n > 0: s += n & 1 n = n >> 1 return s
n = int(input()) for _ in range(1, n + 1): print(_, sep=' ', end='')
n = int(input()) for _ in range(1, n + 1): print(_, sep=' ', end='')
HOST = '0.0.0.0' PORT = 5001 DEBUG = True SECRET_KEY = 'shhhhh!!!' THEME = 'coconut' # DEFAULTS: coconut, banana THEME_FOLDER = 'rum/themes/'+ THEME +'/'
host = '0.0.0.0' port = 5001 debug = True secret_key = 'shhhhh!!!' theme = 'coconut' theme_folder = 'rum/themes/' + THEME + '/'
class C1: gg = 1 def __init__(self, x, y): self.x = 1
class C1: gg = 1 def __init__(self, x, y): self.x = 1
def testGrader(): mylist = ['B', 'D', 'A', 'A', 'C', 'A', 'B', 'A', 'C', 'D'] correct = 0 for letter in mylist: answer = input("What answer did the student putdown? ") if letter == answer: print ("That answer was correct") correct += 1 else: ...
def test_grader(): mylist = ['B', 'D', 'A', 'A', 'C', 'A', 'B', 'A', 'C', 'D'] correct = 0 for letter in mylist: answer = input('What answer did the student putdown? ') if letter == answer: print('That answer was correct') correct += 1 else: print(...
def get_uniques(data, column_name): ''' Get the unique elements from a column which consists of list of items. Return unique elements. ''' unique_vals = set() for row in data[column_name]: # Add list of items to a set unique_vals.update(row) return unique_vals
def get_uniques(data, column_name): """ Get the unique elements from a column which consists of list of items. Return unique elements. """ unique_vals = set() for row in data[column_name]: unique_vals.update(row) return unique_vals
#not working as intended class Node: def __init__(self, probability, character, left=None, right=None): self.probability = probability self.character = character self.left = left self.right = right self.bit = '' def calcProbability(data): chars = dict() for char in d...
class Node: def __init__(self, probability, character, left=None, right=None): self.probability = probability self.character = character self.left = left self.right = right self.bit = '' def calc_probability(data): chars = dict() for char in data: if chars.g...
def longestCommonPrefix(strs: [str]) -> str: n = len(strs) result = "" if not n: return result result = strs[0] for i in range(1, n): result = result[:len(strs[i])] result_len = len(result) for j in range(min(len(strs[i]), result_len)): if result[j] != str...
def longest_common_prefix(strs: [str]) -> str: n = len(strs) result = '' if not n: return result result = strs[0] for i in range(1, n): result = result[:len(strs[i])] result_len = len(result) for j in range(min(len(strs[i]), result_len)): if result[j] != s...
class Solution: def threeSum(self, nums: List[int]) -> List[List[int]]: solution = [] nums.sort() for i in range(len(nums)-2): if i > 0 and nums[i] == nums[i-1]: continue l = i + 1 r = len(nums) - 1 while l < r: ...
class Solution: def three_sum(self, nums: List[int]) -> List[List[int]]: solution = [] nums.sort() for i in range(len(nums) - 2): if i > 0 and nums[i] == nums[i - 1]: continue l = i + 1 r = len(nums) - 1 while l < r: ...
# Sets # Assignment 1 shop_groceries = {'coconuts', 'bananas', 'onions', 'spinach', 'tomatoes', 'cilantro', 'milk'} more_groceries = {'bread', 'chips', 'water bottles', 'lemon'} # Print shop_groceries print("shop_groceries : ", shop_groceries) # Add "onions" to shop_groceries shop_groceries.add("potatoes") print("sh...
shop_groceries = {'coconuts', 'bananas', 'onions', 'spinach', 'tomatoes', 'cilantro', 'milk'} more_groceries = {'bread', 'chips', 'water bottles', 'lemon'} print('shop_groceries : ', shop_groceries) shop_groceries.add('potatoes') print('shop_groceries : ', shop_groceries) shop_groceries.discard('coconuts') print('shop_...
add_library('ttslib') def setup(): size(100, 100) smooth() global tts tts = TTS() def draw(): background(255) fill(255) ellipse(35, 30, 25, 35) ellipse(65, 30, 25, 35) fill(0) ellipse(40, 35, 10, 10) ellipse(60, 35, 10, 10) noFill() arc(50, 50, 50, 50, 0, PI) de...
add_library('ttslib') def setup(): size(100, 100) smooth() global tts tts = tts() def draw(): background(255) fill(255) ellipse(35, 30, 25, 35) ellipse(65, 30, 25, 35) fill(0) ellipse(40, 35, 10, 10) ellipse(60, 35, 10, 10) no_fill() arc(50, 50, 50, 50, 0, PI) def ...
# -*- coding: utf-8 -*- class Solution: def findDuplicates(self, nums): result = [] for num in nums: i = abs(num) - 1 if nums[i] > 0: nums[i] = -nums[i] else: result.append(abs(num)) return result if __name__ == '__mai...
class Solution: def find_duplicates(self, nums): result = [] for num in nums: i = abs(num) - 1 if nums[i] > 0: nums[i] = -nums[i] else: result.append(abs(num)) return result if __name__ == '__main__': solution = solutio...
# -*- coding: utf-8 -*- class CredentialException(Exception): def __init__(self, message, code=None, request_id=None): self.code = code self.message = message self.request_id = request_id
class Credentialexception(Exception): def __init__(self, message, code=None, request_id=None): self.code = code self.message = message self.request_id = request_id
APPLICATION_LABEL = 'cog' PURPOSE_TYPES = ( 'Overall Project Coordination', 'Steering Committee', 'Design', 'Design and Implementation Review', 'Task Prioritization', 'Requirements Identification', 'S...
application_label = 'cog' purpose_types = ('Overall Project Coordination', 'Steering Committee', 'Design', 'Design and Implementation Review', 'Task Prioritization', 'Requirements Identification', 'Strategic Direction', 'External Review', 'Implementation', 'Meeting Planning', 'Testing', 'Knowledge Transfer', 'Grant Wri...
a=int(input('a: ')) b=int(input('b: ')) print(a if a >b else b)
a = int(input('a: ')) b = int(input('b: ')) print(a if a > b else b)
class Widget: def __init__(self, font=None, padding=0): self.font = font self.padding = padding def paint(self, canvas, dimension): pass
class Widget: def __init__(self, font=None, padding=0): self.font = font self.padding = padding def paint(self, canvas, dimension): pass
# -*- coding: utf-8 -*- class ArduMgrError(Exception): pass
class Ardumgrerror(Exception): pass
#Fake typing module for testing. class ComplexMetaclass(type): def __new__(self): pass class ComplexBaseClass(metaclass=ComplexMetaclass): def __new__(self): pass class _Optional(ComplexBaseClass, extras=...): def __new__(self): pass Optional = _Optional("Optional") class Col...
class Complexmetaclass(type): def __new__(self): pass class Complexbaseclass(metaclass=ComplexMetaclass): def __new__(self): pass class _Optional(ComplexBaseClass, extras=...): def __new__(self): pass optional = __optional('Optional') class Collections(ComplexBaseClass, extras=...
# -*- coding: utf-8 -*- # # Copyright (c) 2012-2015, CRS4 # # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify...
tables = {'HL70001': ('Sex', (('F', 'Female'), ('M', 'Male'), ('O', 'Other'), ('U', 'Unknown'))), 'HL70002': ('Marital status', (('A', 'Separated'), ('D', 'Divorced'), ('M', 'Married'), ('S', 'Single'), ('W', 'Widowed'))), 'HL70003': ('Event type', (('A01', 'ADT/ACK - Admit/visit notification'), ('A02', 'ADT/ACK - Tran...
# Copyright 2016, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the f...
single_machine_cores = 8 warmup_seconds = 5 java_warmup_seconds = 15 benchmark_seconds = 30 secure_secargs = {'use_test_ca': True, 'server_host_override': 'foo.test.google.fr'} histogram_params = {'resolution': 0.01, 'max_possible': 60000000000.0} empty_generic_payload = {'bytebuf_params': {'req_size': 0, 'resp_size': ...
def test_secure_false(app, client): app.config["SESSION_COOKIE_SECURE"] = False client.get("/store-in-session/k1/value1/") cookie = client.get_session_cookie() assert not cookie.secure def test_secure_true(app, client): app.config["SESSION_COOKIE_SECURE"] = True client.get("/store-in-session...
def test_secure_false(app, client): app.config['SESSION_COOKIE_SECURE'] = False client.get('/store-in-session/k1/value1/') cookie = client.get_session_cookie() assert not cookie.secure def test_secure_true(app, client): app.config['SESSION_COOKIE_SECURE'] = True client.get('/store-in-session/k1...
# Chance that the read pointer will deviate, forward or backward, # while writing to a genome. This drift causes mutations in the form # of duplications and deletions. chance_pointer_deviation = 0.1 # A deviation is equal to the integer paired with the lowest decimal # that is greater than random(). pointer_deviation_...
chance_pointer_deviation = 0.1 pointer_deviation_table = [(0.0015, -4), (0.025, -3), (0.16, -2), (0.5, -1), (0.84, 1), (0.975, 2), (0.9985, 3), (1, 4)]
def neighbors(v): pass def dfs(): path = [] beenTo = set() while len(path) > 0: v = path[-1] beenTo.add(v) for n in neighbors(v): if not n in beenTo: path.append(n) break else: path.pop()
def neighbors(v): pass def dfs(): path = [] been_to = set() while len(path) > 0: v = path[-1] beenTo.add(v) for n in neighbors(v): if not n in beenTo: path.append(n) break else: path.pop()
# ~/at-auto-test.py # This is valid Python, but it looks like a section reference. c = b = d = 0 a = b << c >> d # end.
c = b = d = 0 a = b << c >> d
def avg_by_dividable(data, divider): filtered_data = [x for x in data if x % divider == 0] return sum(filtered_data) / len(filtered_data) numbers = range(int(input()), int(input()) + 1) print(avg_by_dividable(numbers, 3))
def avg_by_dividable(data, divider): filtered_data = [x for x in data if x % divider == 0] return sum(filtered_data) / len(filtered_data) numbers = range(int(input()), int(input()) + 1) print(avg_by_dividable(numbers, 3))
# creating graphs using dicitonaries # Not working graph={'A':{'C','D','E'}} print(graph) # @TODO fix
graph = {'A': {'C', 'D', 'E'}} print(graph)
# basemessage.py class BaseMessage: pass class ByteStream(BaseMessage): pass class BGPMessage(BaseMessage): def __init__(self,tup): assert isinstance(tup,tuple) and len(tup) == 3 self.msg_type = tup[0] self.peer = tup[1] self.msg = tup[2] class WireMessage(bytearray): ...
class Basemessage: pass class Bytestream(BaseMessage): pass class Bgpmessage(BaseMessage): def __init__(self, tup): assert isinstance(tup, tuple) and len(tup) == 3 self.msg_type = tup[0] self.peer = tup[1] self.msg = tup[2] class Wiremessage(bytearray): pass if __name...
{ "targets": [ { "target_name" : "format.handler", "type" : "static_library", "sources" : [ "./format.handler/BinFormat.cpp", "./format.handler/TextFormat.cpp" ], "include_dirs": [ "./include" ], "conditions": [ ["OS==\"linux\"", { "cflags": [ "-g", "-m32", ...
{'targets': [{'target_name': 'format.handler', 'type': 'static_library', 'sources': ['./format.handler/BinFormat.cpp', './format.handler/TextFormat.cpp'], 'include_dirs': ['./include'], 'conditions': [['OS=="linux"', {'cflags': ['-g', '-m32', '-std=c++11', "-D__cdecl=''", "-D__stdcall=''"], 'include_dirs': ['<!(echo $R...
#!/usr/bin/env python # -*- coding: utf-8 -*- ## Baiqiang XIA implementation of data structures # singly linked list # implemented as seperated classes: node and list class sll_node(object): def __init__(self, val, nxt = None): self.data = val self.next = nxt class singlyLinkedList(object):...
class Sll_Node(object): def __init__(self, val, nxt=None): self.data = val self.next = nxt class Singlylinkedlist(object): def __init__(self, head=None): self.head = head def print_sll(self): cur = self.head cnt = 0 print('(head)', end='') while cu...
n = (int(input("Enter n: "))) print("Prime numbers less than",n,"are:") for x in range(n): if x > 1: for y in range(2,x): if (x % y) == 0: break else: print(x) input("Press any key to finish...")
n = int(input('Enter n: ')) print('Prime numbers less than', n, 'are:') for x in range(n): if x > 1: for y in range(2, x): if x % y == 0: break else: print(x) input('Press any key to finish...')
n=int(input()) num=n a={} x=0 count=0 while n!=0: r=n%10 n=int(n/10) a[x]=r for i in range(x): if(r==a[i]): count+=1 break x+=1 if count==0: print(str(num)+" is an Unique No.") else: print(str(num)+" is not an Unique No.")
n = int(input()) num = n a = {} x = 0 count = 0 while n != 0: r = n % 10 n = int(n / 10) a[x] = r for i in range(x): if r == a[i]: count += 1 break x += 1 if count == 0: print(str(num) + ' is an Unique No.') else: print(str(num) + ' is not an Unique No.')
def maior_de_dois(numero1, numero2): maior = int((numero1 + numero2 + abs(numero1-numero2))/2) return maior def entrada(): numeros = input().split(' ') a = int(numeros[0]) b = int(numeros[1]) c = int(numeros[2]) return a, b, c def maior_de_tres(a, b, c): if a >= c: maior_nume...
def maior_de_dois(numero1, numero2): maior = int((numero1 + numero2 + abs(numero1 - numero2)) / 2) return maior def entrada(): numeros = input().split(' ') a = int(numeros[0]) b = int(numeros[1]) c = int(numeros[2]) return (a, b, c) def maior_de_tres(a, b, c): if a >= c: maior_...
fin = open("input_02.txt") myinput = fin.readlines() valid_count = 0 for line in myinput: range_ , letter, pw = line.strip().split(' ') range_low, range_high = range_.split('-') letter = letter.split(':')[0] print(line, range_low, range_high, letter, pw) pos1 = (pw[int(range_low)-1] == letter) ...
fin = open('input_02.txt') myinput = fin.readlines() valid_count = 0 for line in myinput: (range_, letter, pw) = line.strip().split(' ') (range_low, range_high) = range_.split('-') letter = letter.split(':')[0] print(line, range_low, range_high, letter, pw) pos1 = pw[int(range_low) - 1] == letter ...
# def conta(s): # dct = {} # # for i in s: # dct[i] = dct.get(i, 0) + 1 # return dct # # # if __name__ == '__main__': # print(conta('artur')) def conta(s): ordenado = sorted(s) anterior = ordenado[0] contagem = 1 for i in ordenado[1:]: if i == anterior: conta...
def conta(s): ordenado = sorted(s) anterior = ordenado[0] contagem = 1 for i in ordenado[1:]: if i == anterior: contagem += 1 else: print(f'{anterior} : {contagem}') anterior = i contagem = 1 print(f'{anterior} : {contagem}') if __name_...
lista=[[1,2,3], [4,5,6], [7,8,9], [10,11,12]] for y in range(len(lista)): for x in range(len(lista[y])): print (lista[y][x])
lista = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]] for y in range(len(lista)): for x in range(len(lista[y])): print(lista[y][x])
#------------------------------------------------------------------------------- # # Project: ngEO Browse Server <http://ngeo.eox.at> # Authors: Fabian Schindler <fabian.schindler@eox.at> # Marko Locher <marko.locher@eox.at> # Stephan Meissl <stephan.meissl@eox.at> # #---------------------------------...
class Namespace(object): def __init__(self, uri): self._uri = uri self._lxml_uri = '{%s}' % uri @property def uri(self): return self._uri def __call__(self, tag): return self._lxml_uri + tag ns_rep = name_space('http://ngeo.eo.esa.int/ngEO/browseReport/1.0') ns_rep_old...
N = int(raw_input()) L = list(map(int, raw_input().split(" "))) ans = 0 L.sort() for i in range(1, N + 1): iv = i * i l = 0 h = len(L) - 1 best = 0 while l <= h: m = (l + h) // 2 if L[m] < iv: l = m + 1 else: h = m - 1 best = m ...
n = int(raw_input()) l = list(map(int, raw_input().split(' '))) ans = 0 L.sort() for i in range(1, N + 1): iv = i * i l = 0 h = len(L) - 1 best = 0 while l <= h: m = (l + h) // 2 if L[m] < iv: l = m + 1 else: h = m - 1 best = m ans = an...
# 2.03 Math # # We are using math to get the volume of a cube. # # By Shawn Velsor # 10/14/2020 # We are going to create a word problem, then do some stuff. print("Little Timmy is learning how to get the volume of a cube. Unfortunately, he's struggling to understand how " + "to get the volume of a cube. To show how...
print("Little Timmy is learning how to get the volume of a cube. Unfortunately, he's struggling to understand how " + 'to get the volume of a cube. To show how easy it is for him to do such a thing, ' + 'we will calculate the volume by adding 3 variables and calulating them.') print() x = float(input('Size for length: ...
class Solution: def fourSum(self, nums, target): quad = [] nums.sort() for i in range(0, len(nums) - 3): if i > 0 and nums[i] == nums[i - 1]: continue for j in range(i+1, len(nums) - 2): if j > (i + 1) and nums[j] == nums[j - 1]: ...
class Solution: def four_sum(self, nums, target): quad = [] nums.sort() for i in range(0, len(nums) - 3): if i > 0 and nums[i] == nums[i - 1]: continue for j in range(i + 1, len(nums) - 2): if j > i + 1 and nums[j] == nums[j - 1]: ...
def diff(num): sum_of_sq = 0 sq_of_sum = 0 for i in range(num+1): sum_of_sq += pow(i, 2) sq_of_sum += i sq_of_sum = pow(sq_of_sum, 2) return sq_of_sum - sum_of_sq print(diff(100))
def diff(num): sum_of_sq = 0 sq_of_sum = 0 for i in range(num + 1): sum_of_sq += pow(i, 2) sq_of_sum += i sq_of_sum = pow(sq_of_sum, 2) return sq_of_sum - sum_of_sq print(diff(100))
'''class Test: pass #'Just skip past this python' x = Test() Self will be referring to anything that is its own functions or variables (e.g. This function is attached to me, or this is my function). Make sure that the word self is used within the arguments of the function class ph: def printHam(...
"""class Test: pass #'Just skip past this python' x = Test() Self will be referring to anything that is its own functions or variables (e.g. This function is attached to me, or this is my function). Make sure that the word self is used within the arguments of the function class ph: def printHam(self): #firs...