content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
class Point: def __init__(self, x, y): self.x = x self.y = y def __str__(self): return "("+str(self.x)+","+str(self.y)+")" class Rect: def __init__(self, p1, p2): self.lowerleft = p1 self.upperright = p2 def area(self): dx = upperright.x - lowerleft.x ...
class Point: def __init__(self, x, y): self.x = x self.y = y def __str__(self): return '(' + str(self.x) + ',' + str(self.y) + ')' class Rect: def __init__(self, p1, p2): self.lowerleft = p1 self.upperright = p2 def area(self): dx = upperright.x - low...
FREQ = 10 # 1/delta_time based on recorded data SCENE_DUR = 5 # in seconds NUM_TS_PER_SCENE = FREQ * SCENE_DUR RADIUS_AROUND_AGENT = 50. # range to get surrounding objects, in meters ORDERED_COLUMNS = [ "timestamp", "id", "object_type", "center_x", "center_y", "heading", "status" ] # a ...
freq = 10 scene_dur = 5 num_ts_per_scene = FREQ * SCENE_DUR radius_around_agent = 50.0 ordered_columns = ['timestamp', 'id', 'object_type', 'center_x', 'center_y', 'heading', 'status'] max_workers = 5
# Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. { 'includes': [ '../../get_vivaldi_version.gypi' ], 'variables': { 'mac_product_name': 'Vivaldi', 'mac_packaging_dir': '<(PRODUC...
{'includes': ['../../get_vivaldi_version.gypi'], 'variables': {'mac_product_name': 'Vivaldi', 'mac_packaging_dir': '<(PRODUCT_DIR)/<(mac_product_name) Packaging', 'mac_packaging_sh_dir': '${BUILT_PRODUCTS_DIR}/<(mac_product_name) Packaging', 'mac_signing_key': '<!(echo $VIVALDI_SIGNING_KEY)', 'mac_signing_id': '<!(echo...
''' 2-CLAUSE BSD Copyright (c) 2017, apple502j All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of ...
""" 2-CLAUSE BSD Copyright (c) 2017, apple502j All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of condition...
#!/usr/bin/python # -*- coding: utf-8 -*- API_METHOD_PURCHASE='wallet.trade.buy' API_METHOD_REDEEM='wallet.trade.sell' API_METHOD_QUERY='wallet.trade.query' API_METHOD_CANCEL='wallet.trade.cancel' PAYMENT_STATUS_NOTSTARTED='Not Started' PAYMENT_STATUS_PAYSUCCESS='PaySuccess' PAYMENT_STATUS_SUCCESS='Success' PAYMENT_ST...
api_method_purchase = 'wallet.trade.buy' api_method_redeem = 'wallet.trade.sell' api_method_query = 'wallet.trade.query' api_method_cancel = 'wallet.trade.cancel' payment_status_notstarted = 'Not Started' payment_status_paysuccess = 'PaySuccess' payment_status_success = 'Success' payment_status_expiredinvalid = 'Expire...
# Problem name : Plus One # Problem link : https://leetcode.com/problems/plus-one/ # Contributor : Shreeraksha R Aithal class Solution: def plusOne(self, digits: List[int]) -> List[int]: n = len(digits) i = -1 carry = 1 while i>=-n: digits[i] = digits[i] + carry ...
class Solution: def plus_one(self, digits: List[int]) -> List[int]: n = len(digits) i = -1 carry = 1 while i >= -n: digits[i] = digits[i] + carry carry = digits[i] // 10 digits[i] = digits[i] % 10 i = i - 1 if carry > 0: ...
n = int(input()) a = list(map(int, input().split())) dp = [1] * n for i in range(1, len(a)): for j in range(i - 1, -1, -1): if a[j] == a[i]: dp[i] = max(dp[i], dp[j]) if a[j] < a[i]: dp[i] = max(dp[i], dp[j] + 1) print(max(dp)) print(dp)
n = int(input()) a = list(map(int, input().split())) dp = [1] * n for i in range(1, len(a)): for j in range(i - 1, -1, -1): if a[j] == a[i]: dp[i] = max(dp[i], dp[j]) if a[j] < a[i]: dp[i] = max(dp[i], dp[j] + 1) print(max(dp)) print(dp)
# https://leetcode.com/problems/deepest-leaves-sum/ # Definition for a binary tree node. class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def dl_sum_and_depth(root: TreeNode, depth: int) -> tuple[int, int]: if not roo...
class Treenode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def dl_sum_and_depth(root: TreeNode, depth: int) -> tuple[int, int]: if not root.left and (not root.right): return (root.val, depth) (left_sum, left_depth) =...
n, p, s = map(int, input().split()) sets = list() for _ in range(s): sets.append(input().split()[1:]) for s in sets: if str(p) in s: print('KEEP') else: print('REMOVE')
(n, p, s) = map(int, input().split()) sets = list() for _ in range(s): sets.append(input().split()[1:]) for s in sets: if str(p) in s: print('KEEP') else: print('REMOVE')
def iter(n): sum = 0 sum1 = 0 for i in range(0,n,1): sum += 7*pow(10,i) for j in range(1,n,1): sum1 = (pow(10,j+1)-10-(9*j))/81 x = sum + sum1 return x
def iter(n): sum = 0 sum1 = 0 for i in range(0, n, 1): sum += 7 * pow(10, i) for j in range(1, n, 1): sum1 = (pow(10, j + 1) - 10 - 9 * j) / 81 x = sum + sum1 return x
power = {'BUSES': {'Area': 1.33155, 'Bus/Area': 1.33155, 'Bus/Gate Leakage': 0.00662954, 'Bus/Peak Dynamic': 0.0, 'Bus/Runtime Dynamic': 0.0, 'Bus/Subthreshold Leakage': 0.0691322, 'Bus/Subthreshold Leakage with power gating': 0.0259246, 'Gate...
power = {'BUSES': {'Area': 1.33155, 'Bus/Area': 1.33155, 'Bus/Gate Leakage': 0.00662954, 'Bus/Peak Dynamic': 0.0, 'Bus/Runtime Dynamic': 0.0, 'Bus/Subthreshold Leakage': 0.0691322, 'Bus/Subthreshold Leakage with power gating': 0.0259246, 'Gate Leakage': 0.00662954, 'Peak Dynamic': 0.0, 'Runtime Dynamic': 0.0, 'Subthres...
#------------------------------------------------------------------------------- # Name: module1 # Purpose: # # Author: mo-mo- # # Created: 25/08/2018 # Copyright: (c) mo-mo- 2018 # Licence: <your licence> #------------------------------------------------------------------------------- ...
(n, k) = map(int, input().split()) x = list(map(int, input().split())) b = None for i in range(n): if x[i] == 0: b = i start = True break elif x[i] > 0: b = i start = False break if not b: m = abs(x[-k]) else: if start: del x[b] k -= 1 ...
pasta = "tomato, basil, garlic, salt, pasta, olive oil" apple_pie = "apple, sugar, salt, cinnamon, flour, egg, butter" ratatouille = "aubergine, carrot, onion, tomato, garlic, olive oil, pepper, salt" chocolate_cake = "chocolate, sugar, salt, flour, coffee, butter" omelette = "egg, milk, bacon, tomato, salt, pepper" wo...
pasta = 'tomato, basil, garlic, salt, pasta, olive oil' apple_pie = 'apple, sugar, salt, cinnamon, flour, egg, butter' ratatouille = 'aubergine, carrot, onion, tomato, garlic, olive oil, pepper, salt' chocolate_cake = 'chocolate, sugar, salt, flour, coffee, butter' omelette = 'egg, milk, bacon, tomato, salt, pepper' wo...
num1 = 1 num2 = 1 num3 = 200 num100 = 000000 num2 = 100 num4 = 000 num33 = 9998 age = 12 age1 = 123 hahah = 1320389
num1 = 1 num2 = 1 num3 = 200 num100 = 0 num2 = 100 num4 = 0 num33 = 9998 age = 12 age1 = 123 hahah = 1320389
# -*- coding: utf-8 -*- __author__ = 'Sumeet Kumar' __email__ = 'kr.sumeet@gmail.com' __version__ = '1.0.0'
__author__ = 'Sumeet Kumar' __email__ = 'kr.sumeet@gmail.com' __version__ = '1.0.0'
N = int(input()) A = list(map(int, input().split())) ans = 0 for i in range(N): if A[A[i]-1] == (i+1): ans += 1 print(ans//2)
n = int(input()) a = list(map(int, input().split())) ans = 0 for i in range(N): if A[A[i] - 1] == i + 1: ans += 1 print(ans // 2)
class Solution: def repeatedSubstringPattern(self, s: str) -> bool: ans="" temp="" for i in range(0,len(s)-1): temp+=s[i] if len(s)%len(temp)==0 and temp*int((len(s)/len(temp)))==s: print(temp) return 1 ...
class Solution: def repeated_substring_pattern(self, s: str) -> bool: ans = '' temp = '' for i in range(0, len(s) - 1): temp += s[i] if len(s) % len(temp) == 0 and temp * int(len(s) / len(temp)) == s: print(temp) return 1 retur...
# GYP file to build unit tests. { 'includes': [ 'apptype_console.gypi', ], 'targets': [ { 'target_name': 'pathops_unittest', 'type': 'executable', 'suppress_wildcard': '1', 'include_dirs' : [ '../src/core', '../src/effects', '../src/lazy', '../src/pa...
{'includes': ['apptype_console.gypi'], 'targets': [{'target_name': 'pathops_unittest', 'type': 'executable', 'suppress_wildcard': '1', 'include_dirs': ['../src/core', '../src/effects', '../src/lazy', '../src/pathops', '../src/pdf', '../src/pipe/utils', '../src/utils', '../tools/'], 'includes': ['pathops_unittest.gypi']...
# ============================================================================= # # ============================================================================= x =[1,2,5]+ [3,4] x.sort() # ============================================================================= # # ===========================================...
x = [1, 2, 5] + [3, 4] x.sort() a = [[1, 2], [3, 4]] find_matrix(a) def find_matrix(a): n_rows = len(a) n_cols = len(a[0]) for row in range(n_rows): for col in range(n_cols): if row == 0 and col == 0: pass elif row == 0 and col != 0: a[row][co...
class Solution: def groupAnagrams(self, strs: list) -> list: hashmap = {} for s in strs: key = ''.join(sorted(s)) if key in hashmap: hashmap[key] += [s] else: hashmap[key] = [s] return hashmap.values() v = Solution().group...
class Solution: def group_anagrams(self, strs: list) -> list: hashmap = {} for s in strs: key = ''.join(sorted(s)) if key in hashmap: hashmap[key] += [s] else: hashmap[key] = [s] return hashmap.values() v = solution().group...
#!/usr/bin/python # arithmetic.py a = 10 b = 11 c = 12 add = a + b + c sub = c - a mult = a * b div = c / 3 power = (a ** 2) print (add, sub, mult, div) print (power)
a = 10 b = 11 c = 12 add = a + b + c sub = c - a mult = a * b div = c / 3 power = a ** 2 print(add, sub, mult, div) print(power)
# # LeetCode # # Problem - 206 # URL - https://leetcode.com/problems/reverse-linked-list/ # # Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def reverseList(self, head: ListNode) -> ListNode: an...
class Solution: def reverse_list(self, head: ListNode) -> ListNode: ans_node = None while head != None: ans_node = list_node(head.val, ansNode) head = head.next return ansNode
# # PySNMP MIB module ARISTA-NEXTHOP-GROUP-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ARISTA-NEXTHOP-GROUP-MIB # Produced by pysmi-0.3.4 at Wed May 1 11:25:06 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7....
(arista_mibs,) = mibBuilder.importSymbols('ARISTA-SMI-MIB', 'aristaMibs') (integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_range_constraint, constraints_union, ...
class Message: def __init__(self, chat_id=""): self.chat_id = chat_id def set_text(self, text, parse_mode=None, disable_web_page_preview=None, disable_notification=None, reply_to_message_id=None, reply_markup=None): self.text = text self.content_type = "text" se...
class Message: def __init__(self, chat_id=''): self.chat_id = chat_id def set_text(self, text, parse_mode=None, disable_web_page_preview=None, disable_notification=None, reply_to_message_id=None, reply_markup=None): self.text = text self.content_type = 'text' self.parse_mode = ...
# -*- coding: utf-8 -*- __email__ = '{{ cookiecutter.author_email }}' __author__ = '{{ cookiecutter.author_name }}' __version__ = '0.0.1'
__email__ = '{{ cookiecutter.author_email }}' __author__ = '{{ cookiecutter.author_name }}' __version__ = '0.0.1'
#x = "awesome" def myfunc(): print("Python is " + x) #myfunc() '''''''''''''''''''''''''''''''''''' x = "awesome" def myfunc2(): x = "fantastic" print("Python is " + x) myfunc2() print("Python is " + x)
def myfunc(): print('Python is ' + x) '' x = 'awesome' def myfunc2(): x = 'fantastic' print('Python is ' + x) myfunc2() print('Python is ' + x)
#!/usr/bin/env python array = [ { 'fips': '01', 'abbr': 'AL', 'name': 'Alabama', }, { 'fips': '02', 'abbr': 'AK', 'name': 'Alaska', }, { 'fips': '04', 'abbr': 'AZ', 'name': 'Arizona', }, { 'fips': '05', 'abbr': 'AR', 'name': 'Arkansas', }, { 'fips': '06', 'abbr': 'CA', 'name': 'C...
array = [{'fips': '01', 'abbr': 'AL', 'name': 'Alabama'}, {'fips': '02', 'abbr': 'AK', 'name': 'Alaska'}, {'fips': '04', 'abbr': 'AZ', 'name': 'Arizona'}, {'fips': '05', 'abbr': 'AR', 'name': 'Arkansas'}, {'fips': '06', 'abbr': 'CA', 'name': 'California'}, {'fips': '08', 'abbr': 'CO', 'name': 'Colorado'}, {'fips': '09'...
class Solution: def isPrefixOfWord(self, sentence: str, searchWord: str) -> int: for i, w in enumerate(sentence.split(" ")): if w.startswith(searchWord): return i + 1 return -1
class Solution: def is_prefix_of_word(self, sentence: str, searchWord: str) -> int: for (i, w) in enumerate(sentence.split(' ')): if w.startswith(searchWord): return i + 1 return -1
print(", ".join(["spam", "eggs", "ham"])) #prints "spam, eggs, ham" print("Hello ME".replace("ME", "world")) #prints "Hello world" print("This is a sentence.".startswith("This")) # prints "True" print("This is a sentence.".endswith("sentence.")) # prints "True" print("This is a sentence.".upper()) # prints "THIS IS...
print(', '.join(['spam', 'eggs', 'ham'])) print('Hello ME'.replace('ME', 'world')) print('This is a sentence.'.startswith('This')) print('This is a sentence.'.endswith('sentence.')) print('This is a sentence.'.upper()) print('AN ALL CAPS SENTENCE'.lower()) print('spam, eggs, ham'.split(', '))
# Write redmonster output files # # Tim Hutchinson, , University of Utah, April 2014 # t.hutchinson@utah.edu # # July 2014 - now probably defunct, replaced by redmonster.datamgr.io.py class Output: def __init__(self, spec=None): if spec: self.set_filenames() def set_filenames(self): self.zall...
class Output: def __init__(self, spec=None): if spec: self.set_filenames() def set_filenames(self): self.zallfile = 'spZall-%s-%s.fits' % (spec.plate, spec.mjd) self.zbestfile = 'spZbest-%s-%s.fits' % (spec.plate, spec.mjd) self.zlinefile = 'spZline-%s-%s.fits' % (s...
class SplitterNotifier: def __init__(self, notifiers=None): if notifiers is None: notifiers = [] self.notifiers = notifiers def notify(self, notification, text, options=None): if options is None: options = {} for notifier in self.notifiers: no...
class Splitternotifier: def __init__(self, notifiers=None): if notifiers is None: notifiers = [] self.notifiers = notifiers def notify(self, notification, text, options=None): if options is None: options = {} for notifier in self.notifiers: n...
x=2 def increment(number): return number + 1
x = 2 def increment(number): return number + 1
LOGIN_PHASES = [ 'WaitingForAuthentication', 'WaitingForEula', 'Done', 'Disabled', 'Login', '', ] WAIT_FOR_LAUNCH_PHASES = [ 'WaitForLaunch', ] SUCCESS_PHASES = [ 'WaitForSessionExit', ] EULA_PHASES = [ 'Eula', ] CONSENT_REQUIRED_PHASES = [ 'AgeRestriction', ] BANNED_PHASES ...
login_phases = ['WaitingForAuthentication', 'WaitingForEula', 'Done', 'Disabled', 'Login', ''] wait_for_launch_phases = ['WaitForLaunch'] success_phases = ['WaitForSessionExit'] eula_phases = ['Eula'] consent_required_phases = ['AgeRestriction'] banned_phases = [] account_alias_change_phase = ['AccountAlias'] region_mi...
#!/usr/bin/python3 # -*- coding: utf-8 -*- ''' Class Parser parses clingo output ''' class Parser: next_line_facts = False def process_facts(self, facts): facts = facts.split(" ") facts.sort() return facts def process_line(self, line, model): line = line.replace("\n", "") ...
""" Class Parser parses clingo output """ class Parser: next_line_facts = False def process_facts(self, facts): facts = facts.split(' ') facts.sort() return facts def process_line(self, line, model): line = line.replace('\n', '') if 'reading' in line.lower(): ...
def turn_right(): turn_left() turn_left() turn_left() def jump(): move() turn_left() move() turn_right() move() turn_right() move() turn_left() while not at_goal(): jump()
def turn_right(): turn_left() turn_left() turn_left() def jump(): move() turn_left() move() turn_right() move() turn_right() move() turn_left() while not at_goal(): jump()
# parsetab.py # This file is automatically generated. Do not edit. # pylint: disable=W,C,R _tabversion = '3.10' _lr_method = 'LALR' _lr_signature = 'leftANDORleftPLUSMINUSleftTIMESDIVIDErightUMINUSleftLPARENRPARENAND DIVIDE FLOAT GE GT ID IE IN LE LIST LPAREN LT MINUS NE NONE NOT NUMBER OR PLUS RPAREN STR TIMES\n ...
_tabversion = '3.10' _lr_method = 'LALR' _lr_signature = 'leftANDORleftPLUSMINUSleftTIMESDIVIDErightUMINUSleftLPARENRPARENAND DIVIDE FLOAT GE GT ID IE IN LE LIST LPAREN LT MINUS NE NONE NOT NUMBER OR PLUS RPAREN STR TIMES\n expr : expr PLUS expr\n | expr MINUS expr\n | expr TIMES expr\n ...
DEFINITIONS={ "cc_clone_detection_big_clone_bench": { "class_name": "CodeXGlueCCCloneDetectionBigCloneBench", "data_dir_name": "dataset", "dataset_type": "Code-Code", "description": "CodeXGLUE Clone-detection-BigCloneBench dataset, available at https://github.com/microsoft/CodeXGLUE/...
definitions = {'cc_clone_detection_big_clone_bench': {'class_name': 'CodeXGlueCCCloneDetectionBigCloneBench', 'data_dir_name': 'dataset', 'dataset_type': 'Code-Code', 'description': 'CodeXGLUE Clone-detection-BigCloneBench dataset, available at https://github.com/microsoft/CodeXGLUE/tree/main/Code-Code/Clone-detection-...
################################## # import_file.json # ################################## attributes = { "type": "array", "items": { "type": "object", "properties": {"id": {"type": "integer"}, "groupId": {"type": "integer"}}, "required": ["id", "groupId"], }, } bbox ...
attributes = {'type': 'array', 'items': {'type': 'object', 'properties': {'id': {'type': 'integer'}, 'groupId': {'type': 'integer'}}, 'required': ['id', 'groupId']}} bbox = {'$id': 'https://darwin.v7labs.com/schemas/supperannotate/bounding_box', 'description': 'Schema of a Bounding Box', 'title': 'Bounding Box', 'defau...
s = list(map(int, input().split())) for i in range(1, len(s)): if s[i] > s[i - 1]: print(s[i], end=' ')
s = list(map(int, input().split())) for i in range(1, len(s)): if s[i] > s[i - 1]: print(s[i], end=' ')
class Solution: def climbStairs(self, n: int) -> int: if(n==1): return 1 dp = [0] * (n+1) dp[1] = 1 dp[2] = 2 for i in range(3,n+1): dp[i] = dp[i-1] + dp[i-2] return dp[n]
class Solution: def climb_stairs(self, n: int) -> int: if n == 1: return 1 dp = [0] * (n + 1) dp[1] = 1 dp[2] = 2 for i in range(3, n + 1): dp[i] = dp[i - 1] + dp[i - 2] return dp[n]
num1 = int(input("Please input num1: ")) num2 = int(input("Please input num2: ")) num3 = int(input("Please input num3: ")) num4 = int(input("Please input num4: ")) num5 = int(input("Please input num5: ")) num6 = int(input("Please input num6: ")) s = num1 + num2 + num3 + num4 + num5 + num6 print("sum: {}".forma...
num1 = int(input('Please input num1: ')) num2 = int(input('Please input num2: ')) num3 = int(input('Please input num3: ')) num4 = int(input('Please input num4: ')) num5 = int(input('Please input num5: ')) num6 = int(input('Please input num6: ')) s = num1 + num2 + num3 + num4 + num5 + num6 print('sum: {}'.format(s))
q=int(input()) if(1>q or q>10): exit def isAnagram(par1,par2): par1.sort() par2.sort() # print(len(par1)) for i in range(len(par1)): if(par1[i]!=par2[i]): return False return True def init(): strings=[] count=0 q=int(globals()['q']) while(q!=0): st...
q = int(input()) if 1 > q or q > 10: exit def is_anagram(par1, par2): par1.sort() par2.sort() for i in range(len(par1)): if par1[i] != par2[i]: return False return True def init(): strings = [] count = 0 q = int(globals()['q']) while q != 0: strings.appe...
_base_ = [ '../_base_/datasets/icip.py', '../_base_/default_runtime.py', '../_base_/schedules/schedule_40k.py' ] # model settings norm_cfg = dict(type='BN', requires_grad=True) model = dict( type='EncoderDecoder', pretrained=None, backbone=dict( type='ResNetV1c', depth=50, n...
_base_ = ['../_base_/datasets/icip.py', '../_base_/default_runtime.py', '../_base_/schedules/schedule_40k.py'] norm_cfg = dict(type='BN', requires_grad=True) model = dict(type='EncoderDecoder', pretrained=None, backbone=dict(type='ResNetV1c', depth=50, num_stages=4, out_indices=(0, 1, 2, 3), dilations=(1, 1, 1, 1), str...
# # PySNMP MIB module CISCO-ENTITY-SENSOR-EXT-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-ENTITY-SENSOR-EXT-MIB # Produced by pysmi-0.3.4 at Wed May 1 11:57:12 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python versio...
(octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_size_constraint, constraints_intersection, value_range_constraint, constraints_union, single_value_constraint) ...
def binary_search(array, target): start_index = 0 end_index = len(array) - 1 while start_index <= end_index: mid_index = (start_index + end_index) // 2 # integer division in Python 3 mid_element = array[mid_index] if target == mid_element: # we have found the element ...
def binary_search(array, target): start_index = 0 end_index = len(array) - 1 while start_index <= end_index: mid_index = (start_index + end_index) // 2 mid_element = array[mid_index] if target == mid_element: return mid_index elif target < mid_element: ...
#!/usr/bin/python3 # code_generator.py def add_layers(layers): return_string = '''model = tf.keras.Sequential()\n''' for layer in layers: if layer['type'] == 'dense': if layer['activation_function'] is not None: return_string += '''model.add(tf.keras.layers.Dense(units={uni...
def add_layers(layers): return_string = 'model = tf.keras.Sequential()\n' for layer in layers: if layer['type'] == 'dense': if layer['activation_function'] is not None: return_string += "model.add(tf.keras.layers.Dense(units={units}, activation='{activation}', \n ...
#Iris Data sorted into columns #Hugh O'Reilly 04/03/18 with open("data/iris.csv") as f: #Opens Iris data set csv file in data folder for line in f:# loops through each line line = line.replace(',', ' ') #replaces comma with space, code from Mohamed Noor line = line.rstrip() #Removes nextline code o...
with open('data/iris.csv') as f: for line in f: line = line.replace(',', ' ') line = line.rstrip() print(line.split(',')[:]) for column in f: print(f.read())
#Euler Problem 5 Lowest common multiple # Michael Garvey # credits: https://gist.github.com/PEZ/47534 i = 1 for k in (range(1, 21)): #using range to test numbers 1 to 20 if i % k > 0: for j in range(1, 21): if (i*j) % k == 0: i *= j break print (i)
i = 1 for k in range(1, 21): if i % k > 0: for j in range(1, 21): if i * j % k == 0: i *= j break print(i)
def mergeSort(array): print(f"Splitting the array {array}") if len(array)>1: mid = len(array)//2 lefthalf = array[:mid] righthalf = array[mid:] mergeSort(lefthalf) mergeSort(righthalf) i=j=k=0 while i < len(lefthalf) and j < len(righthalf): ...
def merge_sort(array): print(f'Splitting the array {array}') if len(array) > 1: mid = len(array) // 2 lefthalf = array[:mid] righthalf = array[mid:] merge_sort(lefthalf) merge_sort(righthalf) i = j = k = 0 while i < len(lefthalf) and j < len(righthalf): ...
# def add(num1, num2): # # just put these initial values down to the length # x = len(str(num1)) # y = len(str(num2)) # z = 0 # if x >= y : # for k in range(0,x): # z = z + int(num1/(10**x)) + int(num2/(10**x)) # else: # for k in range(0,y): # z = z + i...
def add(num1, num2): x = num1 - int(num1 / 10) * 10 y = num2 - int(num2 / 10) * 10 if x == 0 and y == 0: z = num1 + num2 elif x == 0: z = num1 + y elif y == 0: z = x + num2 else: z = x + y a = len(str(num1)) - 1 b = len(str(num2)) - 1 c = int(num1 / 10...
class HTTP404(Exception): def __init__(self): super(HTTP404, self).__init__() self.code = 404 def __str__(self): return "404: Page Not Found" def __repr__(self): return self.__str__()
class Http404(Exception): def __init__(self): super(HTTP404, self).__init__() self.code = 404 def __str__(self): return '404: Page Not Found' def __repr__(self): return self.__str__()
version='' commithash='64db13864cb1b377c8a9ab7c08e4688d3d1f94ef' gittag_short='' gittag_long='64db138-dirty' git_lastmod='Mon, 15 May 2017 14:34:53 +0200' github_url='https://github.com/plasmodic/ecto' breathe_default_project = 'ecto' breathe_projects = dict(ecto='/home/arnaud.duhamel/qidata/python-ecto/build/temp.lin...
version = '' commithash = '64db13864cb1b377c8a9ab7c08e4688d3d1f94ef' gittag_short = '' gittag_long = '64db138-dirty' git_lastmod = 'Mon, 15 May 2017 14:34:53 +0200' github_url = 'https://github.com/plasmodic/ecto' breathe_default_project = 'ecto' breathe_projects = dict(ecto='/home/arnaud.duhamel/qidata/python-ecto/bui...
# This problem was recently asked by Apple: # You are given a binary tree representation of an arithmetic expression. # In this tree, each leaf is an integer value,, and a non-leaf node is one of the four operations: '+', '-', '*', or '/'. # Write a function that takes this tree and evaluates the expression. class No...
class Node: def __init__(self, val, left=None, right=None): self.val = val self.left = left self.right = right plus = '+' minus = '-' times = '*' divide = '/' def evaluate(root): if root is None: return 0 if root.left is None and root.right is None: return int(root....
image = io.imread('../img/skimage-logo.png') # --- assign each color channel to a different variable --- r = image[:, :, 0] g = image[:, :, 1] b = image[:, :, 2]
image = io.imread('../img/skimage-logo.png') r = image[:, :, 0] g = image[:, :, 1] b = image[:, :, 2]
# # PySNMP MIB module MGMT-SECURITY-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/MGMT-SECURITY-MIB # Produced by pysmi-0.3.4 at Wed May 1 14:11:54 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Ma...
(integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (single_value_constraint, value_range_constraint, constraints_union, constraints_intersection, value_size_constraint) ...
# Copyright 2019 Graphcore Ltd. class NullContextManager(object): def __enter__(self): pass def __exit__(self, *args): pass
class Nullcontextmanager(object): def __enter__(self): pass def __exit__(self, *args): pass
#Global parameters module N = 1024 K = 16 Q = 12289 POLY_BYTES = 1792 NEWHOPE_SEEDBYTES = 32 NEWHOPE_RECBYTES = 256 NEWHOPE_SENDABYTES = POLY_BYTES + NEWHOPE_SEEDBYTES NEWHOPE_SENDBBYTES = POLY_BYTES + NEWHOPE_RECBYTES
n = 1024 k = 16 q = 12289 poly_bytes = 1792 newhope_seedbytes = 32 newhope_recbytes = 256 newhope_sendabytes = POLY_BYTES + NEWHOPE_SEEDBYTES newhope_sendbbytes = POLY_BYTES + NEWHOPE_RECBYTES
# Hacked from winnt.h DELETE = (65536) READ_CONTROL = (131072) WRITE_DAC = (262144) WRITE_OWNER = (524288) SYNCHRONIZE = (1048576) STANDARD_RIGHTS_REQUIRED = (983040) STANDARD_RIGHTS_READ = (READ_CONTROL) STANDARD_RIGHTS_WRITE = (READ_CONTROL) STANDARD_RIGHTS_EXECUTE = (READ_CONTROL) STANDARD_RIGHTS_ALL = (2031616) SP...
delete = 65536 read_control = 131072 write_dac = 262144 write_owner = 524288 synchronize = 1048576 standard_rights_required = 983040 standard_rights_read = READ_CONTROL standard_rights_write = READ_CONTROL standard_rights_execute = READ_CONTROL standard_rights_all = 2031616 specific_rights_all = 65535 access_system_sec...
#Challenge 1 num = 1 while num < 11: print(num) num += 1 #Challenge 2 chosenNum = input('Enter a number: ') modifier = 1 chosenNum = int(chosenNum) for count in range(1, chosenNum, 1): chosenNum += count print (chosenNum) #Challenge 3 for count in range(1500, 2701, 1): if (count % 7 == 0 and ...
num = 1 while num < 11: print(num) num += 1 chosen_num = input('Enter a number: ') modifier = 1 chosen_num = int(chosenNum) for count in range(1, chosenNum, 1): chosen_num += count print(chosenNum) for count in range(1500, 2701, 1): if count % 7 == 0 and count % 5 == 0: print(count) for count in...
#! /home/nsanthony/anaconda3/bin/python num_of_primes = 10000 prime_num_count = 0 primes = [0]*num_of_primes i = 1 #starting prime while prime_num_count < num_of_primes: i += 1 divisible = 1 k = 0 while k < prime_num_count: if(i % primes[k] == 0): #modulus divisible = 0 ...
num_of_primes = 10000 prime_num_count = 0 primes = [0] * num_of_primes i = 1 while prime_num_count < num_of_primes: i += 1 divisible = 1 k = 0 while k < prime_num_count: if i % primes[k] == 0: divisible = 0 break else: k += 1 if divisible != 0: ...
string = input().upper() if string.count('AUGUST')>=1: print('NOU') else: string = ''.join(reversed(string)).replace('A','S') print(string)
string = input().upper() if string.count('AUGUST') >= 1: print('NOU') else: string = ''.join(reversed(string)).replace('A', 'S') print(string)
n_odds = -1 for i in range(0, 14, 2): # Check for the value of i in each iteration breakpoint() # Bad condition if i % 1 == 0: n_odds += 0 print(n_odds)
n_odds = -1 for i in range(0, 14, 2): breakpoint() if i % 1 == 0: n_odds += 0 print(n_odds)
class PublicClass: pass class _PrivateClass: pass def public_function(): pass def _private_function(): pass
class Publicclass: pass class _Privateclass: pass def public_function(): pass def _private_function(): pass
test_image = plt.imread(os.path.join('test_images', 'test4.jpg')) undistorted_img = cv2.undistort(test_image, mtx, dist) thresh_binary = func(image) img_size = (thresh_binary.shape[1], thresh_binary.shape[0]) width, height = img_size offset = 200 src = np.float32([ [ 588, 446 ], [ 691, 446 ], [ 112...
test_image = plt.imread(os.path.join('test_images', 'test4.jpg')) undistorted_img = cv2.undistort(test_image, mtx, dist) thresh_binary = func(image) img_size = (thresh_binary.shape[1], thresh_binary.shape[0]) (width, height) = img_size offset = 200 src = np.float32([[588, 446], [691, 446], [1126, 673], [153, 673]]) dst...
age = 3 admission_fee = (0,25,40) if age < 4: print(f"Your admission fee is ${admission_fee[0]}, welcome to the park!") elif age < 18: print(f"Your admission fee is ${admission_fee[1]}, welcome to the park!") else: print(f"You're a senior so your fee is ${admission_fee[2]}, Welcome!!")
age = 3 admission_fee = (0, 25, 40) if age < 4: print(f'Your admission fee is ${admission_fee[0]}, welcome to the park!') elif age < 18: print(f'Your admission fee is ${admission_fee[1]}, welcome to the park!') else: print(f"You're a senior so your fee is ${admission_fee[2]}, Welcome!!")
# Copyright (c) 2019 Pavel Vavruska # 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, merge, publish, d...
class Map: def __init__(self): self.__map_base = [[10, 10, 10, 10, 10, 10, 12, 12, 12, 12, 12, 12, 12, 12, 14, 14, 14, 14, 14, 14], [10, -1, 0, -1, -1, 10, 12, -1, -1, -1, -1, -1, -1, 12, 14, -1, -1, -1, -1, 14], [10, -1, -1, -1, -1, 10, 12, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 14], [10, -1, -1,...
dict={11:"th", 12:"th", 13:"th", 1:"st", 2:"nd", 3:"rd"} def what_century(year): year=str(year) century=int(year[:2])+1 if year[-2:]!="00" else int(year[:2]) if century in dict: return f"{century}{dict[century]}" elif century%10 in dict: return f"{century}{dict[century%10]}" return f...
dict = {11: 'th', 12: 'th', 13: 'th', 1: 'st', 2: 'nd', 3: 'rd'} def what_century(year): year = str(year) century = int(year[:2]) + 1 if year[-2:] != '00' else int(year[:2]) if century in dict: return f'{century}{dict[century]}' elif century % 10 in dict: return f'{century}{dict[century...
class Solution: def judgeCircle(self, moves: str) -> bool: h_pos = 0 v_pos = 0 for move in moves: if move == 'U': v_pos += 1 elif move == 'D': v_pos -= 1 elif move == 'L': h_pos -= 1 elif...
class Solution: def judge_circle(self, moves: str) -> bool: h_pos = 0 v_pos = 0 for move in moves: if move == 'U': v_pos += 1 elif move == 'D': v_pos -= 1 elif move == 'L': h_pos -= 1 elif move =...
morning = {'Java', 'C', 'Ruby', 'Lisp', 'C#'} afternoon = {'Python', 'C#', 'Java', 'C', 'Ruby'} print(morning ^ afternoon) print(morning.symmetric_difference(afternoon))
morning = {'Java', 'C', 'Ruby', 'Lisp', 'C#'} afternoon = {'Python', 'C#', 'Java', 'C', 'Ruby'} print(morning ^ afternoon) print(morning.symmetric_difference(afternoon))
# https://www.hackerrank.com/challenges/equal-stacks def equal_stacks(stacks): stacks_size = [sum(stack) for stack in stacks] while len(set(stacks_size)) > 1: higher = stacks_size.index(max(stacks_size)) poped = stacks[higher].pop(0) stacks_size[higher] -= poped return stacks_size...
def equal_stacks(stacks): stacks_size = [sum(stack) for stack in stacks] while len(set(stacks_size)) > 1: higher = stacks_size.index(max(stacks_size)) poped = stacks[higher].pop(0) stacks_size[higher] -= poped return stacks_size[0] (n1, n2, n3) = map(int, input().strip().split(' ')) ...
#!/usr/env/bin python3 # #----------------------------------------------------------------------- # # Mathematical and physical constants. # #----------------------------------------------------------------------- # # Pi. pi_geom = 3.14159265358979323846264338327 # Degrees per radian. degs_per_radian = 360.0 / (2.0 ...
pi_geom = 3.141592653589793 degs_per_radian = 360.0 / (2.0 * pi_geom) radius__earth = 6371200.0 valid_vals_boolean = [True, False]
x = 1 for i in range (0, 5): y = 7 for j in range (0, 3): print(f"I={x} J={y}") y -= 1 x += 2
x = 1 for i in range(0, 5): y = 7 for j in range(0, 3): print(f'I={x} J={y}') y -= 1 x += 2
n = int(input("enter a no: ")) for i in range (n*10, n-1 ,-n): print(i)
n = int(input('enter a no: ')) for i in range(n * 10, n - 1, -n): print(i)
class Solution: def minRemoveToMakeValid(self, s: str) -> str: stack = [] bad = set() for index, c in enumerate(s): if c == "(": stack.append(index) elif c == ")": if len(stack) > 0: stack.pop() els...
class Solution: def min_remove_to_make_valid(self, s: str) -> str: stack = [] bad = set() for (index, c) in enumerate(s): if c == '(': stack.append(index) elif c == ')': if len(stack) > 0: stack.pop() ...
# # Copyright (C) 2018 The Android Open Source Project # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable la...
layout = bool_scalar('layout', False) i1 = input('op1', 'TENSOR_FLOAT32', '{1, 3, 3, 2}') f1 = parameter('op2', 'TENSOR_FLOAT32', '{1, 2, 2, 4}', [0.25, 0.0, 0.2, 0.0, 0.25, 0.0, 0.0, 0.3, 0.25, 0.0, 0.0, 0.0, 0.25, 0.1, 0.0, 0.0]) b1 = parameter('op3', 'TENSOR_FLOAT32', '{4}', [1, 2, 3, 4]) o1 = output('op4', 'TENSOR_...
class Arrival: def __init__(self, time_from_stop, dist_from_stop): self.time_from_stop = time_from_stop self.dist_from_stop = dist_from_stop def __repr__(self): return f'''{self.__class__.__name__}( {self.time_from_stop!r}, {self.dist_from_stop!r})''' def __str__(self)...
class Arrival: def __init__(self, time_from_stop, dist_from_stop): self.time_from_stop = time_from_stop self.dist_from_stop = dist_from_stop def __repr__(self): return f'{self.__class__.__name__}(\n {self.time_from_stop!r}, {self.dist_from_stop!r})' def __str__(self): ...
ES_HOST = 'localhost:9200' ES_INDEX = 'pending-cord_cell' ES_DOC_TYPE = 'cell' API_PREFIX = 'cord_cell' API_VERSION = ''
es_host = 'localhost:9200' es_index = 'pending-cord_cell' es_doc_type = 'cell' api_prefix = 'cord_cell' api_version = ''
num1 = 11 num2 = 22 num3 = 33 num4 = 44 num5 = 55 num6 = 66 num7 = 77 num8 = 88 num10 = 100 numm11 = 111
num1 = 11 num2 = 22 num3 = 33 num4 = 44 num5 = 55 num6 = 66 num7 = 77 num8 = 88 num10 = 100 numm11 = 111
class Instrumentable (object): def __init__(self): self.instrumentation = [] def add_instrumentation(self, ins): self.instrumentation.append(ins) def get_context(self): return [] def initialize_instrumentation(self): for i in self.instrumentation: i.ini...
class Instrumentable(object): def __init__(self): self.instrumentation = [] def add_instrumentation(self, ins): self.instrumentation.append(ins) def get_context(self): return [] def initialize_instrumentation(self): for i in self.instrumentation: i.initial...
model = dict( type='FasterRCNN', pretrained='open-mmlab://msra/hrnetv2_w32', backbone=dict( type='HRNet', extra=dict( stage1=dict( num_modules=1, num_branches=1, block='BOTTLENECK', num_blocks=(4, ), ...
model = dict(type='FasterRCNN', pretrained='open-mmlab://msra/hrnetv2_w32', backbone=dict(type='HRNet', extra=dict(stage1=dict(num_modules=1, num_branches=1, block='BOTTLENECK', num_blocks=(4,), num_channels=(64,)), stage2=dict(num_modules=1, num_branches=2, block='BASIC', num_blocks=(4, 4), num_channels=(32, 64)), sta...
# Create by Zwlin parts = ['Is', 'Chicago', 'Not', 'Chicago?'] print(' '.join(parts)) data = ['ACME', 50, 91.1] print(','.join(str(d) for d in data)) print('a','b','c',sep=":") def sample(): yield 'Is' yield 'Chicago' yield 'Not' yield 'Chicago?' print(' '.join(sample())) def combine(source,maxsi...
parts = ['Is', 'Chicago', 'Not', 'Chicago?'] print(' '.join(parts)) data = ['ACME', 50, 91.1] print(','.join((str(d) for d in data))) print('a', 'b', 'c', sep=':') def sample(): yield 'Is' yield 'Chicago' yield 'Not' yield 'Chicago?' print(' '.join(sample())) def combine(source, maxsize): parts = ...
bot1_wieght_layer_one = [[0.9236090789486788, 0.9210637151227483, 0.16119690767556938, 0.8891669007445379, 0.7530696859511529, 0.9684743676682231, 0.9140001906787625, 0.5462343790375778, 0.4625067913831683, 0.10294585839313619, 0.4659734634943964, 0.673851063496881, 0.4119975257359164, 0.4119836779033137, 0.78659108761...
bot1_wieght_layer_one = [[0.9236090789486788, 0.9210637151227483, 0.16119690767556938, 0.8891669007445379, 0.7530696859511529, 0.9684743676682231, 0.9140001906787625, 0.5462343790375778, 0.4625067913831683, 0.10294585839313619, 0.4659734634943964, 0.673851063496881, 0.4119975257359164, 0.4119836779033137, 0.78659108761...
# Copyright (c) 2018, WSO2 Inc. (http://wso2.com) 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 ap...
ns = {'d': 'http://maven.apache.org/POM/4.0.0'} zip_file_extension = '.zip' carbon_name = 'carbon.zip' wso2_server = 'bin/wso2server' value_tag = '{http://maven.apache.org/POM/4.0.0}value' surface_plugin_artifact_id = 'maven-surefire-plugin' product_storage_dir_name = 'storage' deployment_property_file_name = 'deployme...
class A: def __init__(self): self.l=[1,2,3,4,5,6,7,8,9] def __getitem__(self,i): if isinstance(i,int): return self.l[i] else: print(i.start,i.stop,i.step) return self.l[i] a=A() #for i in a.l: # print(i,end='\t') print(a[4]) print(a[:]) print(a[2:]) print(a[:5]) print(a[3:8]) print(a[::2]) print(a[:4...
class A: def __init__(self): self.l = [1, 2, 3, 4, 5, 6, 7, 8, 9] def __getitem__(self, i): if isinstance(i, int): return self.l[i] else: print(i.start, i.stop, i.step) return self.l[i] a = a() print(a[4]) print(a[:]) print(a[2:]) print(a[:5]) print(...
NAME = 'diary.py' ORIGINAL_AUTHORS = [ 'Angelo Giacco' ] ABOUT = ''' Keeps a record of your diary ''' COMMANDS = ''' >>>.diary record <diary entry> Adds to that day's diary entry >>>.diary show <date> Will show the diary entry of specified date (can also accept "today", "yesterday") >>>.diary delete Will delet...
name = 'diary.py' original_authors = ['Angelo Giacco'] about = '\nKeeps a record of your diary\n' commands = '\n>>>.diary record <diary entry>\nAdds to that day\'s diary entry\n\n>>>.diary show <date>\nWill show the diary entry of specified date (can also accept "today", "yesterday")\n\n>>>.diary delete\nWill delete to...
# # PySNMP MIB module DLINK-3100-SOCKET-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/DLINK-3100-SOCKET-MIB # Produced by pysmi-0.3.4 at Wed May 1 12:49:02 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (def...
(object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_intersection, value_range_constraint, value_size_constraint, single_value_constraint, constraints_union) ...
class DirectedEdge: def __init__(self, v, w, weight): self.v = v self.w = w self.weight = weight def from_v(self): return self.v def to_v(self): return self.w def get_weight(self): return self.weight def compare_to(self, that): return self...
class Directededge: def __init__(self, v, w, weight): self.v = v self.w = w self.weight = weight def from_v(self): return self.v def to_v(self): return self.w def get_weight(self): return self.weight def compare_to(self, that): return self...
#!/usr/bin/env python # -*- coding: utf-8 -*- #--------------------------------------------------------------------------------- # # ,--. # | |-. ,---. ,---. ,--.--.,--,--, # | .-. '| .-. :| .-. || .--'| \ # | `-' |\ --.' '-' '| | ...
__author__ = 'Peter Antoine' __copyright__ = 'Copyright 2014-2021, Peter Antoine' __credits__ = ['Peter Antoine'] __license__ = 'MIT' __version__ = '1.5.0' __maintainer__ = 'Peter Antoine' __email__ = 'github@peterantoine.me.uk' __url__ = 'https://github.com/PAntoine/BeornLib' __status__ = 'Development'
# Ali # Adobis's Mission I: The Room of Tragedy # not sure what function this room has but it has no portals sm.sendNext("Why are you here? You shouldn't be here..") sm.warp(211000000) # warps to El Nath
sm.sendNext("Why are you here? You shouldn't be here..") sm.warp(211000000)
# Input boss = {'h': 58, 'd': 9} play = {'h': 50, 'm': 500} spell = [ {'m': 53, 'd': 4, 'a': 0, 't': 1, 'h': 0}, {'m': 73, 'd': 2, 'a': 0, 't': 1, 'h': 2}, {'m': 113, 'd': 0, 'a': 7, 't': 6, 'h': 0}, {'m': 173, 'd': 3, 'a': 0, 't': 6, 'h': 0}, {'m': 229, 'd': 0, 'a': 0, 't': 5, 'h': 101} ]...
boss = {'h': 58, 'd': 9} play = {'h': 50, 'm': 500} spell = [{'m': 53, 'd': 4, 'a': 0, 't': 1, 'h': 0}, {'m': 73, 'd': 2, 'a': 0, 't': 1, 'h': 2}, {'m': 113, 'd': 0, 'a': 7, 't': 6, 'h': 0}, {'m': 173, 'd': 3, 'a': 0, 't': 6, 'h': 0}, {'m': 229, 'd': 0, 'a': 0, 't': 5, 'h': 101}]
def permutations(s): if len(s) == 1: return [s] result = [] for char in s: tail_list = permutations(s.replace(char, '')) mapped = list(map(lambda x : char + x, tail_list)) result += mapped return result if __name__ == '__main__': print(permutations('abc'))
def permutations(s): if len(s) == 1: return [s] result = [] for char in s: tail_list = permutations(s.replace(char, '')) mapped = list(map(lambda x: char + x, tail_list)) result += mapped return result if __name__ == '__main__': print(permutations('abc'))
load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo") load("//dotnet/private:copy_files.bzl", "copy_files") load( "//dotnet:selenium-dotnet-version.bzl", "SUPPORTED_NET_FRAMEWORKS", "SUPPORTED_NET_STANDARD_VERSIONS", ) def _nuget_push_impl(ctx): args = [ "push", ] apikey...
load('@bazel_skylib//rules:common_settings.bzl', 'BuildSettingInfo') load('//dotnet/private:copy_files.bzl', 'copy_files') load('//dotnet:selenium-dotnet-version.bzl', 'SUPPORTED_NET_FRAMEWORKS', 'SUPPORTED_NET_STANDARD_VERSIONS') def _nuget_push_impl(ctx): args = ['push'] apikey = ctx.attr.api_key[BuildSettin...
# Copyright 2011 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 a...
subinclude('//javascript/externs/builddefs:BUILD') subinclude('//javascript/closure/builddefs:BUILD') debug_compiler_defs = CLOSURE_COMPILER_FLAGS_UNOBFUSCATED + ['--generate_exports'] optimized_compiler_defs = CLOSURE_COMPILER_FLAGS_STRICT + ['--generate_exports'] compiler_defs = DEBUG_COMPILER_DEFS + ['--aggressive_v...
def get_conclusion_page_number(doc): for i in reversed(range(doc.pageCount)): page = doc.loadPage(i) text = page.getText() text_lowered = text.lower() if 'conclusion' in text_lowered: return i else: # Page before the last page which is usually the Printing Sp...
def get_conclusion_page_number(doc): for i in reversed(range(doc.pageCount)): page = doc.loadPage(i) text = page.getText() text_lowered = text.lower() if 'conclusion' in text_lowered: return i else: return doc.pageCount - 1
''' Created on Feb 26, 2014 @author: efarhan ''' physics_events = [] def add_physics_event(event): global physics_events physics_events.append(event) def get_physics_event(): global physics_events return physics_events def clear_physics_event(): global physics_events del physics_events[:] cl...
""" Created on Feb 26, 2014 @author: efarhan """ physics_events = [] def add_physics_event(event): global physics_events physics_events.append(event) def get_physics_event(): global physics_events return physics_events def clear_physics_event(): global physics_events del physics_events[:] c...
def sum(a): if a <= 1: return 1 else: return a+sum(a-1) print(sum(5))
def sum(a): if a <= 1: return 1 else: return a + sum(a - 1) print(sum(5))
# class Solution: # ## with division # def productExceptSelf(self, nums: List[int]) -> List[int]: # N = len(nums) # # traverse the list # ## 1st pass, get the total product # total_prod = 1 # zero_counter = 0 # for num in nums: # if zero_count...
class Solution: def product_except_self(self, nums: List[int]) -> List[int]: n = len(nums) output = [] zero_counter = 0 for idx in range(N): if nums[idx] == 0: zero_counter += 1 if zero_counter > 1: return [0 for i in range(N)]...
#!/usr/bin/env python3 def read_list_from_file(file_name): f = open(file_name) list = [] dict={} for x in f: list.append(x.strip()) f.close() i=0 while i< len(list): dict[list[i]] = list[i+1] i=i+2 return dict def is_verified(vin, password) -> bool: dict = rea...
def read_list_from_file(file_name): f = open(file_name) list = [] dict = {} for x in f: list.append(x.strip()) f.close() i = 0 while i < len(list): dict[list[i]] = list[i + 1] i = i + 2 return dict def is_verified(vin, password) -> bool: dict = read_list_from...
class StringHash: def __init__(self, text, base=997, mod=10 ** 18 + 3): n = len(text) self.text = text self.base = base self.mod = mod self.power = [1] * (n + 2) self.prefix_hash = [0] * (n + 2) for i in range(1, n + 1): self.power[i] = self.powe...
class Stringhash: def __init__(self, text, base=997, mod=10 ** 18 + 3): n = len(text) self.text = text self.base = base self.mod = mod self.power = [1] * (n + 2) self.prefix_hash = [0] * (n + 2) for i in range(1, n + 1): self.power[i] = self.power...
# !/usr/bin/env python3 # Author: C.K # Email: theck17@163.com # DateTime:2021-09-23 22:21:37 # Description: class Solution: def kthSmallest(self, matrix: List[List[int]], k: int) -> int: m, n = len(matrix), len( matrix[0]) # For general, the matrix need not be a square def countLessO...
class Solution: def kth_smallest(self, matrix: List[List[int]], k: int) -> int: (m, n) = (len(matrix), len(matrix[0])) def count_less_or_equal(x): cnt = 0 c = n - 1 for r in range(m): while c >= 0 and matrix[r][c] > x: c -= 1 ...