diff options
Diffstat (limited to 'challenge-069/lubos-kolouch/python/ch-2.py')
| -rw-r--r-- | challenge-069/lubos-kolouch/python/ch-2.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/challenge-069/lubos-kolouch/python/ch-2.py b/challenge-069/lubos-kolouch/python/ch-2.py new file mode 100644 index 0000000000..5efef48bb8 --- /dev/null +++ b/challenge-069/lubos-kolouch/python/ch-2.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +def generate_string(n: int) -> str: + if n == 0: + return "" + if n == 1: + return "0" + s_n_1 = generate_string(n - 1) + return s_n_1 + "0" + "".join('0' if c == '1' else '1' for c in s_n_1[::-1]) + + +print(generate_string(30)) |
