Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Algorithm to convert combinations to bitstring

by ikegami (Patriarch)
on Oct 18, 2006 at 18:30 UTC ( [id://579163]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my %lookup = map { $_ => 1 << (ord($_) - ord('A')) } 'A'..'Z';
    
    ...
    
    print('A'..'Z', "\n");
    print(scalar(reverse(sprintf("%26b", $bitmap))), "\n");
    
  2. or download this
    ABCDEFGHIJKLMNOPQRSTUVWXYZ
    111000011
    
  3. or download this
    my @powers = map { 1 << $_ } 0..25;
    
    ...
    
    print('A'..'Z', "\n");
    print(scalar(reverse(sprintf("%26b", $bitmap))), "\n");
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (1)
As of 2024-04-25 02:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found