diff options
| author | drbaggy <js5@sanger.ac.uk> | 2021-06-27 20:22:30 +0100 |
|---|---|---|
| committer | drbaggy <js5@sanger.ac.uk> | 2021-06-27 20:22:30 +0100 |
| commit | 287d70fb03bbb2ba51e636cf051775400e94bcb4 (patch) | |
| tree | 85a39b2a331bbb5b49d17f63ae76796f3999e7ce /challenge-118/abigail/python/ch-1.py | |
| parent | 9beb73e6913f7e462c4aca8719048a7be98e4ad2 (diff) | |
| parent | 1b3142a75a8db8a886596770514e2d9fa1cd9187 (diff) | |
| download | perlweeklychallenge-club-287d70fb03bbb2ba51e636cf051775400e94bcb4.tar.gz perlweeklychallenge-club-287d70fb03bbb2ba51e636cf051775400e94bcb4.tar.bz2 perlweeklychallenge-club-287d70fb03bbb2ba51e636cf051775400e94bcb4.zip | |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'challenge-118/abigail/python/ch-1.py')
| -rw-r--r-- | challenge-118/abigail/python/ch-1.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/challenge-118/abigail/python/ch-1.py b/challenge-118/abigail/python/ch-1.py new file mode 100644 index 0000000000..df0451a44e --- /dev/null +++ b/challenge-118/abigail/python/ch-1.py @@ -0,0 +1,19 @@ +#!/opt/local/bin/python + +# +# See ../README.md +# + +# +# Run as: python ch-1.py < input-file +# + +import fileinput + +for line in fileinput . input (): + bin = '{:b}' . format (int (line)) # Turn to binary representation + if bin == bin [::-1]: # bin [::-1] reverse the string + print (1) + else: + print (0) + |
