Sum of digits

Dessign the function @sum_dig(f, k, n)@ that, given a list ff of non negative integers, a non negative integer kk and an integer nn, returns a list with the first kk numbers in ff whose digits add up more than nn. If ff does not have kk numbers holding this property, the function will return the empty list.

It’s mandatory to use the function @sumadigitos(num)@ below to calculate the sum of digits:

def sumadigitos(num):
    return sum([int(i) for i in list(str(num))])

Sample session

Problem information

Author: InfBesos

Generation: 2026-01-25T16:41:35.405Z

© Jutge.org, 2006–2026.
https://jutge.org