Skip to content

Instantly share code, notes, and snippets.

@fabienhinault
Created November 4, 2022 15:23
Show Gist options
  • Save fabienhinault/39f3671ec76b5b6d29c62e32641b371b to your computer and use it in GitHub Desktop.
Save fabienhinault/39f3671ec76b5b6d29c62e32641b371b to your computer and use it in GitHub Desktop.
cat /dev/urandom | tr -dc '1-6' | head -c 3 | sed -r 's/(.)/\1\n/g' | sort -r > DA ; echo 'tirage attaquant'; cat DA; cat /dev/urandom | tr -dc '1-6' | head -c 2 | sed -r 's/(.)/\1\n/g' | sort -r > DD ; echo 'tirage défenseur'; cat DD; paste DA DD | head -n 2 | sed -e '1 iA=0; D=0' -e 's/\([1-6]\).*\([1-6]\)/if [[ \1 -le \2 ]]; then A=\$(( A - 1 )); else D=\$(( D - 1 )); fi/' -e '$ aecho attaquant \$A ; echo defenseur \$D ' | bash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment