CARVIEW |
Select Language
HTTP/2 302
server: nginx
date: Sat, 16 Aug 2025 05:28:22 GMT
content-type: text/plain; charset=utf-8
content-length: 0
x-archive-redirect-reason: found capture at 20080709073800
location: https://web.archive.org/web/20080709073800/https://www.daniweb.com/code/snippet864.html
server-timing: captures_list;dur=0.982415, exclusion.robots;dur=0.029765, exclusion.robots.policy;dur=0.012537, esindex;dur=0.016872, cdx.remote;dur=51.637456, LoadShardBlock;dur=203.339348, PetaboxLoader3.datanode;dur=114.730118, PetaboxLoader3.resolve;dur=49.762210
x-app-server: wwwb-app210
x-ts: 302
x-tr: 318
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
set-cookie: wb-p-SERVER=wwwb-app210; path=/
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
HTTP/2 200
server: nginx
date: Sat, 16 Aug 2025 05:28:22 GMT
content-type: text/html; charset=utf-8
x-archive-orig-date: Wed, 09 Jul 2008 14:36:48 GMT
x-archive-orig-server: Apache/2.2
x-archive-orig-x-powered-by: PHP/5.1.6
x-archive-orig-set-cookie: bblastvisit=1215614208; expires=Thu, 09-Jul-2009 14:36:48 GMT; path=/; domain=.daniweb.com
x-archive-orig-set-cookie: bblastactivity=0; expires=Thu, 09-Jul-2009 14:36:48 GMT; path=/; domain=.daniweb.com
x-archive-orig-cache-control: private
x-archive-orig-pragma: private
x-archive-orig-connection: close
x-archive-orig-transfer-encoding: chunked
x-archive-orig-x_commoncrawl_parsesegmentid: 3876
x-archive-orig-x_commoncrawl_originalurl: https://www.daniweb.com/code/snippet864.html
x-archive-orig-x_commoncrawl_urlfp: -1757054465414633239
x-archive-orig-x_commoncrawl_hostfp: -6905732606072050477
x-archive-orig-x_commoncrawl_signature: 221c6f78c56c7422e90f45e5b19429a2
x-archive-orig-x_commoncrawl_crawlno: 1
x-archive-orig-x_commoncrawl_fetchtimestamp: 1215614280702
x-archive-guessed-content-type: text/html
x-archive-guessed-charset: utf-8
memento-datetime: Wed, 09 Jul 2008 07:38:00 GMT
link: ; rel="original", ; rel="timemap"; type="application/link-format", ; rel="timegate", ; rel="first memento"; datetime="Wed, 09 Jul 2008 07:38:00 GMT", ; rel="memento"; datetime="Wed, 09 Jul 2008 07:38:00 GMT", ; rel="next memento"; datetime="Tue, 09 Sep 2008 07:45:51 GMT", ; rel="last memento"; datetime="Wed, 01 Apr 2009 21:05:26 GMT"
content-security-policy: default-src 'self' 'unsafe-eval' 'unsafe-inline' data: blob: archive.org web.archive.org web-static.archive.org wayback-api.archive.org athena.archive.org analytics.archive.org pragma.archivelab.org wwwb-events.archive.org
x-archive-src: 1216929228041_10-c/1216929458304_0.arc.gz
server-timing: captures_list;dur=0.471959, exclusion.robots;dur=0.017742, exclusion.robots.policy;dur=0.008656, esindex;dur=0.010664, cdx.remote;dur=33.759337, LoadShardBlock;dur=148.794528, PetaboxLoader3.datanode;dur=132.365042, PetaboxLoader3.resolve;dur=132.115426, load_resource;dur=124.480346
x-app-server: wwwb-app210
x-ts: 200
x-tr: 364
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
content-encoding: gzip
Power Set List from Input List - python
Power Set List from Input List
•
•
•
•

What is DaniWeb IT Discussion Community?
You're currently browsing the Python section within the Software Development category of DaniWeb, a massive community of 363,779 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,502 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Python advertiser:
Returns the power set of the elements of a given list (even if some of those elements are also lists).
# From another DaniWeb snippet def int2bin(n, count=24): """returns the binary of integer n, using count number of digits""" return "".join([str((n >> y) & 1) for y in range(count-1, -1, -1)]) # PowerSet of a List def PowerSet(orignal_list): list_size = len(orignal_list) num_sets = 2**list_size powerset = [] # Don't include empty set for i in range(num_sets)[1:]: subset = [] binary_digits = list(int2bin(i,list_size)) list_indices = range(list_size) for (bit,index) in zip(binary_digits,list_indices): if bit == '1': subset.append(orignal_list[index]) powerset.append(subset) return powerset if __name__ == "__main__": print PowerSet([1,2,3])
Post Comment
•
•
•
•
DaniWeb Marketplace (Sponsored Links)
Forum Highlights
- Python Forum
- Today's Posts
- Unanswered Threads
Related Features
DANIWEB FEATURE INDEX
Advertisement
Statistics