diff options
| author | 冯昶 <fengchang@novel-supertv.com> | 2023-05-02 14:47:44 +0800 |
|---|---|---|
| committer | 冯昶 <fengchang@novel-supertv.com> | 2023-05-02 14:47:44 +0800 |
| commit | fb913ef4e973a29450b92ca89588e839bf6635f6 (patch) | |
| tree | 94abff55c6006a2b0a4b1da93a5e661753e00fea /challenge-070/lubos-kolouch/python/ch-2.py | |
| parent | efea8410c80647939ae587536a4f1f66dd2c3a4a (diff) | |
| parent | 6cc2e38f43011f65d7deaf1e03cf55e4306a53e5 (diff) | |
| download | perlweeklychallenge-club-fb913ef4e973a29450b92ca89588e839bf6635f6.tar.gz perlweeklychallenge-club-fb913ef4e973a29450b92ca89588e839bf6635f6.tar.bz2 perlweeklychallenge-club-fb913ef4e973a29450b92ca89588e839bf6635f6.zip | |
Merge remote-tracking branch 'upstream/master'
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) |
