content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
"""Parsing Destinations from phone numbers. Copyright (c) 2016-present, Facebook, Inc. All rights reserved. This source code is licensed under the BSD-style license found in the LICENSE file in the root directory of this source tree. An additional grant of patent rights can be found in the PATENTS file in the same d...
"""Parsing Destinations from phone numbers. Copyright (c) 2016-present, Facebook, Inc. All rights reserved. This source code is licensed under the BSD-style license found in the LICENSE file in the root directory of this source tree. An additional grant of patent rights can be found in the PATENTS file in the same d...
# Uses python3 def get_fibonacci_last_digit_naive(n): if n <= 1: return n previous = 0 current = 1 for _ in range(n - 1): previous, current = current, previous + current return current % 10 def get_digit_fast(n): if n <= 1: return n prev, curr = 0, 1 for _ i...
def get_fibonacci_last_digit_naive(n): if n <= 1: return n previous = 0 current = 1 for _ in range(n - 1): (previous, current) = (current, previous + current) return current % 10 def get_digit_fast(n): if n <= 1: return n (prev, curr) = (0, 1) for _ in range(n - ...
suitcase = ["sunglasses", "hat", "passport", "laptop", "suit", "shoes"] first = suitcase[0:2] # The first and second items (index zero and one) print(first) middle = suitcase[2:4] # Third and fourth items (index two and three) print(middle) last = suitcase[4:6] # The last two items (index four and five)
suitcase = ['sunglasses', 'hat', 'passport', 'laptop', 'suit', 'shoes'] first = suitcase[0:2] print(first) middle = suitcase[2:4] print(middle) last = suitcase[4:6]
# Copyright (C) 2016 Google Inc. # Licensed under http://www.apache.org/licenses/LICENSE-2.0 <see LICENSE file> """ Migrations Utility Module. Place here your migration helpers that is shared among number of migrations. """
""" Migrations Utility Module. Place here your migration helpers that is shared among number of migrations. """
# https://leetcode.com/problems/decode-ways/submissions/ # https://leetcode.com/problems/decode-ways/discuss/253018/Python%3A-Easy-to-understand-explanation-bottom-up-dynamic-programming class Solution_recursion_memo: def numDecodings(self, s): L = len(s) def helper(idx, memo): ...
class Solution_Recursion_Memo: def num_decodings(self, s): l = len(s) def helper(idx, memo): if idx == L: return 1 if idx > L or s[idx] == '0': return float('-inf') if idx in memo: return memo[idx] else...
# Implement the function interval_intersection below. # You can define other functions if it helps you decompose and solve # the problem. # Do not import any module that you do not use! # Remember that if this were an exam problem, in order to be marked # this file must meet certain requirements: # - it must contain ...
def interval_intersection(lA, uA, lB, uB): if lB >= lA and lB <= uA: if uB < uA: return uB - lB else: return uA - lB elif lA >= lB and lA <= uB: if uA < uB: return uA - lA else: return uB - lA return 0 def test_interval_interse...
# Copyright 2019 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 ...
"""Define metadata constants.""" label_column = 'labelArray' key_column = 'fullVisitorId' non_feature_columns = [LABEL_COLUMN, KEY_COLUMN] num_intervals = 4 seed = 123
def distance(str1: str, str2: str) -> float: """ The Levenshtein distance is a string metric for measuring the difference between two sequences. It is calculated as the minimum number of single-character edits necessary to transform one string into another """ n, m = len(str1), len(str2...
def distance(str1: str, str2: str) -> float: """ The Levenshtein distance is a string metric for measuring the difference between two sequences. It is calculated as the minimum number of single-character edits necessary to transform one string into another """ (n, m) = (len(str1), len(str2))...
#!/usr/bin/env python3 all_cases = [[[8, 1, 6], [3, 5, 7], [4, 9, 2]], [[6, 1, 8], [7, 5, 3], [2, 9, 4]], [[4, 9, 2], [3, 5, 7], [8, 1, 6]], [[2, 9, 4], [7, 5, 3], [6, 1, 8]], [[8, 3, 4], [1, 5, 9], [6, 7, 2]], [[4, 3, 8], [9, 5, 1], [2, 7, 6]], ...
all_cases = [[[8, 1, 6], [3, 5, 7], [4, 9, 2]], [[6, 1, 8], [7, 5, 3], [2, 9, 4]], [[4, 9, 2], [3, 5, 7], [8, 1, 6]], [[2, 9, 4], [7, 5, 3], [6, 1, 8]], [[8, 3, 4], [1, 5, 9], [6, 7, 2]], [[4, 3, 8], [9, 5, 1], [2, 7, 6]], [[6, 7, 2], [1, 5, 9], [8, 3, 4]], [[2, 7, 6], [9, 5, 1], [4, 3, 8]]] s = [] for s_i in range(3):...
def CountWithPseudocounts(Motifs): t = len(Motifs) k = len(Motifs[0]) count = {} # insert your code here for symbol in "ACGT": count[symbol] = [] for j in range(k): count[symbol].append(1) for i in range(t): for j in range(k): symbol = Motifs[i][j...
def count_with_pseudocounts(Motifs): t = len(Motifs) k = len(Motifs[0]) count = {} for symbol in 'ACGT': count[symbol] = [] for j in range(k): count[symbol].append(1) for i in range(t): for j in range(k): symbol = Motifs[i][j] count[symbol]...
DEBUG = True SECRET_KEY = 'trinity kevin place' SQLALCHEMY_DATABASE_URI = 'sqlite:////tmp/angular_flask.db'
debug = True secret_key = 'trinity kevin place' sqlalchemy_database_uri = 'sqlite:////tmp/angular_flask.db'
def cb(result): print('Service has been created') heartbeatTimeout = 15 payload = {'tags': ['tag1', 'tag2', 'tag3']} d = client.services.register('serviceId', heartbeatTimeout, payload) d.addCallback(cb) reactor.run()
def cb(result): print('Service has been created') heartbeat_timeout = 15 payload = {'tags': ['tag1', 'tag2', 'tag3']} d = client.services.register('serviceId', heartbeatTimeout, payload) d.addCallback(cb) reactor.run()
# Code generated by font-to-py.py. # Font: DejaVuSans.ttf version = '0.26' def height(): return 20 def max_width(): return 20 def hmap(): return False def reverse(): return False def monospaced(): return False def min_ch(): return 32 def max_ch(): return 126 _font =\ b'\x0a\x00\x0c\x...
version = '0.26' def height(): return 20 def max_width(): return 20 def hmap(): return False def reverse(): return False def monospaced(): return False def min_ch(): return 32 def max_ch(): return 126 _font = b'\n\x00\x0c\x00\x00\x06\x00\x00\x06n\x00\x86o\x00\xce\x01\x00|\x00\x008\x00...
DEFAULT_MAPPING = { "login": "login", "password": "password", "account": "account", } MODULE_KEY = "click_creds.classes.ClickCreds"
default_mapping = {'login': 'login', 'password': 'password', 'account': 'account'} module_key = 'click_creds.classes.ClickCreds'
if __name__ == "__main__": im = 256 ih = 256 print("P3\n",im," ",ih,"\n255\n") for j in range(ih, 0, -1): for i in range(im): r = i / (im-1) g = j / (ih -1) b = 0.25 ir = int(255.999 * r) ig = int(255.999 * g) ib = int(255....
if __name__ == '__main__': im = 256 ih = 256 print('P3\n', im, ' ', ih, '\n255\n') for j in range(ih, 0, -1): for i in range(im): r = i / (im - 1) g = j / (ih - 1) b = 0.25 ir = int(255.999 * r) ig = int(255.999 * g) ib = in...
def maxRepeating(str): l = len(str) count = 0 res = str[0] for i in range(l): cur_count = 1 for j in range(i + 1, l): if (str[i] != str[j]): break cur_count += 1 # Update result if required if cur_count > ...
def max_repeating(str): l = len(str) count = 0 res = str[0] for i in range(l): cur_count = 1 for j in range(i + 1, l): if str[i] != str[j]: break cur_count += 1 if cur_count > count: count = cur_count res = str[i] ...
dot3StatsTable = u'.1.3.6.1.2.1.10.7.2.1' dot3StatsAlignmentErrors = dot3StatsTable + u'.2' dot3StatsFCSErrors = dot3StatsTable + u'.3' dot3StatsFrameTooLongs = dot3StatsTable + u'.13' dots3stats_table_oids = [dot3StatsFCSErrors, dot3StatsAlignmentErrors, dot3StatsFrameTooLongs]
dot3_stats_table = u'.1.3.6.1.2.1.10.7.2.1' dot3_stats_alignment_errors = dot3StatsTable + u'.2' dot3_stats_fcs_errors = dot3StatsTable + u'.3' dot3_stats_frame_too_longs = dot3StatsTable + u'.13' dots3stats_table_oids = [dot3StatsFCSErrors, dot3StatsAlignmentErrors, dot3StatsFrameTooLongs]
x1 = 1 y1 = 0 x2 = 0 y2 = -2 m1 = (y2 / x1) print(f'X-intercept = {x1, x2} and Y-intercept = {y1, y2}\nSlope = {m1}') # 8
x1 = 1 y1 = 0 x2 = 0 y2 = -2 m1 = y2 / x1 print(f'X-intercept = {(x1, x2)} and Y-intercept = {(y1, y2)}\nSlope = {m1}')
# ~/dev/py/fieldz/littleBigTest.py """ This has been hacked down from bigTest.py by eliminating field types that we can't handle yet. """ LITTLE_BIG_PROTO_SPEC = """ protocol org.xlattice.fieldz.test.littleBigProto message bigTestMsg: # required fields, unnumbered vBoolReqField vbool vEnumReqField ven...
""" This has been hacked down from bigTest.py by eliminating field types that we can't handle yet. """ little_big_proto_spec = "\nprotocol org.xlattice.fieldz.test.littleBigProto\n\nmessage bigTestMsg:\n # required fields, unnumbered\n vBoolReqField vbool\n vEnumReqField venum\n vuInt32ReqField vuint32\...
"""p2 server constants""" # Matches full Request Path, starting with leading slash TAG_SERVE_MATCH_PATH = 'serve.p2.io/match/path' # Matches relative Request Path, without leading slash TAG_SERVE_MATCH_PATH_RELATIVE = 'serve.p2.io/match/path/relative' # Matches request Hostname TAG_SERVE_MATCH_HOST = 'serve.p2.io/matc...
"""p2 server constants""" tag_serve_match_path = 'serve.p2.io/match/path' tag_serve_match_path_relative = 'serve.p2.io/match/path/relative' tag_serve_match_host = 'serve.p2.io/match/host' tag_serve_match_meta = 'serve.p2.io/match/meta/'
#!/usr/bin/env python # -*- coding: utf-8 -*- ''' Created on: 2021/07/10 12:48 @Author: Merc2 '''
""" Created on: 2021/07/10 12:48 @Author: Merc2 """
# -*- coding: utf-8 -*- """Classes for AWS accounts.""" # import boto3 # from botocore.exceptions import ClientError class OrgAccount: """Manage AWS Accounts from AWS Organizations.""" def __init__(self, SESSION): """Create an OrgAccount object.""" self.session = SESSION self.org = ...
"""Classes for AWS accounts.""" class Orgaccount: """Manage AWS Accounts from AWS Organizations.""" def __init__(self, SESSION): """Create an OrgAccount object.""" self.session = SESSION self.org = self.session.client('organizations') def get_accounts(self): """Get child a...
class Xbpm(Device): x = Cpt(EpicsSignalRO, 'Pos:X-I') y = Cpt(EpicsSignalRO, 'Pos:Y-I') a = Cpt(EpicsSignalRO, 'Ampl:ACurrAvg-I') b = Cpt(EpicsSignalRO, 'Ampl:BCurrAvg-I') c = Cpt(EpicsSignalRO, 'Ampl:CCurrAvg-I') d = Cpt(EpicsSignalRO, 'Ampl:DCurrAvg-I') total = Cpt(EpicsSignalRO, 'Ampl:Cur...
class Xbpm(Device): x = cpt(EpicsSignalRO, 'Pos:X-I') y = cpt(EpicsSignalRO, 'Pos:Y-I') a = cpt(EpicsSignalRO, 'Ampl:ACurrAvg-I') b = cpt(EpicsSignalRO, 'Ampl:BCurrAvg-I') c = cpt(EpicsSignalRO, 'Ampl:CCurrAvg-I') d = cpt(EpicsSignalRO, 'Ampl:DCurrAvg-I') total = cpt(EpicsSignalRO, 'Ampl:Cur...
# # PySNMP MIB module V2H124-24-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/V2H124-24-MIB # Produced by pysmi-0.3.4 at Wed May 1 15:33:28 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 201...
(octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_union, value_range_constraint, single_value_constraint, constraints_intersection, value_size_constraint) ...
def func(): a = (input("enter a letter : ")) if a.isalpha(): print("alphabet") else: print("NO") func()
def func(): a = input('enter a letter : ') if a.isalpha(): print('alphabet') else: print('NO') func()
class Solution(object): def maxProduct(self, words): """ :type words: List[str] :rtype: int """ bitmap = [0] * len(words) mask = 0x01 ans = 0 for i in xrange(0, len(words)): word = words[i] for c in word: ...
class Solution(object): def max_product(self, words): """ :type words: List[str] :rtype: int """ bitmap = [0] * len(words) mask = 1 ans = 0 for i in xrange(0, len(words)): word = words[i] for c in word: bitmap[i...
class Solution: def getWinner(self, arr: List[int], k: int) -> int: nums = deque(arr) win_count = 0 winner = nums[0] while True: a = nums.popleft() b = nums.popleft() if a > b: if winner == a: win_count ...
class Solution: def get_winner(self, arr: List[int], k: int) -> int: nums = deque(arr) win_count = 0 winner = nums[0] while True: a = nums.popleft() b = nums.popleft() if a > b: if winner == a: win_count += 1 ...
class Solution: def fb(self, A): d3 = A % 3 == 0 d5 = A % 5 == 0 if d3 and d5: return "FizzBuzz" elif d3: return "Fizz" elif d5: return "Buzz" else: return str(A) # @param A : integer #...
class Solution: def fb(self, A): d3 = A % 3 == 0 d5 = A % 5 == 0 if d3 and d5: return 'FizzBuzz' elif d3: return 'Fizz' elif d5: return 'Buzz' else: return str(A) def fizz_buzz(self, A): return [self.fb(i) ...
l=[0]*10 for i in range(len(l)): l[i]=i*2 print(0 in l) print(1 in l) print(2 in l) print(3 in l) print(4 in l)
l = [0] * 10 for i in range(len(l)): l[i] = i * 2 print(0 in l) print(1 in l) print(2 in l) print(3 in l) print(4 in l)
#import os #import glob #modules = glob.glob(os.path.dirname(__file__)+"/*.py") #__all__ = [ os.path.basename(f)[:-3] for f in modules] __user_users_tablename__ = 'users' __user_users_head__ = 'admin' __user_online_tablename__ = 'online' __user_online_head__ = 'online' __user_admingroup_tablename__ = 'admingroup' __use...
__user_users_tablename__ = 'users' __user_users_head__ = 'admin' __user_online_tablename__ = 'online' __user_online_head__ = 'online' __user_admingroup_tablename__ = 'admingroup' __user_admingroup_head__ = 'admingroup'
# https://adventofcode.com/2020/day/13 infile = open('input.txt', 'r') earliest_time_to_depart = int(infile.readline()) buses = [] for bus in infile.readline().rstrip().split(','): if bus != 'x': buses.append(int(bus)) buses.sort() infile.close() earliest_bus = -1 minimum_wait_time = max(buses) for bus in...
infile = open('input.txt', 'r') earliest_time_to_depart = int(infile.readline()) buses = [] for bus in infile.readline().rstrip().split(','): if bus != 'x': buses.append(int(bus)) buses.sort() infile.close() earliest_bus = -1 minimum_wait_time = max(buses) for bus in buses: latest_bus_departure = int(ea...
# pcinput # input functions that check for type # Pieter Spronck # These functions are rather ugly as they print error messages if something is wrong. # However, they are meant for a course, which means they are used by students who # are unaware (until the end of the course) of exceptions and things like that. # Thi...
def get_float(prompt): while True: try: num = float(input(prompt)) except ValueError: print('That is not a number -- please try again') continue return num def get_integer(prompt): while True: try: num = int(input(prompt)) ...
class Chord(object): def __init__(self): self.tones = [] def add_tone(self, tone): self.tones.append(tone)
class Chord(object): def __init__(self): self.tones = [] def add_tone(self, tone): self.tones.append(tone)
n = int(input()) print('+', end='') for i in range(n-2): print(' -', end='') print(' +') for k in range(n-2): print('|', end='') for row in range(n-2): print(' -', end='') print(' |') print('+', end='') for j in range(n-2): print(' -', end='') print(' +')
n = int(input()) print('+', end='') for i in range(n - 2): print(' -', end='') print(' +') for k in range(n - 2): print('|', end='') for row in range(n - 2): print(' -', end='') print(' |') print('+', end='') for j in range(n - 2): print(' -', end='') print(' +')
d = int(input("Enter the decimal number:")) m = d r,t = 0,[] while(d>0): r = d % 8 t.append(chr(r+48)) d = d//8 t = t[::-1] print("The octal of the decimal number",m,"is",end = " ") for i in range(0,len(t)): print(t[i],end='')
d = int(input('Enter the decimal number:')) m = d (r, t) = (0, []) while d > 0: r = d % 8 t.append(chr(r + 48)) d = d // 8 t = t[::-1] print('The octal of the decimal number', m, 'is', end=' ') for i in range(0, len(t)): print(t[i], end='')
# Authors: Alexandre Gramfort <gramfort@nmr.mgh.harvard.edu> # Matti Hamalainen <msh@nmr.mgh.harvard.edu> # # License: BSD (3-clause) class Bunch(dict): """ Container object for datasets: dictionnary-like object that exposes its keys as attributes. """ def __init__(self, **kwargs): ...
class Bunch(dict): """ Container object for datasets: dictionnary-like object that exposes its keys as attributes. """ def __init__(self, **kwargs): dict.__init__(self, kwargs) self.__dict__ = self fiff = bunch() FIFF.FIFFB_MEAS = 100 FIFF.FIFFB_MEAS_INFO = 101 FIFF.FIFFB_RAW_DATA =...
class Ship(): def __init__(self, name, ship_head, ship_size): self.ship_head = ship_head self.name = name self.size = ship_size self.generate_position() #pensar numa nova nomenclatura def generate_position(self): self.position = [] ship_column = self.ship...
class Ship: def __init__(self, name, ship_head, ship_size): self.ship_head = ship_head self.name = name self.size = ship_size self.generate_position() def generate_position(self): self.position = [] ship_column = self.ship_head[1] ship_row = self.ship_he...
def lambda_handler(event, context): message = 'Hello {} {}! Keep being awesome!'.format(event['first_name'], event['last_name']) #print to CloudWatch logs print(message) return { 'message' : message }
def lambda_handler(event, context): message = 'Hello {} {}! Keep being awesome!'.format(event['first_name'], event['last_name']) print(message) return {'message': message}
# Copyright 2019 The Bazel Authors. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable la...
"""Tests for `swift_library.private_deps`.""" load('@build_bazel_rules_swift//test/rules:provider_test.bzl', 'make_provider_test_rule') private_deps_provider_test = make_provider_test_rule(config_settings={'//command_line_option:features': ['swift.supports_private_deps']}) def private_deps_test_suite(): """Test su...
"""Example of creating new training data from a larger data set""" # Data (Daily stock prices in $) price = [[9.9, 9.8, 9.8, 9.4, 9.5, 9.7], [9.5, 9.4, 9.4, 9.3, 9.2, 9.1], [8.4, 7.9, 7.9, 8.1, 8.0, 8.0], [7.1, 5.9, 4.8, 4.8, 4.7, 3.9]] # One-liner sample = [line[::2] for line in price] ...
"""Example of creating new training data from a larger data set""" price = [[9.9, 9.8, 9.8, 9.4, 9.5, 9.7], [9.5, 9.4, 9.4, 9.3, 9.2, 9.1], [8.4, 7.9, 7.9, 8.1, 8.0, 8.0], [7.1, 5.9, 4.8, 4.8, 4.7, 3.9]] sample = [line[::2] for line in price] print(sample)
# python 3.7.4 """ I used an iterative approach. List comprehension would create a very long lists. This approach tend to have less iteration when you hit a prime factor because the initial number will be divided at every hit. In the worst case we have n iteration in prime_factors function because we have inserted a pr...
""" I used an iterative approach. List comprehension would create a very long lists. This approach tend to have less iteration when you hit a prime factor because the initial number will be divided at every hit. In the worst case we have n iteration in prime_factors function because we have inserted a prime number. In ...
#imported from https://bitbucket.org/pypy/benchmarks/src/846fa56a282b0e8716309f891553e0af542d8800/own/fannkuch.py?at=default # the export line is in fannkuch.pythran #runas fannkuch(9);fannkuch2(9) #bench fannkuch(9) def fannkuch(n): count = range(1, n+1) max_flips = 0 m = n-1 r = n check = 0 p...
def fannkuch(n): count = range(1, n + 1) max_flips = 0 m = n - 1 r = n check = 0 perm1 = range(n) perm = range(n) while 1: if check < 30: check += 1 while r != 1: count[r - 1] = r r -= 1 if perm1[0] != 0 and perm1[m] != m: ...
# -*- coding: utf-8 -*- """ lantz.errors ~~~~~~~~~~~~ Implements base classes for instrumentation related exceptions. They are useful to mix with specific exceptions from libraries or modules and therefore allowing code to catch them via lantz excepts without breaking specific ones. :copyr...
""" lantz.errors ~~~~~~~~~~~~ Implements base classes for instrumentation related exceptions. They are useful to mix with specific exceptions from libraries or modules and therefore allowing code to catch them via lantz excepts without breaking specific ones. :copyright: 2012 by The Lantz ...
# Copyright 2020-2021 The MathWorks, Inc. # Configure MATLAB_DESKTOP_PROXY to extend for Jupyter config = { # Link the documentation url here. This will show up on the website UI # where users can create issue's or make enhancement requests "doc_url": "https://github.com/mathworks/jupyter-matlab-proxy", ...
config = {'doc_url': 'https://github.com/mathworks/jupyter-matlab-proxy', 'extension_name': 'Jupyter', 'extension_name_short_description': 'Jupyter'}
# Ex1 def naturalSum(min, max): __min = min __max = max __value = 0 for x in range(__min, __max + 1): if x%7 == 0 or x%9 == 0: __value += x return __value print("natural sum to 20: " + str(naturalSum(0,20))) print("natural sum to 10000: " + str(naturalSum(0,10000)))
def natural_sum(min, max): __min = min __max = max __value = 0 for x in range(__min, __max + 1): if x % 7 == 0 or x % 9 == 0: __value += x return __value print('natural sum to 20: ' + str(natural_sum(0, 20))) print('natural sum to 10000: ' + str(natural_sum(0, 10000)))
print(2) for i in range(3, 101): found = False for j in range(2, i // 2 + 1): if i % j == 0: found = True break if not found: print(i)
print(2) for i in range(3, 101): found = False for j in range(2, i // 2 + 1): if i % j == 0: found = True break if not found: print(i)
#!/usr/bin/env python # encoding: utf-8 # # Copyright (c) 2008 Doug Hellmann All rights reserved. # """ """ #end_pymotw_header print('Importing example package')
""" """ print('Importing example package')
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # SPDX-License-Identifier: MIT-0 def transform(logdata): if 'errorCode' in logdata or 'errorMessage' in logdata: logdata['event']['outcome'] = 'failure' else: logdata['event']['outcome'] = 'success' try: name = lo...
def transform(logdata): if 'errorCode' in logdata or 'errorMessage' in logdata: logdata['event']['outcome'] = 'failure' else: logdata['event']['outcome'] = 'success' try: name = logdata['user']['name'] if ':' in name: logdata['user']['name'] = name.split(':')[-1]....
"""This file defines the unified tensor framework interface required by DGL. The principles of this interface: * There should be as few interfaces as possible. * The interface is used by DGL system so it is more important to have clean definition rather than convenient usage. * Default arguments should be avoided. *...
"""This file defines the unified tensor framework interface required by DGL. The principles of this interface: * There should be as few interfaces as possible. * The interface is used by DGL system so it is more important to have clean definition rather than convenient usage. * Default arguments should be avoided. *...
def singleton(class_): instances = {} def getinstance(*args, **kwargs): if class_ not in instances: instances[class_] = class_(*args, **kwargs) return instances[class_] return getinstance @singleton class BotWrapper: def __init__(self): self.bot = None def se...
def singleton(class_): instances = {} def getinstance(*args, **kwargs): if class_ not in instances: instances[class_] = class_(*args, **kwargs) return instances[class_] return getinstance @singleton class Botwrapper: def __init__(self): self.bot = None def set...
#! /usr/bin/python # -*- coding: iso-8859-15 -*- for n in (1, 6): c = n ** 2 print(n,c)
for n in (1, 6): c = n ** 2 print(n, c)
class RandomMock: """Callable object returning given sequence of "random" numbers. Can be substituted instead of random.random() function to test the behavior of algorithm in case random generator returns some specific sequence of values. I.e. to make these tests deterministic. See randfunc= paramet...
class Randommock: """Callable object returning given sequence of "random" numbers. Can be substituted instead of random.random() function to test the behavior of algorithm in case random generator returns some specific sequence of values. I.e. to make these tests deterministic. See randfunc= paramet...
""" Definition of ListNode class ListNode(object): def __init__(self, val, next=None): self.val = val self.next = next """ class Solution: """ @param head: The head of linked list. @return: You should return the head of the sorted linked list, using constant space complexity. """ ...
""" Definition of ListNode class ListNode(object): def __init__(self, val, next=None): self.val = val self.next = next """ class Solution: """ @param head: The head of linked list. @return: You should return the head of the sorted linked list, using constant space complexity. """ ...
# dp class Solution: def numSquares(self, n: int) -> int: dp = [float("inf")] * (n + 1) dp[0] = 0 for i in range(1, n + 1): j = 1 while j * j <= i: dp[i] = min(dp[i], dp[i - j * j] + 1) j += 1 return dp[n]
class Solution: def num_squares(self, n: int) -> int: dp = [float('inf')] * (n + 1) dp[0] = 0 for i in range(1, n + 1): j = 1 while j * j <= i: dp[i] = min(dp[i], dp[i - j * j] + 1) j += 1 return dp[n]
# --- # jupyter: # jupytext: # cell_markers: region,endregion # kernelspec: # display_name: Python 3 # language: python # name: python3 # --- 1+2+3 # region active="" # This is a raw cell # endregion # This is a markdown cell
1 + 2 + 3
""" :Author(s) Ryan Forster: This file contains constants from Tables 2 and 4 from "Understanding M-values" By Erik C. Baker, P.E. Used for the calculation of gradient factors """ # m naught values for haldane are all 2.0 HALDANE_M_NAUGHT = 2.0 ''' Haldane M value constant ''' ZHL16A_N_DELTA = [1.9082, 1.7928, ...
""" :Author(s) Ryan Forster: This file contains constants from Tables 2 and 4 from "Understanding M-values" By Erik C. Baker, P.E. Used for the calculation of gradient factors """ haldane_m_naught = 2.0 '\nHaldane M value constant\n' zhl16_a_n_delta = [1.9082, 1.7928, 1.5352, 1.3847, 1.278, 1.2306, 1.1857, 1.1504,...
# 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 class Solution: def tree2str(self, t: TreeNode) -> str: if not t: return '' left = '({})'.format(self.t...
class Solution: def tree2str(self, t: TreeNode) -> str: if not t: return '' left = '({})'.format(self.tree2str(t.left)) if t.left or t.right else '' right = '({})'.format(self.tree2str(t.right)) if t.right else '' return '{}{}{}'.format(t.val, left, right)
_constant_id = 0 def _create_constant_id(): global _constant_id _constant_id += 1 return f'<Game Constant (id={_constant_id})' text_relative_margin_size = _create_constant_id() margin_relative_text_spawn = _create_constant_id() mutable_text_size = _create_constant_id() default_font_path = 'nsr.ttf'
_constant_id = 0 def _create_constant_id(): global _constant_id _constant_id += 1 return f'<Game Constant (id={_constant_id})' text_relative_margin_size = _create_constant_id() margin_relative_text_spawn = _create_constant_id() mutable_text_size = _create_constant_id() default_font_path = 'nsr.ttf'
#!/usr/bin/env python # coding: utf-8 # In[1]: def contnum(n): # initializing starting number num = 1 # outer loop to handle number of rows for i in range(0, n): # inner loop to handle number of columns # values changing acc. to outer loop for j in range(0, i+1):...
def contnum(n): num = 1 for i in range(0, n): for j in range(0, i + 1): print(num, end=' ') num = num + 1 print('\r') n = 5 contnum(n)
class PlayerInfo: def __init__(self, manager): self.window = manager.window self.game = manager.game self.manager = manager self._bottom_index = 0 self._top_index = 0 self.bottom_num_pages = 3 self.top_num_pages = 2 def __call__(self): self.setup_...
class Playerinfo: def __init__(self, manager): self.window = manager.window self.game = manager.game self.manager = manager self._bottom_index = 0 self._top_index = 0 self.bottom_num_pages = 3 self.top_num_pages = 2 def __call__(self): self.setup...
""" Doc string """ def asdf(): pass
""" Doc string """ def asdf(): pass
class Solution: def nearestPalindromic(self, n: str) -> str: def getPalindromes(s: str) -> tuple: num = int(s) k = len(s) palindromes = [] half = s[0:(k + 1) // 2] reversedHalf = half[:k // 2][::-1] candidate = int(half + reversedHalf) if candidate < num: palindr...
class Solution: def nearest_palindromic(self, n: str) -> str: def get_palindromes(s: str) -> tuple: num = int(s) k = len(s) palindromes = [] half = s[0:(k + 1) // 2] reversed_half = half[:k // 2][::-1] candidate = int(half + reversedH...
def is_prime(num: int) -> bool: prime_nums_list: list = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97] if num in prime_nums_list: return True elif list(str(num))[-1] in ['2', '5']: return False else: for n in range(2, num): ...
def is_prime(num: int) -> bool: prime_nums_list: list = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97] if num in prime_nums_list: return True elif list(str(num))[-1] in ['2', '5']: return False else: for n in range(2, num): ...
# create a simple tree data structure with python # First of all: a class implemented to present tree node class TreeNode: def __init__(self, val): self.val = val self.left = None self.right = None class Tree: def __init__(self): self.root = None self.size = 0 def a...
class Treenode: def __init__(self, val): self.val = val self.left = None self.right = None class Tree: def __init__(self): self.root = None self.size = 0 def addnode(self, new): if self.root == None: self.root = new self.size += 1 ...
class Solution: def lengthOfLongestSubstringKDistinct(self, s: str, k: int) -> int: if k == 0: return 0 maxLen = 0 d = {} i, j = 0, 0 while j < len(s): d[s[j]] = d.get(s[j], 0) + 1 if len(d) <= k: tempMax = 0 for key, va...
class Solution: def length_of_longest_substring_k_distinct(self, s: str, k: int) -> int: if k == 0: return 0 max_len = 0 d = {} (i, j) = (0, 0) while j < len(s): d[s[j]] = d.get(s[j], 0) + 1 if len(d) <= k: temp_max = 0 ...
# -*- coding: utf-8 -*- """Module for flask views. Only the home page view is defined in this scope. All other views are defined in nested modules for partitioning. """
"""Module for flask views. Only the home page view is defined in this scope. All other views are defined in nested modules for partitioning. """
leap = Runtime.start("leap","LeapMotion") leap.addLeapDataListener(python) def onLeapData(data): print (data.rightHand.index) leap.startTracking()
leap = Runtime.start('leap', 'LeapMotion') leap.addLeapDataListener(python) def on_leap_data(data): print(data.rightHand.index) leap.startTracking()
language="java" print("Checking if else conditions") if language=='Python': print(Python) elif language=="java": print("java") else: print("no match") print("\nChecking Boolean Conditions") user='Admin' logged_in=False if user=='Admin' and logged_in: print("ADMIN PAGE") else: print("Bad Creds") i...
language = 'java' print('Checking if else conditions') if language == 'Python': print(Python) elif language == 'java': print('java') else: print('no match') print('\nChecking Boolean Conditions') user = 'Admin' logged_in = False if user == 'Admin' and logged_in: print('ADMIN PAGE') else: print('Bad ...
"""Implement an algorithm that takes a BST and transform it into a circular double linked list. The transformation must be done in place. BST: 4 2 6 1 5 10 CDLL: ______________________ / \ 1 <> 2 <> 4 <> 5 <> 6 <> 10 \__________________...
"""Implement an algorithm that takes a BST and transform it into a circular double linked list. The transformation must be done in place. BST: 4 2 6 1 5 10 CDLL: ______________________ / 1 <> 2 <> 4 <> 5 <> 6 <> 10 \\___________________...
class Adder: a = 0 b = 0 def add(self): return self.a + self.b def __init__(self,a,b): self.a = a; self.b = b; a = int(input('Enter first number: ')) b = int(input('Enter second number: ')) x = Adder(a,b) print(x.add())
class Adder: a = 0 b = 0 def add(self): return self.a + self.b def __init__(self, a, b): self.a = a self.b = b a = int(input('Enter first number: ')) b = int(input('Enter second number: ')) x = adder(a, b) print(x.add())
def char_sum(s: str): sum = 0 for char in s: sum += ord(char) return sum # Time complexity: O(M+N) # Space complexity: O(1) def check_permutation(s1: str, s2: str): sum1 = char_sum(s1) sum2 = char_sum(s2) return sum1 == sum2 print(check_permutation("same", "same")) print(check_perm...
def char_sum(s: str): sum = 0 for char in s: sum += ord(char) return sum def check_permutation(s1: str, s2: str): sum1 = char_sum(s1) sum2 = char_sum(s2) return sum1 == sum2 print(check_permutation('same', 'same')) print(check_permutation('same', 'smae')) print(check_permutation('same',...
# -*- coding: utf-8 -*- # # Copyright (C) 2021 CERN. # # Invenio-App-RDM is free software; you can redistribute it and/or modify # it under the terms of the MIT License; see LICENSE file for more details. """Test that all export formats are working.""" def test_export_formats(client, running_app, record): """Tes...
"""Test that all export formats are working.""" def test_export_formats(client, running_app, record): """Test that all expected export formats are working.""" formats = ['json', 'csl', 'datacite-json', 'datacite-xml', 'dublincore'] for f in formats: res = client.get(f'/records/{record.id}/export/{f...
class APIError(RuntimeError): def __init__(self, message): self.message = message def __str__(self): return "%s" % (self.message) def __repr__(self): return self.__str__()
class Apierror(RuntimeError): def __init__(self, message): self.message = message def __str__(self): return '%s' % self.message def __repr__(self): return self.__str__()
kumas, inus, ookamis = 10, 4, 16 if (kumas > inus) and (kumas > ookamis): print(ookamis) elif (inus > kumas) and (inus > ookamis): print(kumas) elif (ookamis > kumas) and (ookamis > inus): print(inus)
(kumas, inus, ookamis) = (10, 4, 16) if kumas > inus and kumas > ookamis: print(ookamis) elif inus > kumas and inus > ookamis: print(kumas) elif ookamis > kumas and ookamis > inus: print(inus)
L = [92,456,34,7234,24,7,623,5,35] maxSoFar = L[0] for i in range(len(L)): if L[i] > maxSoFar: maxSoFar = L[i] print(maxSoFar)
l = [92, 456, 34, 7234, 24, 7, 623, 5, 35] max_so_far = L[0] for i in range(len(L)): if L[i] > maxSoFar: max_so_far = L[i] print(maxSoFar)
class Empleado: cantidad_empleados = 0 tasa_incremento = 1.03 def __init__(self, nombre, apellido, email, sueldo): self.nombre = nombre self.apellido = apellido self.email = email self.sueldo = sueldo def get_full_name(self): return '{} {}'.format(self.nombre, s...
class Empleado: cantidad_empleados = 0 tasa_incremento = 1.03 def __init__(self, nombre, apellido, email, sueldo): self.nombre = nombre self.apellido = apellido self.email = email self.sueldo = sueldo def get_full_name(self): return '{} {}'.format(self.nombre, s...
class A: def long_unique_identifier(self): pass def foo(x): x.long_unique_identifier() # <ref>
class A: def long_unique_identifier(self): pass def foo(x): x.long_unique_identifier()
# -*- coding: utf-8 -*- def parametrized(dec): def layer(*args, **kwargs): def repl(f): return dec(f, *args, **kwargs) return repl return layer @parametrized def dependency(module, *_deps): module.deps = _deps return module @parametrized def source(module, _source): ...
def parametrized(dec): def layer(*args, **kwargs): def repl(f): return dec(f, *args, **kwargs) return repl return layer @parametrized def dependency(module, *_deps): module.deps = _deps return module @parametrized def source(module, _source): module.source = _source ...
print("Enter The Number n") n = int(input()) if (n%2)!=0: print("Weird") elif (n%2)==0: if n in range(2,5): print("Not Weird") elif n in range(6,21): print("Weird") elif n > 20: print("Not Weird")
print('Enter The Number n') n = int(input()) if n % 2 != 0: print('Weird') elif n % 2 == 0: if n in range(2, 5): print('Not Weird') elif n in range(6, 21): print('Weird') elif n > 20: print('Not Weird')
#! /usr/bin/env python3 # -*- coding: utf-8 -*- """ Unit test cases for cellular environment and algorithms """ __author__ = 'Ari Saha (arisaha@icloud.com), Mingyang Liu(liux3941@umn.edu)'
""" Unit test cases for cellular environment and algorithms """ __author__ = 'Ari Saha (arisaha@icloud.com), Mingyang Liu(liux3941@umn.edu)'
model = dict( type='TSN2D', backbone=dict( type='ResNet', pretrained='modelzoo://resnet50', nsegments=8, depth=50, out_indices=(3,), tsm=True, bn_eval=False, partial_bn=False), spatial_temporal_module=dict( type='SimpleSpatialModule', ...
model = dict(type='TSN2D', backbone=dict(type='ResNet', pretrained='modelzoo://resnet50', nsegments=8, depth=50, out_indices=(3,), tsm=True, bn_eval=False, partial_bn=False), spatial_temporal_module=dict(type='SimpleSpatialModule', spatial_type='avg', spatial_size=7), segmental_consensus=dict(type='SimpleConsensus', co...
""" Xilinx primitive tokens """ ASYNC_PORTS = "async_ports" CLK_PORTS = "clk_ports" CLOCK_BUFFERS = "clock_buffers" COMBINATIONAL_CELLS = "combinational_cells" COMPLEX_SEQUENTIAL_CELLS = "complex_sequential_cells" DESCRIPTION = "description" FF_CELLS = "ff_cells" MISC_CELLS = "misc_cells" NAME = "name" POWER_GROUND_CEL...
""" Xilinx primitive tokens """ async_ports = 'async_ports' clk_ports = 'clk_ports' clock_buffers = 'clock_buffers' combinational_cells = 'combinational_cells' complex_sequential_cells = 'complex_sequential_cells' description = 'description' ff_cells = 'ff_cells' misc_cells = 'misc_cells' name = 'name' power_ground_cel...
#AUTHOR: Pornpimol Kaewphing #Python3 Concept: Twosum in Python #GITHUB: https://github.com/gympohnpimol def twoSum(self, nums: List[int], target: int) -> List[int]: for i in range(len(nums)): for j in range(i + 1, len(nums)): if nums[i] + nums[j] == target: ...
def two_sum(self, nums: List[int], target: int) -> List[int]: for i in range(len(nums)): for j in range(i + 1, len(nums)): if nums[i] + nums[j] == target: return [i, j] else: pass
def combine_toxic_classes(df): """"""""" Reconfigures the Jigsaw Toxic Comment dataset from a multi-label classification problem to a binary classification problem predicting if a text is toxic (class=1) or non-toxic (class=0). Input: - df: A pandas DataFrame with columns: ...
def combine_toxic_classes(df): """ Reconfigures the Jigsaw Toxic Comment dataset from a multi-label classification problem to a binary classification problem predicting if a text is toxic (class=1) or non-toxic (class=0). Input: - df: A pandas DataFrame with columns: - ...
list1 = [1, 2, 3] list2 = ["One", "Two"] print("list1: ", list1) print("list2: ", list2) print("\n") list12 = list1 + list2 print("list1 + list2: ", list12) list2x3 = list2 * 3 print("list2 * 3: ", list2x3) hasThree = "Three" in list2 print("'Three' in list2? ", hasThree)
list1 = [1, 2, 3] list2 = ['One', 'Two'] print('list1: ', list1) print('list2: ', list2) print('\n') list12 = list1 + list2 print('list1 + list2: ', list12) list2x3 = list2 * 3 print('list2 * 3: ', list2x3) has_three = 'Three' in list2 print("'Three' in list2? ", hasThree)
# -*- coding: utf-8 -*- """ @Time : 2020/11/26 15:38 @Author : PyDee @File : __init__.py.py @description : """
""" @Time : 2020/11/26 15:38 @Author : PyDee @File : __init__.py.py @description : """
def print_in_blocks(li, bp): dli = [] temp_list = [] for i in range(len(li)): temp_list.append(li[i]) if i != 0 and (i+1)%bp == 0: dli.append(temp_list) temp_list = [] cols = bp max_col_len = [] for _ in range(cols): max_col_len.append(0) f...
def print_in_blocks(li, bp): dli = [] temp_list = [] for i in range(len(li)): temp_list.append(li[i]) if i != 0 and (i + 1) % bp == 0: dli.append(temp_list) temp_list = [] cols = bp max_col_len = [] for _ in range(cols): max_col_len.append(0) f...
# These should reflect //ci/prebuilt/BUILD declared targets. This a map from # target in //ci/prebuilt/BUILD to the underlying build recipe in # ci/build_container/build_recipes. TARGET_RECIPES = { "ares": "cares", "backward": "backward", "event": "libevent", "event_pthreads": "libevent", # TODO(htu...
target_recipes = {'ares': 'cares', 'backward': 'backward', 'event': 'libevent', 'event_pthreads': 'libevent', 'gcovr': 'gcovr', 'googletest': 'googletest', 'tcmalloc_and_profiler': 'gperftools', 'http_parser': 'http-parser', 'lightstep': 'lightstep', 'nghttp2': 'nghttp2', 'protobuf': 'protobuf', 'protoc': 'protobuf', '...
# Python3 program to solve Rat in a Maze # problem using backracking # Maze size N = 4 # A utility function to print solution matrix sol def printSolution( sol ): for i in sol: for j in i: print(str(j) + " ", end ="") print("") # A utility function to check if x, y is valid # index for N * N Maze def isSaf...
n = 4 def print_solution(sol): for i in sol: for j in i: print(str(j) + ' ', end='') print('') def is_safe(maze, x, y): if x >= 0 and x < N and (y >= 0) and (y < N) and (maze[x][y] == 1): return True return False def solve_maze(maze): sol = [[0 for j in range(4)] f...
# We use this to create easily readable errors for when debugging elastic beanstalk deployment configurations class DynamicParameter(Exception): pass #NOTE: integer values need to be strings def get_base_eb_configuration(): return [ # Instance launch configuration details { 'N...
class Dynamicparameter(Exception): pass def get_base_eb_configuration(): return [{'Namespace': 'aws:autoscaling:launchconfiguration', 'OptionName': 'InstanceType', 'Value': dynamic_parameter('InstanceType')}, {'Namespace': 'aws:autoscaling:launchconfiguration', 'OptionName': 'IamInstanceProfile', 'Value': dyna...
''' Context: String compression using counts of repeated characters Definitions: Objective: Assumptions: Only lower and upper case letters present Constraints: Inputs: string value Algorithm flow: Compress the string ...
""" Context: String compression using counts of repeated characters Definitions: Objective: Assumptions: Only lower and upper case letters present Constraints: Inputs: string value Algorithm flow: Compress the string ...
class Solution(object): def multiply(self, num1, num2): """ :type num1: str :type num2: str :rtype: str """ num1 = num1[: : -1] num2 = num2[: : -1] multi = [0 for i in range(len(num1) + len(num2))] for i in range(len(num1)): ...
class Solution(object): def multiply(self, num1, num2): """ :type num1: str :type num2: str :rtype: str """ num1 = num1[::-1] num2 = num2[::-1] multi = [0 for i in range(len(num1) + len(num2))] for i in range(len(num1)): for j in r...
# coding=utf-8 # Licensed Materials - Property of IBM # Copyright IBM Corp. 2015,2017 """ SPL primitive operators that call a Python function or callable class are created by decorators provided :py:mod:`streamsx.spl.spl` Once created the operators become part of a toolkit and may be used like any other SPL operator. "...
""" SPL primitive operators that call a Python function or callable class are created by decorators provided :py:mod:`streamsx.spl.spl` Once created the operators become part of a toolkit and may be used like any other SPL operator. """
def slow_fib(n: int) -> int: if n < 1: return 0 if n == 1: return 1 return slow_fib(n-1) + slow_fib(n-2)
def slow_fib(n: int) -> int: if n < 1: return 0 if n == 1: return 1 return slow_fib(n - 1) + slow_fib(n - 2)
def word_frequency(list): words = {} for word in list: if word in words: words[word] += 1 else: words[word] = 1 return words frequency_counter = word_frequency(['hey', 'hi', 'more', 'hey', 'hi']) print(frequency_counter)
def word_frequency(list): words = {} for word in list: if word in words: words[word] += 1 else: words[word] = 1 return words frequency_counter = word_frequency(['hey', 'hi', 'more', 'hey', 'hi']) print(frequency_counter)
''' Task Given an integer, , and space-separated integers as input, create a tuple, , of those integers. Then compute and print the result of . Note: hash() is one of the functions in the __builtins__ module, so it need not be imported. Input Format The first line contains an integer, , denoting the number of eleme...
""" Task Given an integer, , and space-separated integers as input, create a tuple, , of those integers. Then compute and print the result of . Note: hash() is one of the functions in the __builtins__ module, so it need not be imported. Input Format The first line contains an integer, , denoting the number of eleme...
# Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"). You # may not use this file except in compliance with the License. A copy of # the License is located at # # https://aws.amazon.com/apache2.0/ # # or in the "license" fil...
def inject_create_tags(event_name, class_attributes, **kwargs): """This injects a custom create_tags method onto the ec2 service resource This is needed because the resource model is not able to express creating multiple tag resources based on the fact you can apply a set of tags to multiple ec2 resour...
# GENERATED VERSION FILE # TIME: Fri Mar 20 02:18:57 2020 __version__ = '1.1.0+58a3f02' short_version = '1.1.0'
__version__ = '1.1.0+58a3f02' short_version = '1.1.0'
bruin = set(["Boxtel","Best","Beukenlaan","Helmond 't Hout","Helmond","Helmond Brouwhuis","Deurne"]) groen = set(["Boxtel","Best","Beukenlaan","Geldrop","Heeze","Weert"]) print(bruin.intersection(groen)) print(bruin.difference(groen)) print(bruin.union(groen))
bruin = set(['Boxtel', 'Best', 'Beukenlaan', "Helmond 't Hout", 'Helmond', 'Helmond Brouwhuis', 'Deurne']) groen = set(['Boxtel', 'Best', 'Beukenlaan', 'Geldrop', 'Heeze', 'Weert']) print(bruin.intersection(groen)) print(bruin.difference(groen)) print(bruin.union(groen))
# 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: if not head: return head prevHead = head ...
class Solution: def reverse_list(self, head: ListNode) -> ListNode: if not head: return head prev_head = head while prevHead.next: curr = prevHead.next prevHead.next = curr.next curr.next = head head = curr return head cla...