develooper Front page | perl.perl6.users | Postings from December 2019

play with raku and autobiographical numbers

Thread Next
From:
Marc Chantreux
Date:
December 31, 2019 13:40
Subject:
play with raku and autobiographical numbers
Message ID:
20191231133318.GA19278@prometheus.u-strasbg.fr
hello,

2020 describes itself as it is composed by

    2 0
    0 1
    2 2
    0 3

perfect golf excuse! I have :

    sub is_autobiographic (\x) {
        my \s = x.Str;
        my @r = s.comb;
        my %appearance_of;
        %appearance_of{$_}++ for @r;
        x ~~ join '', (%appearance_of{$_}//0 for 0..^@r);
    }

    (^∞
    ).race( :10000batch,:10degree
    ).grep( &is_autobiographic
    ).head(10).map(*.say)

anyone with something simpler?

marc

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About