Най-задълбочената програма по софтуерно инженерство в България
Loading...
+ Нов въпрос
Zapryan avatar Zapryan 5 Точки

Задача "List Pureness"

Здравейте, колеги! Имам проблем със следната задача:

Write function called best_list_pureness which will receive a list of numbers and a number K. You have to rotate the list K times (last becomes first) to find the variation of the list with the best pureness (pureness is calculated by summing all the elements in the list multiplied by their indices). For example, in the list [4, 3, 2, 6] with the best pureness is (3 * 0) + (2 * 1) + (6 * 2) + (4 * 3) = 26. At the end the function should return a string containing the highest pureness and the amount of rotations that were made to find this pureness in the following format: "Best pureness {pureness_value} after {count_rotations} rotations". If there is more than one highest pureness, take the first one.
Note: Submit only the function in the judge system
Input
There will be no input, just parameters passed to your function
Output
There is no expected output
The function should return a string in the following format: "Best pureness {pureness_value} after {count_rotations} rotations"

Всичките примерни тестове ми излизат, обаче в "Judge" получавам 40 точки и не мога да разбера защо. Ще бъде много благодарен, ако някой ми помогне.

Моят код е: https://pastebin.com/cHdavJAr

Линк към "Judge": https://judge.softuni.bg/Contests/Practice/Index/2551#2

 

Тагове:
0
Python Advanced
dreadlordow avatar dreadlordow 11 Точки
Best Answer

Първият ти цикъл трябва да е в рейндж rotations+1 - for rotation in range(rotations + 1):

0
Zapryan avatar Zapryan 5 Точки

Много благодаря!

0