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

Re: Generate all unique combinations of 1 and 0 using specified length of "0"-string and count of 1's

by tobyink (Canon)
on Sep 18, 2020 at 10:40 UTC ( #11121912=note: print w/replies, xml ) Need Help??


in reply to Generate all unique combinations of 1 and 0 using specified length of "0"-string and count of 1's

For an especially slow solution, just read 10 bytes from /dev/random and test whether it contains seven 0s and three 1s. If it does, keep it. If it doesn't, discard it and repeat.

  • Comment on Re: Generate all unique combinations of 1 and 0 using specified length of "0"-string and count of 1's

Replies are listed 'Best First'.
Re^2: Generate all unique combinations of 1 and 0 using specified length of "0"-string and count of 1's
by Eily (Monsignor) on Sep 18, 2020 at 11:52 UTC

    Because of the "unique" requirement, you can add a cache as well, so that it can take a lot of memory as well as time.

      Only takes a lot of memory if you cache the unsuccessful hits.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (1)
As of 2021-12-07 06:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    R or B?



    Results (33 votes). Check out past polls.

    Notices?