Skip to content

Latest commit

 

History

History
74 lines (55 loc) · 951 Bytes

File metadata and controls

74 lines (55 loc) · 951 Bytes
title Sum of an reversed list with odd index item modification
tags
aggregation
I/O
definite input

Problem Statement

Given a space separated string of numbers, reverse the list and add the odd index's square to the number at the odd index in the new reversed list.

Print the sum of this new list.

Assume the numbers are non-negative integers.

Solution

<template>
<sol>
nums = list(map(int, input().split()))
new_nums = nums[::-1]
for i in range(len(new_nums)):
    if(i%2 != 0):
        new_nums[i] += i**2
print(sum(new_nums))
</sol>
</template>

Public Test Cases

Input 1

1 1 1 1 1

Output 1

15

Input 2

2 3 1 2 2

Output 2

20

Private Test Cases

Input 1

22 32 12 22 22

Output 1

120

Input 2

0 0 0

Output 2

1