|  | @@ -0,0 +1,41 @@
 | 
											
												
													
														|  | 
 |  | +#!/bin/bash
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +declare -a color=("spade" "heart" "club" "diamond")
 | 
											
												
													
														|  | 
 |  | +declare -a point=("A" "2" "3" "4" "5" "6" "7" "8" "9" "10" "J" "Q" "K")
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +function seed_random() {
 | 
											
												
													
														|  | 
 |  | +  local min=$1
 | 
											
												
													
														|  | 
 |  | +  local max=$2
 | 
											
												
													
														|  | 
 |  | +  seq $1 $2 | shuf -n $(($2-$1+1))
 | 
											
												
													
														|  | 
 |  | +}
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +function deal_cards() {
 | 
											
												
													
														|  | 
 |  | +  local cards=$1
 | 
											
												
													
														|  | 
 |  | +  local beg=$2
 | 
											
												
													
														|  | 
 |  | +  local end=$3
 | 
											
												
													
														|  | 
 |  | +  local cnt=0
 | 
											
												
													
														|  | 
 |  | +  for i in $cards
 | 
											
												
													
														|  | 
 |  | +  do
 | 
											
												
													
														|  | 
 |  | +    if [ $cnt -eq $end ];then
 | 
											
												
													
														|  | 
 |  | +      return
 | 
											
												
													
														|  | 
 |  | +    fi
 | 
											
												
													
														|  | 
 |  | +    if [ $cnt -ge $beg ];then
 | 
											
												
													
														|  | 
 |  | +      printf ${color[$(($i%4))]}${point[$(($i%13))]}" "
 | 
											
												
													
														|  | 
 |  | +    fi
 | 
											
												
													
														|  | 
 |  | +    cnt=$(($cnt+1))
 | 
											
												
													
														|  | 
 |  | +  done
 | 
											
												
													
														|  | 
 |  | +}
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +function main() {
 | 
											
												
													
														|  | 
 |  | +  card_idx=$(seed_random 0 51)
 | 
											
												
													
														|  | 
 |  | +  printf "first one: "
 | 
											
												
													
														|  | 
 |  | +  deal_cards "$card_idx" 0 13
 | 
											
												
													
														|  | 
 |  | +  printf "\nsecond one: "
 | 
											
												
													
														|  | 
 |  | +  deal_cards "$card_idx" 13 26
 | 
											
												
													
														|  | 
 |  | +  printf "\nthird one: "
 | 
											
												
													
														|  | 
 |  | +  deal_cards "$card_idx" 26 39
 | 
											
												
													
														|  | 
 |  | +  printf "\nfourth one: "
 | 
											
												
													
														|  | 
 |  | +  deal_cards "$card_idx" 39 52
 | 
											
												
													
														|  | 
 |  | +}
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +main
 |