Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > sci.math > #325379

Re: Algorithm involving binary strings.

From JohnF <john@please.see.sig.for.email.com>
Newsgroups sci.math
Subject Re: Algorithm involving binary strings.
Date 2016-01-02 12:50 +0000
Organization PANIX Public Access Internet and UNIX, NYC
Message-ID <n68h26$h24$1@reader1.panix.com> (permalink)
References (3 earlier) <0685fc25-f598-47c8-b037-23ac17659e10@googlegroups.com> <n64nmv$lrv$1@reader1.panix.com> <6e5fb971-139e-4155-936e-4a0f8e6191ab@googlegroups.com> <n67bjq$mde$1@reader1.panix.com> <2f7d57ff-f16e-4aeb-bf71-987b2b25c15f@googlegroups.com>

Show all headers | View raw


Paul <pepstein5@gmail.com> wrote:
<<snip>>
> Thanks for your comments. bitset<M>; won't compile
> unless M is a constant.
I wasn't aware of that. In fact, I usually code in C,
and wasn't aware of bitset at all until you mentioned
it and I looked it up.

> That's why I used bitset<500>
That would explain it.

> Do you know of a workaround (other than coding in another language)? 
Nope... how about
   switch(M) {
     case 1: bitset<1> etc; break;
     case 2: bitset<2> etc; break;
     default: bitset<500> etc; break; }
just kidding. Though you could have just a few cases
   if ( M <= 100 ) { bitset<100> etc; }
   else if ( M <= 200 } { you_know_the_rest; }
That always-<500> default's gotta cost a lot of
usually-unnecessary work. And efficiency's apparently
a sine qua non for this exercise.

> Attempting to solve problems and using a book as a reference only
> when stuck has many difficulties.  One drawback is that deficits
> in a person's knowledge can go unrepaired.  For example, a problem
> might involve sorting and a person might only know O(n^2) methods,
> and might happily code such a solution without consulting the
> algorithms book, and never learn the more efficient methods.

What comes to mind for me is that it took me a while to come across
recursive descent parsing, which would have neatened up a lot of
my code if I'd known the technique sooner. And I'm sure there are
other similar cases that I still don't know about.

> My idea is to read Algorithms Unlocked (simply because it's like
> CLRS and much shorter) and then attempt problems from hackerrank.

I've got a print copy of CLRS first edition, from way back.
Maybe Algorithms Unlocked might be worth a look. Got a url for that?:)

> I've also never heard of executable code being embedded in pdf's.
> The point I was trying to make is that there are lots of pirate
> sites giving away free ebooks online without the publishers' consent.
> (I have no idea whether your recommended download comes from one of
> those sites).  Downloading (and even visiting without downloading)
> such sites is fraught with virus risk.  As far as I know, the risk
> is not generally associated with the pdf document itself.  Here
> I'm using "virus" as a generic term for "bad alterations to your
> computer".  The most usual problem (in cases where there is a problem)
> is that activating the download secretly downloads other stuff besides
> the pdf and it is these other files that cause the problem.  Malware
> is the correct term, I think.
> Paul

Yeah, I used wget to download the pdf, without even visiting the site.
And I guess I could have done that from my shell account on my ISP,
and then scp'ed it to my pc from there. And, yeah, I'd guess the pdf
isn't legal.
-- 
John Forkosh  ( mailto:  j@f.com  where j=john and f=forkosh )

Back to sci.math | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Algorithm involving binary strings. Paul <pepstein5@gmail.com> - 2015-12-30 09:41 -0800
  Re: Algorithm involving binary strings. Virgil <VIRGIL@VIRGIL.com> - 2015-12-30 13:16 -0700
  Re: Algorithm involving binary strings. quasi <quasi@null.set> - 2015-12-30 16:30 -0500
    Re: Algorithm involving binary strings. James Waldby <not@valid.invalid> - 2015-12-31 01:18 +0000
  Re: Algorithm involving binary strings. JohnF <john@please.see.sig.for.email.com> - 2015-12-31 06:53 +0000
    Re: Algorithm involving binary strings. Paul <pepstein5@gmail.com> - 2015-12-31 06:46 -0800
      Re: Algorithm involving binary strings. Paul <pepstein5@gmail.com> - 2015-12-31 07:38 -0800
        Re: Algorithm involving binary strings. John Forkosh <forkosh@panix.com> - 2016-01-01 02:19 +0000
          Re: Algorithm involving binary strings. JohnF <john@please.see.sig.for.email.com> - 2016-01-01 11:44 +0000
          Re: Algorithm involving binary strings. Paul <pepstein5@gmail.com> - 2016-01-01 05:00 -0800
            Re: Algorithm involving binary strings. JohnF <john@please.see.sig.for.email.com> - 2016-01-02 02:11 +0000
              Re: Algorithm involving binary strings. Paul <pepstein5@gmail.com> - 2016-01-02 02:20 -0800
                Re: Algorithm involving binary strings. JohnF <john@please.see.sig.for.email.com> - 2016-01-02 12:50 +0000
                Re: Algorithm involving binary strings. Paul <pepstein5@gmail.com> - 2016-01-02 07:12 -0800
                Re: Algorithm involving binary strings. JohnF <john@please.see.sig.for.email.com> - 2016-01-03 04:55 +0000

csiph-web