aboutsummaryrefslogtreecommitdiff
path: root/challenge-070/walt-mankowski/python
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-070/walt-mankowski/python')
-rw-r--r--challenge-070/walt-mankowski/python/ch-2.py4
1 files changed, 1 insertions, 3 deletions
diff --git a/challenge-070/walt-mankowski/python/ch-2.py b/challenge-070/walt-mankowski/python/ch-2.py
index be0f8ac2d3..bb052aa981 100644
--- a/challenge-070/walt-mankowski/python/ch-2.py
+++ b/challenge-070/walt-mankowski/python/ch-2.py
@@ -4,9 +4,7 @@ n = int(argv[1])
S = [0, 1, 3, 2]
def gray_code(n, S):
- fmt = f"0{n-1}b"
- S2 = [eval(f"0b1{x}") for x in [f"{x:{fmt}}" for x in S][::-1]]
- return S + S2
+ return S + [2**(n-1) + x for x in S][::-1]
for i in range(3, n+1):
S = gray_code(i, S)