Add tags

Add tags to the following comment

sedで書けそうな気がするのですが、めんどくさがってsortを使うことにしたのでシェルスクリプトになってしまいました。 行が長いです。ごめんなさい。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
#!/bin/sh

if echo $1 | grep -q -v '^\([CDHS][A2-9TJQK]\)\{5\}$'; then
    echo 'Error: Invalid hand'
    exit 1
fi

declare n=`echo $1 | sed 's/[CDHS]\(.\)/\1\n/g' | tr 'A2-9TJQK' 'a-m' | sort | tr -d '\n' | sed -e '/[a-e]$/y/abcde/ijklm/' -e '/[f-i]$/y/abcdefghi/efghijklm/' -e '/[jk]$/y/abcdefghijk/cdefghijklm/' -e '/l$/y/abcdefghijkl/bcdefghijklm/'`

if echo $1 | grep -q '\(.\).\(\1.\)\{4\}'; then
    echo $n | sed -e 's/ajklm/Royal flush/' -e 's/ijklm/Straight flush/' -e 's/....m/Flush/'
elif echo $n | grep -q '[ai]jklm'; then
    echo Straight
elif echo $n | grep -q '\(.\)\1\1\1'; then
    echo Four of a kind
else
    echo $n | sed -e 's/\(.\)\1\1//' -e 's/\(.\)\1//g' -e 's/^.....$/No pair/' -e 's/^...$/One pair/' -e 's/^..$/Three of a kind/' -e 's/^.$/Two pair/' -e 's/^$/Full house/'
fi

Add tags

The input will be splited to tags with space.

Index

Feed

Other

Link

Pathtraq

loading...