Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Re(3): Puzzle: need a more general algorithm

by Ovid (Cardinal)
on Jul 09, 2002 at 14:17 UTC ( [id://180484]=note: print w/replies, xml ) Need Help??


in reply to Re(3): Puzzle: need a more general algorithm
in thread Puzzle: need a more general algorithm

Tempting, but the this is the "swapping bits" that I was referring to. The solution skips these three combinations:

01101 01110 10110

If you look at them closely, you'll see why you can't generate them. That's what got me stuck on this track. If that can be solved, this is a good way to go.

Oh, and since you mentioned this was untested, I won't comment about for my $bit ($splits-1..0) { :)

Cheers,
Ovid

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

Replies are listed 'Best First'.
Re(5): Puzzle: need a more general algorithm
by FoxtrotUniform (Prior) on Jul 09, 2002 at 15:04 UTC

    D'oh!

    Fortunately, a man far smarter than I has written an article that you might find useful. ("Pre-Fascicle 2c: Generating all combinations", about halfway down the page. The draft is a .ps.gz file, which is why I didn't link to it directly.)

    --
    The hell with paco, vote for Erudil!
    :wq

      After giving this some thought, I realized that traditional permutation generators are going to have a problem here. Consider the following four permutations:

      11100 11100 11100 11100

      Those can be different permutations. The second could have the first and second ones swapped, the third could have the last fourth and fifth zeroes swapped, etc. Even though, to us, they look the same, the permutators that I've played with don't see that (and how would they calculate it?).

      And it was an interesting coincidence to see the Knuth thread on /. this morning. I'm checking it out now.

      Cheers,
      Ovid

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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (7)
As of 2024-04-24 10:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found