From f941a821ef1b78baf66799c94084d69cc4c334fa Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Thu, 25 Oct 2012 02:22:25 -0500 Subject: another solution --- SSET.pl | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 SSET.pl diff --git a/SSET.pl b/SSET.pl new file mode 100644 index 0000000..82c127f --- /dev/null +++ b/SSET.pl @@ -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) + . '}'; +} -- cgit v1.2.3