From 935d9df6751698e81ba9024ee2b35e54275b4130 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Mon, 21 Nov 2022 16:21:36 +0100 Subject: [PATCH] python: ex2: add solution --- python/ex2.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 python/ex2.py diff --git a/python/ex2.py b/python/ex2.py new file mode 100755 index 0000000..81ddfd6 --- /dev/null +++ b/python/ex2.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python + +from copy import copy + + +def f(n: int) -> list[list[int]]: + if n == 0: + return [] + if n == 1: + return [[1]] + + res = f(n - 1) + res.append(copy(res[-1])) + res[-1].append(n) + + return res + + +def main(): + for i in range(5): + print(f"f({i})={f(i)}") + + +if __name__ == "__main__": + main()