aboutsummaryrefslogtreecommitdiff
path: root/challenge-134/abigail/perl/ch-1.pl
blob: b04f5958bbe575297972b8db9db27ac59b5e45cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/opt/perl/bin/perl

use 5.032;

use strict;
use warnings;
no  warnings 'syntax';

use experimental 'signatures';
use experimental 'lexical_subs';

#
# See ../README.md
#

#
# Run as: perl ch-1.pl
#

#
# The first 40320 (= 8!) pandigital numbers in base 10 are 10 digits long,
# all starting with '10'. The other 8 digits are all the permutations of
# of the digits 2 .. 8.
#
# So, to generate the first 5 of them, we start with the first one,
# 1023456789, chop of the last three digits (7, 8, 9), get all the
# 6 (= 3!) permutations, sort them, throw away the last, and put them
# after the first six digits.
#

#
# 6 permutations, we can easily do by hand. That's quicker then searching
# on CPAN for a module which does the work for us.
#

say "1023456$_" for qw [789 798 879 897 978];