Skip to content

Instantly share code, notes, and snippets.

@fabienhinault
Created November 6, 2022 16:59
Show Gist options
  • Save fabienhinault/acfd72195353a37398533584340c68f7 to your computer and use it in GitHub Desktop.
Save fabienhinault/acfd72195353a37398533584340c68f7 to your computer and use it in GitHub Desktop.
use List::Util qw(zip)
@t = ( [ 3, "attaquant", "" ], [ 2, "defenseur", 1])
map { push @$_, ([reverse sort map {(int rand 6) + 1} (1..$_->[0])]) } @t
map { print "tirage $_->[1]: @{$_->[3]}\n" } @t
@r = map {$_->[0] > $_->[1]} ((zip $t[0]->[3], $t[1]->[3])[0..1])
map { $v = $_->[2]; push @$_, ( - grep $_ == $v, @r) } @t
map { print "domage $_->[1]: $_->[4]\n" } @t
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment