blob: 08f922acac7d351f4f56a6edb65fdc280540da3b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
#!/bin/sh
# gleichstand 3
# gewonnen 6
# A X=Rock 1
# B Y=Paper 2
# C Z=Scissors 3
# sed -e 's/\w \(\w\)/& \1/g' -e 's/X/A/' -e 's/Y/B/' -e 's/Z/C/' \
# -e 's/\(A A\)\|\(B B\)\|\(C C\)/3/' -e 's/\(A B\)\|\(B C\)|\(C A\)/6/' \
# -e 's/[ABC] [ABC] //' -e 's/X/1/' -e 's/Y/2/' -e 's/Z/3/' \
# -e 's/ /+/' /dev/stdin \
# | paste -sd+
cat /dev/stdin | sed -e 's/\w \(\w\)/& \1/g' -e 's/\(A X\)\|\(B Y\)\|\(C Z\)/3/' \
-e 's/\(A Y\)\|\(B Z\)\|\(C X\)/6/' -e 's/[ABC] [XYZ] //' -e 's/X/1/' \
-e 's/Y/2/' -e 's/Z/3/' -e 's/ /+/' | paste -sd+ | bc
|