def parsestructure(path, userid, date):
with open(f'/backups/{userid}/{date}') as structfile:
parsed = []
for line in structfile.readlines():
item = line.split() # https://docs.python.org/3/library/stdtypes.html#str.split
fullname = item[0]
if fullname.startswith(path):
name = fullname.replace(path, '') # для этого существует
namelst = name.split('/') # модуль os.path
isdir = item[1] == 'dir'
isfile = not isdir # нафиг вообще нужно
if isdir:
name = namelst[0]
pdict = {'path': path, 'name': name, 'is_dir': isdir, 'is_file': isfile}
parsed.append(pdict)
def solve(n, coins):
l = [1] + [0] * n
for c in coins:
for x in range(n - c, -1, -1):
l[x + c] += l[x]
print(l[n])
solve(5, [1, 2, 3, 4, 5]) # 3
solve(25, [1, 2, 4, 8, 16]) # 1 - единственность двичного представления
solve(1000, range(1, 1001)) # 8635565795744155161506