diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2023-04-25 11:34:18 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-25 11:34:18 +0100 |
| commit | 0b58d3d4acc046547b3b8c0cce2f5ba9a0e7df2c (patch) | |
| tree | 5f94a5354fc0ccfd6bc2c1bde6a36423379d106b /challenge-070/lubos-kolouch/python/ch-2.py | |
| parent | 8f85486dbac39eedd05e465f9a9fa66c079d45c9 (diff) | |
| parent | f90349fbd02a4b243f73bcdfc245abfa36df497f (diff) | |
| download | perlweeklychallenge-club-0b58d3d4acc046547b3b8c0cce2f5ba9a0e7df2c.tar.gz perlweeklychallenge-club-0b58d3d4acc046547b3b8c0cce2f5ba9a0e7df2c.tar.bz2 perlweeklychallenge-club-0b58d3d4acc046547b3b8c0cce2f5ba9a0e7df2c.zip | |
Merge pull request #7966 from LubosKolouch/master
Challenge 214 LK Perl Python
Diffstat (limited to 'challenge-070/lubos-kolouch/python/ch-2.py')
| -rw-r--r-- | challenge-070/lubos-kolouch/python/ch-2.py | 14 |
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) |
