diff options
author | Jesse Luehrs <doy@tozt.net> | 2012-10-25 02:22:25 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2012-10-25 02:22:25 -0500 |
commit | f941a821ef1b78baf66799c94084d69cc4c334fa (patch) | |
tree | 389dc2460d390e021fdea7d85b308baa47cd5ce7 /SSET.pl | |
parent | 50503831bef2fb4e8ba0c63b9432495a39fbaa5b (diff) | |
download | rosalind-f941a821ef1b78baf66799c94084d69cc4c334fa.tar.gz rosalind-f941a821ef1b78baf66799c94084d69cc4c334fa.zip |
another solution
Diffstat (limited to 'SSET.pl')
-rw-r--r-- | SSET.pl | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -0,0 +1,16 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use 5.016; + +chomp(my $length = <>); +my @elements = 1..$length; + +say 2 ** $length; + +for my $i (0..(2 ** $length - 1)) { + my @included = split '', sprintf("%0${length}b", $i); + say '{' + . join(', ', map { $elements[$_] } grep { $included[$_] } 0..$length) + . '}'; +} |