aboutsummaryrefslogtreecommitdiff
path: root/challenge-070/lubos-kolouch/python/ch-2.py
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-070/lubos-kolouch/python/ch-2.py')
-rw-r--r--challenge-070/lubos-kolouch/python/ch-2.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/challenge-070/lubos-kolouch/python/ch-2.py b/challenge-070/lubos-kolouch/python/ch-2.py
new file mode 100644
index 0000000000..48ab086970
--- /dev/null
+++ b/challenge-070/lubos-kolouch/python/ch-2.py
@@ -0,0 +1,14 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+N = 4
+gray_code = ["0", "1"]
+
+for i in range(2, N + 1):
+ rev_gray_code = gray_code[::-1]
+ gray_code = ["0" + x for x in gray_code]
+ rev_gray_code = ["1" + x for x in rev_gray_code]
+ gray_code += rev_gray_code
+
+gray_code = [int(x, 2) for x in gray_code]
+print(gray_code)