From quantum_mechanic_1964 at yahoo.com Wed Oct 1 12:51:08 2003 From: quantum_mechanic_1964 at yahoo.com (Quantum Mechanic) Date: Mon Aug 2 21:25:57 2004 Subject: [Buffalo-pm] Re: [tpm] Bit Counting In-Reply-To: Message-ID: <20031001175108.65667.qmail@web14008.mail.yahoo.com> --- Mike Stok wrote: > On Wed, 1 Oct 2003, Quantum Mechanic wrote: > > > I'm looking for an elegant way to generate a list > of > > numbers whose binary representation has a given > number > > of 1's. I also want to generate this list in > numerical > > order. > > If you know the number of bits in your upper limit > and you know how many > of them have to be 1 then you can just generate the > right bit strings > quite easily (and then filter those bigger than your > limit) Thanks, that's the next direction I'm going to explore. I'm really just doing this as an adventure -- real work will have to wait! -QM ===== ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Quantum Mechanics: The dreams stuff is made of __________________________________ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com From quantum_mechanic_1964 at yahoo.com Wed Oct 1 10:13:59 2003 From: quantum_mechanic_1964 at yahoo.com (Quantum Mechanic) Date: Mon Aug 2 21:25:57 2004 Subject: [Buffalo-pm] Bit Counting Message-ID: <20031001151359.87128.qmail@web14006.mail.yahoo.com> I'm looking for an elegant way to generate a list of numbers whose binary representation has a given number of 1's. I also want to generate this list in numerical order. For example, with 4 bits on, less than 50: 15 1111 23 10111 27 11011 29 11101 30 11110 39 100111 43 101011 45 101101 46 101110 Now it's easy enough to check every number up to the limit, but it seems there should be a more efficient method. On the other hand, the overhead involved in "skipping" some numbers may be more expensive than the straightforward approach. Anyone have any insights into this? Just for reference, here's some code to check every number, and print out the decimal and binary: #!/your/perl/here $bit_count = shift; $last_number = (shift or -1); $x = 1; while ( ( $last_number < 0 ) or ( $x <= $last_number ) ) { my $y = $x; # copy $x into $y, and chew up $y as we go my $bits; while ( $y ) { $bits .= $y % 2; $y = $y >> 1; } if ( $bit_count == ( $bits =~ tr/1// ) ) { # add underline for readability if needed # 1 while ( $bits =~ s/([01]{4})([01])/$1_$2/ ); $bits = reverse $bits; print "$x $bits\n"; } $x++; } __END__ ===== ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Quantum Mechanics: The dreams stuff is made of __________________________________ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com From mike at stok.co.uk Wed Oct 1 11:42:20 2003 From: mike at stok.co.uk (Mike Stok) Date: Mon Aug 2 21:25:57 2004 Subject: [Buffalo-pm] Re: [tpm] Bit Counting In-Reply-To: <20031001151359.87128.qmail@web14006.mail.yahoo.com> Message-ID: On Wed, 1 Oct 2003, Quantum Mechanic wrote: > I'm looking for an elegant way to generate a list of > numbers whose binary representation has a given number > of 1's. I also want to generate this list in numerical > order. > > For example, with 4 bits on, less than 50: > > 15 1111 > 23 10111 > 27 11011 > 29 11101 > 30 11110 > 39 100111 > 43 101011 > 45 101101 > 46 101110 > > Now it's easy enough to check every number up to the > limit, but it seems there should be a more efficient > method. On the other hand, the overhead involved in > "skipping" some numbers may be more expensive than the > straightforward approach. > > Anyone have any insights into this? If you know the number of bits in your upper limit and you know how many of them have to be 1 then you can just generate the right bit strings quite easily (and then filter those bigger than your limit) 50 has 6 bits, and you want 4 of them on, so you're generating all the strings with 2 0s and 4 1s. Then you need to check that they are all <= your limit... Hope this helps, Mike -- mike@stok.co.uk | The "`Stok' disclaimers" apply. http://www.stok.co.uk/~mike/ | GPG PGP Key 1024D/059913DA mike@exegenix.com | Fingerprint 0570 71CD 6790 7C28 3D60 http://www.exegenix.com/ | 75D2 9EC4 C1C0 0599 13DA From mike at stok.co.uk Wed Oct 1 13:40:01 2003 From: mike at stok.co.uk (Mike Stok) Date: Mon Aug 2 21:25:57 2004 Subject: [Buffalo-pm] Re: [tpm] Bit Counting In-Reply-To: <20031001151359.87128.qmail@web14006.mail.yahoo.com> Message-ID: On Wed, 1 Oct 2003, Quantum Mechanic wrote: > I'm looking for an elegant way to generate a list of > numbers whose binary representation has a given number > of 1's. I also want to generate this list in numerical > order. > > For example, with 4 bits on, less than 50: > > 15 1111 > 23 10111 > 27 11011 > 29 11101 > 30 11110 > 39 100111 > 43 101011 > 45 101101 > 46 101110 > > Now it's easy enough to check every number up to the > limit, but it seems there should be a more efficient > method. On the other hand, the overhead involved in > "skipping" some numbers may be more expensive than the > straightforward approach. > > Anyone have any insights into this? Just for fun... [mike@ratdog tmp]$ cat try.rb #!/usr/bin/env ruby def make_strings (ones, length) return if ones > length if length == 1 yield ones == 1 ? '1' : '0' else make_strings(ones, length - 1) { |s| yield '0' + s } make_strings(ones - 1, length - 1) { |s| yield '1' + s } if ones > 0 end end ones, limit = ARGV[0].to_i, ARGV[1].to_i bits = (Math.log(limit + 1) / Math.log(2)).ceil # need 3 bits for 4 make_strings(ones, bits) do |s| value = s.to_i(2) # convert string s to integer (using base 2) break if value > limit puts "#{s} #{value}" end [mike@ratdog tmp]$ ./try.rb 4 50 001111 15 010111 23 011011 27 011101 29 011110 30 100111 39 101011 43 101101 45 Mike -- mike@stok.co.uk | The "`Stok' disclaimers" apply. http://www.stok.co.uk/~mike/ | GPG PGP Key 1024D/059913DA mike@exegenix.com | Fingerprint 0570 71CD 6790 7C28 3D60 http://www.exegenix.com/ | 75D2 9EC4 C1C0 0599 13DA From dwueppel at newswire.ca Wed Oct 1 14:14:12 2003 From: dwueppel at newswire.ca (Derek Wueppelmann) Date: Mon Aug 2 21:25:57 2004 Subject: [Buffalo-pm] Re: [tpm] Bit Counting In-Reply-To: References: Message-ID: <1065035646.9465.6.camel@sprocket.newswire.ca> On Wed, 2003-10-01 at 14:40, Mike Stok wrote: > On Wed, 1 Oct 2003, Quantum Mechanic wrote: > > > I'm looking for an elegant way to generate a list of > > numbers whose binary representation has a given number > > of 1's. I also want to generate this list in numerical > > order. > > > > For example, with 4 bits on, less than 50: > > > > 15 1111 > > 23 10111 > > 27 11011 > > 29 11101 > > 30 11110 > > 39 100111 > > 43 101011 > > 45 101101 > > 46 101110 > > > > Now it's easy enough to check every number up to the > > limit, but it seems there should be a more efficient > > method. On the other hand, the overhead involved in > > "skipping" some numbers may be more expensive than the > > straightforward approach. > > > > Anyone have any insights into this? Sorry I didn't post directly to your post but here's a thought. -- This e-mail transmission is intended for the addressee indicated above. It may contain information that is privileged, confidential or otherwise protected from disclosure. Any review, dissemination, or use of this transmission or its contents by persons other than the addressee is strictly prohibited. --------------------------------------------------------------------- (0 Derek Wueppelmann derek.wueppelmann@newswire.ca D-- Canada NewsWire Ltd. http://www.newswire.ca / ) Work: (416) 863-2107 --------------------------------------------------------------------- From mike at stok.co.uk Wed Oct 1 14:41:03 2003 From: mike at stok.co.uk (Mike Stok) Date: Mon Aug 2 21:25:57 2004 Subject: [Buffalo-pm] Re: [tpm] Bit Counting In-Reply-To: <1065035646.9465.6.camel@sprocket.newswire.ca> Message-ID: On 1 Oct 2003, Derek Wueppelmann wrote: > On Wed, 2003-10-01 at 14:40, Mike Stok wrote: > > On Wed, 1 Oct 2003, Quantum Mechanic wrote: > > > > > I'm looking for an elegant way to generate a list of > > > numbers whose binary representation has a given number > > > of 1's. I also want to generate this list in numerical > > > order. > > > > > > For example, with 4 bits on, less than 50: > > > > > > 15 1111 > > > 23 10111 > > > 27 11011 > > > 29 11101 > > > 30 11110 > > > 39 100111 > > > 43 101011 > > > 45 101101 > > > 46 101110 > > > > > > Now it's easy enough to check every number up to the > > > limit, but it seems there should be a more efficient > > > method. On the other hand, the overhead involved in > > > "skipping" some numbers may be more expensive than the > > > straightforward approach. > > > > > > Anyone have any insights into this? > > Sorry I didn't post directly to your post but here's a thought. ? :-) If you want perl then this does the same as he ruby but is smarter about generating all 0s or 1s: [mike@ratdog tmp]$ cat try.pl #!/usr/bin/env perl use POSIX 'ceil'; sub make_strings (&$$); sub make_strings (&$$) { my ( $block, $ones, $length ) = @_; return if $ones > $length or $length < 1; if ( $ones == 0 ) { $block->( '0' x $length ); } elsif ( $ones == $length ) { $block->( '1' x $length ); } else { make_strings { $block->( "0$_[0]" ) } $ones, $length - 1; make_strings { $block->( "1$_[0]" ) } $ones - 1, $length - 1 if $ones > 0; } } ( $ones, $limit ) = @ARGV; $bits = ceil( log( $limit + 1 ) / log(2) ); ITERATION: { make_strings { my $s = shift; my $value = oct("0b$s"); last ITERATION if $value > $limit; print "$s $value\n"; } $ones, $bits; } [mike@ratdog tmp]$ ./try.pl 4 50 001111 15 010111 23 011011 27 011101 29 011110 30 100111 39 101011 43 101101 45 101110 46 (shame I can't put the & in the prototype at the end and be able to keep dropping the sub keyword...) Mike -- mike@stok.co.uk | The "`Stok' disclaimers" apply. http://www.stok.co.uk/~mike/ | GPG PGP Key 1024D/059913DA mike@exegenix.com | Fingerprint 0570 71CD 6790 7C28 3D60 http://www.exegenix.com/ | 75D2 9EC4 C1C0 0599 13DA From robert_raux at fastmail.fm Mon Oct 6 09:32:09 2003 From: robert_raux at fastmail.fm (Robert Raux) Date: Mon Aug 2 21:25:57 2004 Subject: [Buffalo-pm] Lightning Talk Reminder Message-ID: <1065450728.2030.20.camel@truck.muffins> Hi All-- Just taking a look at who signed up for lightning talks this Thursday and I'm a little disappointed! Please take the time to sign up, let's have some fun with this. Remember, the meeting is: ----------------- Thursday, October 9, 2003 242 Bell Hall (subject to change) 7:00 p.m. UB North Campus ------------------ The lightning talk details (off the website) Lightning Talks are 5-10-minute talks about anything you want to share about Perl: * Your favorite modules * An interesting one-liner * A cool thing you did with Perl * Something you like (or hate) about Perl * Comparing Perl to another programming language * Etc.... This is an evening meeting where everyone can (and SHOULD) participate. Five to ten minutes goes by faster than you think: it's a great opportunity to talk about something without the pressure of putting together a full talk. It's a great forum to discuss a subject that doesn't need a long discussion. Sign up at http://buffalo.pm.org/kwiki/index.cgi?BuffaloLightningTalks If you're interested in *exactly* what this talk is, take a look at http://perl.plover.com/lightning-talks.html I look forward to seeing you all there and I sure hope that we have some more sign-ups. Don't be shy! Rob -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: This is a digitally signed message part Url : http://mail.pm.org/pipermail/buffalo-pm/attachments/20031006/b65ff514/attachment.bin From dmagnuszewski at yahoo.com Mon Oct 6 14:28:43 2003 From: dmagnuszewski at yahoo.com (Daniel Magnuszewski) Date: Mon Aug 2 21:25:58 2004 Subject: [Buffalo-pm] Lightning Talk Reminder In-Reply-To: <1065450728.2030.20.camel@truck.muffins> Message-ID: <20031006192843.95665.qmail@web21104.mail.yahoo.com> I just signed up. Also, UB is having a general meeting for ACM (Association for Computing Machinery) right before this meeting. Hopefully I'll be able to get a large mass of people from that meeting to go to this one. So this could be a big week in the sense of attracting new people into the group. -Dan Robert Raux wrote: Hi All-- Just taking a look at who signed up for lightning talks this Thursday and I'm a little disappointed! Please take the time to sign up, let's have some fun with this. Remember, the meeting is: ----------------- Thursday, October 9, 2003 242 Bell Hall (subject to change) 7:00 p.m. UB North Campus ------------------ The lightning talk details (off the website) Lightning Talks are 5-10-minute talks about anything you want to share about Perl: * Your favorite modules * An interesting one-liner * A cool thing you did with Perl * Something you like (or hate) about Perl * Comparing Perl to another programming language * Etc.... This is an evening meeting where everyone can (and SHOULD) participate. Five to ten minutes goes by faster than you think: it's a great opportunity to talk about something without the pressure of putting together a full talk. It's a great forum to discuss a subject that doesn't need a long discussion. Sign up at http://buffalo.pm.org/kwiki/index.cgi?BuffaloLightningTalks If you're interested in *exactly* what this talk is, take a look at http://perl.plover.com/lightning-talks.html I look forward to seeing you all there and I sure hope that we have some more sign-ups. Don't be shy! Rob > ATTACHMENT part 1.2 application/pgp-signature name=signature.asc _______________________________________________ Buffalo-pm mailing list Buffalo-pm@mail.pm.org http://mail.pm.org/mailman/listinfo/buffalo-pm --------------------------------- Do you Yahoo!? The New Yahoo! Shopping - with improved product search -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/buffalo-pm/attachments/20031006/097fe361/attachment.htm From bpm at binarymojo.net Mon Oct 6 15:36:21 2003 From: bpm at binarymojo.net (Kevin Christopher) Date: Mon Aug 2 21:25:58 2004 Subject: [Buffalo-pm] Lightning Talk Reminder In-Reply-To: <1065450728.2030.20.camel@truck.muffins> References: <1065450728.2030.20.camel@truck.muffins> Message-ID: <5266.64.65.247.81.1065472581.squirrel@my.modwest.com> P.S. to Rob's reminder: I really want to stress again the fact that this Lightning Talk meeting is a very casual, fun, kind of thing. No spit-and-polish or slaving over dozens of presentation slides required. If you were interested in Perl enough to join this list, you will certainly have at least 5 minutes of comments about Perl. You can talk about anything remotely related to Perl (I'm talking about Ruby!). A presentation on your favorite one-liner, for example, will easily fill 5 minutes, and you'll need more time, if anything, to talk about a module. (We will allow a little more time (e.g. up to 10-15 minutes if you need it.). How should you present a Lighting Talk? A few of us were up in Toronto on 9/25 for their Lightning Talks meeting: presenters there used PowerPoint, the Internet, paper photocopies of source code, and the commandline for notes, illustrations, and demos. Just put together a few slides of PowerPoint and bring your laptop, or let let one of your fellow Perl mongers know if you need to borrow a laptop or have some other AV/network needs/questions. See you this Thursday at Bell 242, North Campus, at 7:00 p.m.! -Kevin > Hi All-- > > Just taking a look at who signed up for lightning talks this Thursday > and I'm a little disappointed! Please take the time to sign up, let's > have some fun with this. > > Remember, the meeting is: > ----------------- > Thursday, October 9, 2003 > 242 Bell Hall (subject to change) > 7:00 p.m. > UB North Campus > ------------------ > > The lightning talk details (off the website) > > Lightning Talks are 5-10-minute talks about anything you want to share > about Perl: > > * Your favorite modules > * An interesting one-liner > * A cool thing you did with Perl > * Something you like (or hate) about Perl > * Comparing Perl to another programming language > * Etc.... > This is an evening meeting where everyone can (and SHOULD) participate. > Five to ten minutes goes by faster than you think: it's a great > opportunity to talk about something without the pressure of putting > together a full talk. It's a great forum to discuss a subject that > doesn't need a long discussion. > > Sign up at http://buffalo.pm.org/kwiki/index.cgi?BuffaloLightningTalks > > If you're interested in *exactly* what this talk is, take a look at > http://perl.plover.com/lightning-talks.html > > > I look forward to seeing you all there and I sure hope that we have some > more sign-ups. Don't be shy! > > Rob From bpm at binarymojo.net Wed Oct 8 12:40:06 2003 From: bpm at binarymojo.net (Kevin Christopher) Date: Mon Aug 2 21:25:58 2004 Subject: [Buffalo-pm] Reminder: Tomorrow 7-9: Lightning Talks Message-ID: <7444.64.65.247.81.1065634806.squirrel@my.modwest.com> Lightning Talks Night! Thursday, October 9, 2003 242 Bell Hall 7:00 p.m. UB North Campus Lightning Talks are 5-10-minute talks about anything you want to share about Perl: - Your favorite modules - An interesting one-liner - A cool thing you did with Perl - Something you like (or hate) about Perl - Comparing Perl to another programming language - Etc.... This is an evening meeting where everyone can (and should) participate. Five to ten minutes goes by faster than you think: it's a great opportunity to talk about something without the pressure of putting together a full talk. It's a great forum to discuss a subject that doesn't need a long discussion. Sign up at http://buffalo.pm.org/kwiki/index.cgi?BuffaloLightningTalks Want to know more about what Lightning Talks are all about? See MJD's page on them at: http://perl.plover.com/lightning-talks.html From jlf27 at cse.Buffalo.EDU Wed Oct 8 18:51:54 2003 From: jlf27 at cse.Buffalo.EDU (Jesse L Farinacci) Date: Mon Aug 2 21:25:58 2004 Subject: [Buffalo-pm] lightning talk Message-ID: <20031008235154.GA2307@cse.Buffalo.EDU> hi guys--i signed up for a talk but need these files to be on the display sysetm ... also, does the system have net access? would be great to demo my script.. http://www.cse.buffalo.edu/~jlf27/bpm/ thanks, later, -jesse -- "To live forever, or die in the attempt." Please avoid sending me Word or PowerPoint attachments. See http://www.gnu.org/philosophy/no-word-attachments.html -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 185 bytes Desc: not available Url : http://mail.pm.org/pipermail/buffalo-pm/attachments/20031008/297dcb57/attachment.bin From dmagnuszewski at yahoo.com Fri Oct 10 13:48:29 2003 From: dmagnuszewski at yahoo.com (Daniel Magnuszewski) Date: Mon Aug 2 21:25:58 2004 Subject: [Buffalo-pm] Lightning Talk Message-ID: <20031010184830.99879.qmail@web21105.mail.yahoo.com> All, I was wondering if we could get all those scripts put up on the web site into a "Lightning Talk Archive" section. Also, I wouldn't be opposed to having some lightning talks at the next meeting as well. Thoughts? -Dan --------------------------------- Do you Yahoo!? The New Yahoo! Shopping - with improved product search -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/buffalo-pm/attachments/20031010/2f19ac0c/attachment.htm From robert_raux at fastmail.fm Fri Oct 10 10:10:32 2003 From: robert_raux at fastmail.fm (Robert Raux) Date: Mon Aug 2 21:25:58 2004 Subject: [Buffalo-pm] Lightning Talk In-Reply-To: <20031010184830.99879.qmail@web21105.mail.yahoo.com> References: <20031010184830.99879.qmail@web21105.mail.yahoo.com> Message-ID: <1065798631.1746.3.camel@truck.muffins> On Fri, 2003-10-10 at 18:48, Daniel Magnuszewski wrote: > All, > > I was wondering if we could get all those scripts put up on the web > site into a "Lightning Talk Archive" section. I agree, that seems like a reasonable and helpful request. > Also, I wouldn't be opposed to having some lightning talks at the > next meeting as well. Thoughts? I wouldn't mind varying the location a bit (perhaps alternative brews?). I think it would be neat to do a couple of brief talks on things people have done with perl, or want to do with perl, without the actual code. Perhaps explaining why perl willbe/was the best choice for the project (besides the obvious of course). Just a thought. Rob -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: This is a digitally signed message part Url : http://mail.pm.org/pipermail/buffalo-pm/attachments/20031010/46771162/attachment.bin From bpm at binarymojo.net Tue Oct 14 20:50:33 2003 From: bpm at binarymojo.net (Kevin Christopher) Date: Mon Aug 2 21:25:58 2004 Subject: [Buffalo-pm] Lightning Talk In-Reply-To: <20031010184830.99879.qmail@web21105.mail.yahoo.com> References: <20031010184830.99879.qmail@web21105.mail.yahoo.com> Message-ID: <33084.67.75.60.62.1066182633.squirrel@my.modwest.com> > I was wondering if we could get all those scripts put up on the web site > into a "Lightning Talk Archive" section. Anyone who wants to have their presentation or scripts posted, send me the files and I'll get it on buffalo.pm.org this week. > Also, I wouldn't be opposed to > having some lightning talks at the next meeting as well. Thoughts? It was great to find out what several Perl Mongers are interesting in and doing with Perl. I think it's a good idea to have them fairly regularly, but maybe not back-to-back. -Kevin > All, > > I was wondering if we could get all those scripts put up on the web site > into a "Lightning Talk Archive" section. Also, I wouldn't be opposed to > having some lightning talks at the next meeting as well. Thoughts? > > -Dan > > > --------------------------------- > Do you Yahoo!? > The New Yahoo! Shopping - with improved product search From bpm at binarymojo.net Tue Oct 14 21:31:31 2003 From: bpm at binarymojo.net (Kevin Christopher) Date: Mon Aug 2 21:25:58 2004 Subject: [Buffalo-pm] Lightning Talk Message-ID: <33094.67.75.60.62.1066185091.squirrel@my.modwest.com> Going to an alternative meeting place and kicking back and having a few beers (at Alternative Brews) or coffee (at Higher Grounds Coffee House, quieter than A.B., but still more atmosphere than Bell 242) is a good idea. Whenever we have met off campus, at least one person comments that it's good to get away from the campus. Maybe a good way to get around the AV problem would be for speakers to put together some one- or two-page handouts w/ code examples, etc. -Kevin > On Fri, 2003-10-10 at 18:48, Daniel Magnuszewski wrote: >> All, >> >> I was wondering if we could get all those scripts put up on the web >> site into a "Lightning Talk Archive" section. > > I agree, that seems like a reasonable and helpful request. > >> Also, I wouldn't be opposed to having some lightning talks at the >> next meeting as well. Thoughts? > > I wouldn't mind varying the location a bit (perhaps alternative > brews?). I think it would be neat to do a couple of brief talks on > things people have done with perl, or want to do with perl, without > the actual code. Perhaps explaining why perl willbe/was the best > choice for the project (besides the obvious of course). Just a > thought. > > Rob From cbrandt at buffalo.edu Tue Oct 28 16:58:38 2003 From: cbrandt at buffalo.edu (Jim Brandt) Date: Mon Aug 2 21:25:58 2004 Subject: [Buffalo-pm] IBM Perl articles Message-ID: <443AC2B6-099A-11D8-8AA6-000A9588183A@buffalo.edu> Found a link to these articles on IBMs website of all places. Nice to see Big Blue supporting a *real* language! If that link is too ugly, you can surf there from here: Look for the "Cultured Perl" link. ========================================== Jim Brandt Administrative Computing Services University at Buffalo