Accenture
Accenture
Hiringhustle
def SmallLargeSum(array):
if len(array) == 0 or len(array) <= 3:
return 0
even_indices = array[::2]
odd_indices = array[1::2]
even_indices.sort(reverse=True)
odd_indices.sort(reverse=True)
print(SmallLargeSum([3, 2, 1, 7, 5, 4]))
print(SmallLargeSum([4, 0, 7, 9, 6, 4, 2]))
bB1_89
Output:
print(CheckPassword('bB1_89'))
Input:
1C0C1C1A0B1
Output:
1
Explanation:
def CalculateBinaryOperations(binary_string):
if len(binary_string) == 0:
return -1
result = int(binary_string[0])
if operator == 'A':
result = result & operand
elif operator == 'B':
result = result | operand
elif operator == 'C':
result = result ^ operand
return result
print(CalculateBinaryOperations('1C0C1C1A0B1'))
4.Write a function FindMaxInArray, which will find the greatest number from
an array with its desired index? The greatest number and its desired index
should be printed in separate lines.
10
96
def FindMaxInArray(array):
max_value = max(array)
max_index = array.index(max_value)
print(max_value)
print(max_index)
FindMaxInArray([15, 78, 96, 17, 20, 65, 14, 36, 18, 20])