Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Puzzle Time

by golux (Pilgrim)
on Dec 23, 2012 at 05:03 UTC ( #1010075=note: print w/ replies, xml ) Need Help??


in reply to Puzzle Time

The solution by Athanasius is already very nice and succinct; it can find all 548 solutions twice as fast (31 seconds instead of 65) if the tests are performed for each digit rather than after all digits have been hashed:

#!/usr/bin/perl -w use strict; use warnings; my $count = 0; my $start = time; OUTER: for my $n (1 .. 987_654_321) { my %digits; map { next OUTER if !$_ or $digits{$_}++ or $n % $_ } split //, $n; printf "#%d is %d\n", ++$count, $n; ($count == 548) and printf "Time: %d sec\n", time - $start; }
say  substr+lc crypt(qw $i3 SI$),4,5


Comment on Re: Puzzle Time
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1010075]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2015-07-07 15:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (90 votes), past polls