1#!/usr/local/bin/perl
2
3###
4# This program is copyright Alec Muffett 1997. The author disclaims all
5# responsibility or liability with respect to it's usage or its effect
6# upon hardware or computer systems, and maintains copyright as set out
7# in the "LICENCE" document which accompanies distributions of Crack v5.0
8# and upwards.
9###
10
11%perms = ();
12
13sub Permute
14{
15    my $depth = shift;
16    my $i;
17
18    if ($depth == 0)
19    {
20	@stack = ();
21    }
22    for ($i = 0; $i <= $#set; $i++)
23    {
24	$stack[$depth] = $set[$i];
25
26	if ($depth == $#set)
27	{
28	    %output = ();
29	    foreach (@stack)
30	    {
31		$output{$_}++;
32	    }
33	    $perm = join(" ", sort(keys(%output)));
34	    $perms{$perm}++;
35	}
36	else
37	{
38	    &Permute($depth + 1);
39	}
40    }
41}
42
43@maps = ([ '/$s$s', '/0s0o', '/2s2a', '/3s3e', '/5s5s', '/1s1i', '/4s4a' ],
44	 [ '/$s$s', '/0s0o', '/2s2a', '/3s3e', '/5s5s', '/1s1i', '/4s4h' ],
45	 [ '/$s$s', '/0s0o', '/2s2a', '/3s3e', '/5s5s', '/1s1l', '/4s4a' ],
46	 [ '/$s$s', '/0s0o', '/2s2a', '/3s3e', '/5s5s', '/1s1l', '/4s4h' ]);
47
48@set = (0 .. 5);
49
50# why be elegant when you can use brute force?  moreover, it's easier
51# to think brute-force at 1am in the morning, and leaves you with time
52# for coffee...
53
54&Permute(0);
55
56foreach $perm (sort(keys(%perms)))
57{
58    foreach $aref (@maps)
59    {
60	foreach $i (split(" ", $perm))
61	{
62	    print ${$aref}[$i];
63	}
64	print "\n";
65    }
66}
67
68exit 0;
69