#!/usr/bin/perl -s use v5.16; use Test2::V0; use autodie; use Math::Prime::Util 'forperm'; use experimental qw(signatures postderef); our ($tests, $examples, $verbose); run_tests() if $tests || $examples; # does not return die <@{@given} = (); local $" = ''; my %missing; # @_ holds the index set, not the values. forperm { $missing{"@orig[@_]"} = undef unless exists $given{"@orig[@_]"}; } @orig; keys %missing; } ### Examples and tests sub run_tests { SKIP: { skip "examples" unless $examples; is [missing_perms('PERL', qw(PELR PREL PERL PRLE PLER PLRE EPRL EPLR ERPL ERLP ELPR ELRP RPEL RPLE REPL RELP RLPE RLEP LPER LPRE LEPR LRPE LREP))], ['LERP'], 'task 1'; } SKIP: { skip "tests" unless $tests; is scalar(missing_perms('abcdef')), 720, '6!'; is [missing_perms('aabb', 'aabb', 'bbaa')], bag { item 'abba'; item 'baab'; item 'abab'; item 'baba'; end; }, 'non-unique letters'; } done_testing; exit; }