#!/bin/bash if [ "$1" = "" ]; then echo "usage: $0 \$times_to_flip" echo "shows all possible permutations of a cointoss" exit 1 fi charset=(H T) permute(){ (($1 == 0)) && { echo "$2"; return; } for char in "${charset[@]}" do permute "$((${1} - 1 ))" "$2$char" done } permute "$1"