diff options
| author | Abigail <abigail@abigail.be> | 2021-07-12 16:04:39 +0200 |
|---|---|---|
| committer | Abigail <abigail@abigail.be> | 2021-07-12 18:43:38 +0200 |
| commit | b6998257ebb26100a3566169cfd6dc0b8d3a060f (patch) | |
| tree | ca7f074f7f33c3229408c738e164f657b88fa3cf /challenge-121/abigail/bash | |
| parent | 5f2d90da63b25cf21b53a3f557fb71a11a5ace06 (diff) | |
| download | perlweeklychallenge-club-b6998257ebb26100a3566169cfd6dc0b8d3a060f.tar.gz perlweeklychallenge-club-b6998257ebb26100a3566169cfd6dc0b8d3a060f.tar.bz2 perlweeklychallenge-club-b6998257ebb26100a3566169cfd6dc0b8d3a060f.zip | |
Solutions in 16 languages for week 121, part 1
Diffstat (limited to 'challenge-121/abigail/bash')
| -rw-r--r-- | challenge-121/abigail/bash/ch-1.sh | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/challenge-121/abigail/bash/ch-1.sh b/challenge-121/abigail/bash/ch-1.sh new file mode 100644 index 0000000000..affeeb846e --- /dev/null +++ b/challenge-121/abigail/bash/ch-1.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +# +# See ../README.md +# + +# +# Run as: bash ch-1.sh < input-file +# + +set -f + +while read m n +do ((n = 2 ** (n - 1))) + if (((m / n) % 2)) + then ((m = m - n)) + else ((m = m + n)) + fi + echo $m +done |
