Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Efficient enumeration of pandigital fractions

by LanX (Saint)
on Jul 21, 2018 at 17:25 UTC ( [id://1219017]=note: print w/replies, xml ) Need Help??


in reply to Efficient enumeration of pandigital fractions

FWIW

a brute force for the decimal case

DB<34> sub dig { my @res= reverse split //,$_[0]; return @res,(0) x +4} DB<35> sub repeat { my %h; @h{@_}=(); return 1 if @_ > keys %h } DB<36> $d=4; $c=0; for $i (2..4) { for $x (1..10**$d) { $p = $i*$x+$ +c ; @x = dig($x); @p = dig($p); next if repeat($i,@x[0..$d-1], @p[0.. +$d]); next if $p[4]; print "($i * $x) + $c = $p \t $i \t @x[3,2,1,0] +\t@p[4,3,2,1,0]\n" }} (4 * 1738) + 0 = 6952 4 1 7 3 8 0 6 9 5 2 (4 * 1963) + 0 = 7852 4 1 9 6 3 0 7 8 5 2

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2024-04-24 20:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found