diff options
| author | Abigail <abigail@abigail.be> | 2021-05-04 14:26:32 +0200 |
|---|---|---|
| committer | Abigail <abigail@abigail.be> | 2021-05-04 14:27:49 +0200 |
| commit | e9ecb8b56098b11633bed3c39c85574a5f23be5b (patch) | |
| tree | e4733e7e96f71e7b3b06277802f0c949a86d8801 /challenge-111/abigail/bash | |
| parent | a6e9ec2dfad251a3012f53fb828064d68948bf49 (diff) | |
| download | perlweeklychallenge-club-e9ecb8b56098b11633bed3c39c85574a5f23be5b.tar.gz perlweeklychallenge-club-e9ecb8b56098b11633bed3c39c85574a5f23be5b.tar.bz2 perlweeklychallenge-club-e9ecb8b56098b11633bed3c39c85574a5f23be5b.zip | |
Bash solution for week 111, part 1
Diffstat (limited to 'challenge-111/abigail/bash')
| -rw-r--r-- | challenge-111/abigail/bash/ch-1.sh | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/challenge-111/abigail/bash/ch-1.sh b/challenge-111/abigail/bash/ch-1.sh new file mode 100644 index 0000000000..0ef20b5732 --- /dev/null +++ b/challenge-111/abigail/bash/ch-1.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +# +# See ../README.md +# + +# +# Run as: bash ch-1.sh < input-file +# + +declare -A matrix +MATRIX_SIZE=5 + +# +# Read in the matrix +# +for ((i = 1; i <= $MATRIX_SIZE; i ++)) +do read -a line + for n in ${line[@]} + do matrix[$n]=1 + done +done + +# +# Print 1/0 depending or not whether the number is in the matrix +# +while read number +do echo $((matrix[$number] ? 1 : 0)) +done |
