1 2 3 4 5 6 7 8
#! /usr/bin/env perl6 unit sub MAIN (Str $alphabet, Str $string); say $alphabet.comb.unique.map( { $string.comb.grep(* eq $_ ) } ).sum;