Beefy Boxes and Bandwidth Generously Provided by pair Networks Joe
We don't bite newbies here... much
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

merlyn wrote: All you need is a good generating algorithm and you can brute force this!

I thought this idea was so intensely cool that I just had to try it out. However, coming up with a "good generating alorithm" escapes me. First, I took the list of possible permutations that dws created and translated it:

[1][2][3][4,5,6] 1 1 1 0 0 [1][2][3,4][5,6] 1 1 0 1 0 [1][2][3,4,5][6] 1 1 0 0 1 [1][2,3][4][5,6] 1 0 1 1 0 [1][2,3][4,5][6] 1 0 1 0 1 [1][2,3,4][5][6] 1 0 0 1 1 [1,2][3][4][5,6] 0 1 1 1 0 [1,2][3][4,5][6] 0 1 1 0 1 [1,2][3,4][5][6] 0 1 0 1 1 [1,2,3][4][5][6] 0 0 1 1 1

Then, once I was sure I understood it, I went ahead and hardcoded that so I could manipulate it and look for patterns.

#!/usr/bin/perl -w use strict; use Data::Dumper; my @categories = qw/ 11100 11010 11001 10110 10101 10011 01110 01101 01011 00111 /; @categories = sort @categories; my @cat2 = sort { $a <=> $b } map { ord pack 'b*', $_ } @categories; print Dumper \@categories, \@cat2;

Which prints the following:

$VAR1 = [ '00111', '01011', '01101', '01110', '10011', '10101', '10110', '11001', '11010', '11100' ]; $VAR2 = [ 7, 11, 13, 14, 19, 21, 22, 25, 26, 28 ];

Needless to say, the list seems arbitrary (even though we know it's not) and try as I might, I can't come up with a method of creating that, much less writing a generalized routine. I thought about trying to discover a pattern in the sequences, but no dice. Later, I tried creating a "picture" of the bits and swapping pairs, but I couldn't come up with a sequence for that, either. I'll start looking into permutators, but I feel like I'm missing something awfully basic here. There are only 10 possible combinations, so I didn't think generating them would be that hard :(

Cheers,
Ovid

Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.


In reply to Re: •Re: Puzzle: need a more general algorithm by Ovid
in thread Puzzle: need a more general algorithm by Ovid

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others having an uproarious good time at the Monastery: (7)
    As of 2014-04-21 08:12 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      April first is:







      Results (492 votes), past polls