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


Groups > sci.math > #325415

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-03 04:55 +0000
Organization PANIX Public Access Internet and UNIX, NYC
Message-ID <n6a9ja$le7$1@reader1.panix.com> (permalink)
References (5 earlier) <6e5fb971-139e-4155-936e-4a0f8e6191ab@googlegroups.com> <n67bjq$mde$1@reader1.panix.com> <2f7d57ff-f16e-4aeb-bf71-987b2b25c15f@googlegroups.com> <n68h26$h24$1@reader1.panix.com> <e65d054d-35b6-4ab6-80e3-2b60a9d6128b@googlegroups.com>

Show all headers | View raw


Paul <pepstein5@gmail.com> wrote:
> On Saturday, January 2, 2016 at 12:50:27 PM UTC, JohnF wrote:
>> 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,
> I am ignorant about Gnu and related issues.
> I had no idea what wget meant and read it as a typo for "get".
> Good that you are using safe methods to get downloads.

My bad, sorry about that, I just assumed linux (and friends)
was de rigueur among programmers. And I'm now assuming you've
googled wget and know all you need to. (see below about "safe")

> Algorithms Unlocked is available via vk.com  I will link to the
> download page and also another page about vk.com to enable you
> to decide whether you want to support their site.
> vk.com is described here:
>    https://en.wikipedia.org/wiki/VK_(social_networking)

Well, part of that page says,
  "VK grants easy access to pornographic images, video and
   other such materials..."
so "support" isn't exactly the word describing what I'd like
to do to them.

> They allow you to download the book here:
>  https://vk.com/doc10903696_190637386?hash=a53c5f15549ac496d2&dl=8c0954f5b4aea05a0a  

Thanks for the link, Paul. The "safe" trick here is to first wget
that doc109... page. Then viewing its source reveals
   function saveDoc() {
     var src = 'https://psv4.vk.me/c537109/u10903696/docs/652b58883d71/Algorithms_Unlocked.pdf?extra=wcHQkQX9yBQ5X...etc'
And so the direct link to the pdf is just
 https://psv4.vk.me/c537109/u10903696/docs/652b58883d71/Algorithms_Unlocked.pdf
and now you can wget that pdf directly, without ever browser-visiting
any page at all. And note the copyright's MIT Press 2013, so I suppose
we can conclude it's pirated. But my cursory examination is that
you're right -- it's a great book. Indeed, the preface and intro are
pretty much word-for-word taken from its bigger brother.

> I had not heard of recursive descent parsing. I am interviewing
> for software dev jobs and want to limit my searching to areas
> of vocational value.  Outside academia, do you think that this
> technique is valuable to employers?  If so, I will look into it.
> Thanks again for your help.
> Paul

Well, I >>don't<< think it's likely to be valuable on an interview.
And neither Cormen book discusses it, but it's pretty much
chapter one in many compiler design books. If you have the bnf grammar
for a language you need to parse, then recursive descent's the
straightforward and elegant way to do it. I haven't written any
compilers, but lots of applications I've written required designing
a "little language" (very little) for user input. And my brute force
parsing required way more coding than should have been necessary.
Even parsing something as simple as a ?query_string of the form
<variable>=<value>&<variable>=<value>&etc is likely to benefit.
(You can google  recursive descent bnf  for more info, if interested.)
-- 
John Forkosh  ( mailto:  j@f.com  where j=john and f=forkosh )

Back to sci.math | Previous | Next — Previous 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