Digit fifth powers

Author: Andrei Osipov

Surprisingly there are only three numbers that can be written as the sum of fourth powers of their digits:

1634 = 1+ 6+ 3+ 48208 = 8+ 2+ 0+ 89474 = 9+ 4+ 7+ 4

As 1 = 14 is not a sum it is not included.

The sum of these numbers is 1634 + 8208 + 9474 = 19316.

Find the sum of all the numbers that can be written as the sum of fifth powers of their digits.

Source code: prob030-andreoss.pl

use v6;

sub get-numbers(:$start = 10, :$depth = 6, *@a) {
    return $@a unless $depth;
    flat do for ^$start -> \x {
        get-numbers start => x + 1,
                    depth => $depth -1, |@a,x;
    }
}

say [+] gather for get-numbers() -> @a {
    my $v = [+] @a »**» 5;
    my $b = [+] $v.comb.list »**» 5;
    take $b if $v == $b;
    LAST take -1;
}