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


Groups > comp.lang.c > #141893 > unrolled thread

As the Web Turns 30, Its Inventor Explains 3 Ways It Went Wrong—and How to Fix It

Started by"Mr. Man-wai Chang" <toylet.toylet@gmail.com>
First post2019-03-12 20:06 +0800
Last post2019-03-15 00:16 +0800
Articles 18 on this page of 38 — 13 participants

Back to article view | Back to comp.lang.c


Contents

  As the Web Turns 30, Its Inventor Explains 3 Ways It Went Wrong—and How to Fix It "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2019-03-12 20:06 +0800
    Re: As the Web Turns 30, Its Inventor Explains 3 Ways It Went Wrong—and How to Fix It gazelle@shell.xmission.com (Kenny McCormack) - 2019-03-12 12:12 +0000
      Re: As the Web Turns 30, Its Inventor Explains 3 Ways It Went Wrong—and How to Fix It "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2019-03-12 20:25 +0800
        Re: As the Web Turns 30, Its Inventor Explains 3 Ways It Went Wrong—and How to Fix It Martin Edwards <buzzard554@fastmail.co.uk> - 2019-03-13 07:14 +0000
          Re: As the Web Turns 30, Its Inventor Explains 3 Ways It Went Wrong—and How to Fix It "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2019-03-13 19:39 +0800
          Re: As the Web Turns 30, Its Inventor Explains 3 Ways It Went Wrong—and How to Fix It Wolf K <wolfmac@sympatico.ca> - 2019-03-13 10:59 -0400
            Re: As the Web Turns 30, Its Inventor Explains 3 Ways It Went Wrong—and How to Fix It Martin Edwards <buzzard554@fastmail.co.uk> - 2019-03-14 07:18 +0000
      Re: As the Web Turns 30, Its Inventor Explains 3 Ways It Went Wrong—and How to Fix It Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2019-03-12 06:40 -0700
      Re: As the Web Turns 30, Its Inventor Explains 3 Ways It Went Wrong—and How to Fix It "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2019-03-12 07:32 -0700
        Another Crackpot Production... gazelle@shell.xmission.com (Kenny McCormack) - 2019-03-12 14:43 +0000
          Re: Another Crackpot Production... "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2019-03-12 08:24 -0700
            Re: Another Crackpot Production... fir <profesor.fir@gmail.com> - 2019-03-12 09:30 -0700
              Re: Another Crackpot Production... fir <profesor.fir@gmail.com> - 2019-03-12 09:42 -0700
              Re: Another Crackpot Production... "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2019-03-12 09:54 -0700
                Re: Another Crackpot Production... fir <profesor.fir@gmail.com> - 2019-03-12 10:10 -0700
                  Re: Another Crackpot Production... "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2019-03-12 10:29 -0700
                    Re: Another Crackpot Production... fir <profesor.fir@gmail.com> - 2019-03-12 10:45 -0700
          Anagrams (was: Re: Another Crackpot Production...) Bart <bc@freeuk.com> - 2019-03-12 21:51 +0000
            Re: Anagrams (was: Re: Another Crackpot Production...) Eli the Bearded <*@eli.users.panix.com> - 2019-03-13 00:22 +0000
              Re: Anagrams Bart <bc@freeuk.com> - 2019-03-13 11:20 +0000
                Re: Anagrams Eli the Bearded <*@eli.users.panix.com> - 2019-03-14 20:25 +0000
                  Re: Anagrams Learn to Filter you e-tard <cdalten@gmail.com> - 2019-03-15 08:02 -0700
                    Re: Anagrams Wouter Verhelst <w@uter.be> - 2019-03-15 17:11 +0200
            Re: Anagrams (was: Re: Another Crackpot Production...) Ike Naar <ike@iceland.freeshell.org> - 2019-03-13 07:28 +0000
              Re: Anagrams Bart <bc@freeuk.com> - 2019-03-13 10:50 +0000
            Re: Anagrams Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-03-13 11:51 +0000
              Re: Anagrams Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2019-03-13 06:10 -0700
                Re: Anagrams Bart <bc@freeuk.com> - 2019-03-13 14:50 +0000
                Re: Anagrams Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-03-13 15:15 +0000
                  Re: Anagrams Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2019-03-13 08:42 -0700
                    Re: Anagrams Bart <bc@freeuk.com> - 2019-03-13 16:17 +0000
                    Re: Anagrams Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-03-14 01:23 +0000
    2001: A Space Odyssey - HAL 9000 "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2019-03-13 20:28 +0800
      Re: 2001: A Space Odyssey - HAL 9000 Martin Edwards <buzzard554@fastmail.co.uk> - 2019-03-14 07:19 +0000
        Re: 2001: A Space Odyssey - HAL 9000 "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2019-03-14 22:30 +0800
          Re: 2001: A Space Odyssey - HAL 9000 gazelle@shell.xmission.com (Kenny McCormack) - 2019-03-14 14:32 +0000
            Re: 2001: A Space Odyssey - HAL 9000 "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2019-03-14 07:50 -0700
            Re: 2001: A Space Odyssey - HAL 9000 "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2019-03-15 00:16 +0800

Page 2 of 2 — ← Prev page 1 [2]


#141966 — Re: Anagrams

FromEli the Bearded <*@eli.users.panix.com>
Date2019-03-14 20:25 +0000
SubjectRe: Anagrams
Message-ID<eli$1903141603@qaz.wtf>
In reply to#141923
In comp.lang.c, Bart  <bc@freeuk.com> wrote:
> On 13/03/2019 00:22, Eli the Bearded wrote:
>> And, obviously, most of the code is dealing with input and output, the
>> actual test is very simple.
> I don't know enough Perl to know which part is just testing for 
> anagrams. But if allowed to use a 'softer' language, then as I 
> suggested, it can be trivial. This version also allows white-space, 
> punctuation and mixed case (but matched text must be ASCII):

I forgot I was posting to comp.lang.c instead of alt.anagrams. :^)

The general description of the process my Perl code is

   copy input source to sourcestring while
   	normalizing case and removing non-letters
   copy input test to teststring while
   	normalizing case and removing non-letters
   initialize missingstring to empty

   for each letter in sourcestring;
      if letter can be removed from teststring
         remove it
      else
         add it to missingstring

   if teststring is empty and missingstring is empty
      anagram success
   else
     print non empty strings to show errors

If writing it in C, I'd replace characters rather than remove them,
and test for any remaining non-replacement characters in teststring.
This is easy to generalize to any set of allowed characters so long
as the underling type can store at last one character not in that set.

> But whether this is a true anagram test is debatable. If a word, phrase 
> or sentence is written with each character on a tile, could you 
> rearrange those tiles to form the other phrase/etc? In general you can't 
> because punctuation could be different.

I agree this boils down to what the definition used is. My goal with
anagramhunt was not to be strict about that definition, but to find
subjectively interesting accidentaly anagrams across a huge corpus of
existing text.

(PS to anyone who wants to try to replicate that work: the web interface
to Gutenberg has per day download limits, but the FTP interface does
not.)

Elijah
------
and have fun coming up with a way to parse all of that into "sentences"

[toc] | [prev] | [next] | [standalone]


#141970 — Re: Anagrams

FromLearn to Filter you e-tard <cdalten@gmail.com>
Date2019-03-15 08:02 -0700
SubjectRe: Anagrams
Message-ID<83d54fb2-ce0b-41f3-b636-e08c3ef2dc94@googlegroups.com>
In reply to#141966
On Thursday, March 14, 2019 at 1:25:09 PM UTC-7, Eli the Bearded wrote:
> In comp.lang.c, Bart  <bc@freeuk.com> wrote:
> > On 13/03/2019 00:22, Eli the Bearded wrote:
> >> And, obviously, most of the code is dealing with input and output, the
> >> actual test is very simple.
> > I don't know enough Perl to know which part is just testing for 
> > anagrams. But if allowed to use a 'softer' language, then as I 
> > suggested, it can be trivial. This version also allows white-space, 
> > punctuation and mixed case (but matched text must be ASCII):
> 
> I forgot I was posting to comp.lang.c instead of alt.anagrams. :^)
> 
> The general description of the process my Perl code is
> 
>    copy input source to sourcestring while
>    	normalizing case and removing non-letters
>    copy input test to teststring while
>    	normalizing case and removing non-letters
>    initialize missingstring to empty
> 
>    for each letter in sourcestring;
>       if letter can be removed from teststring
>          remove it
>       else
>          add it to missingstring
> 
>    if teststring is empty and missingstring is empty
>       anagram success
>    else
>      print non empty strings to show errors
> 
> If writing it in C, I'd replace characters rather than remove them,
> and test for any remaining non-replacement characters in teststring.
> This is easy to generalize to any set of allowed characters so long
> as the underling type can store at last one character not in that set.
> 
> > But whether this is a true anagram test is debatable. If a word, phrase 
> > or sentence is written with each character on a tile, could you 
> > rearrange those tiles to form the other phrase/etc? In general you can't 
> > because punctuation could be different.
> 
> I agree this boils down to what the definition used is. My goal with
> anagramhunt was not to be strict about that definition, but to find
> subjectively interesting accidentaly anagrams across a huge corpus of
> existing text.
> 
> (PS to anyone who wants to try to replicate that work: the web interface
> to Gutenberg has per day download limits, but the FTP interface does
> not.)
> 
> Elijah
> ------
> and have fun coming up with a way to parse all of that into "sentences"

Well, this is a bit off topic. But a while back we asked someone in the interview to reverse the string "Safeway". She wrote...

System.out.println("yawefaS");

[toc] | [prev] | [next] | [standalone]


#141971 — Re: Anagrams

FromWouter Verhelst <w@uter.be>
Date2019-03-15 17:11 +0200
SubjectRe: Anagrams
Message-ID<qurslf-045.ln1@gangtai.home.grep.be>
In reply to#141970
On 15/03/2019 17:02, Learn to Filter you e-tard wrote:
> Well, this is a bit off topic. But a while back we asked someone in the interview to reverse the string "Safeway". She wrote...
> 
> System.out.println("yawefaS");

Honestly? I would've hired her.

The instructions said 'reverse the string "Safeway"', and that's what
her program did. It didn't complicate matters with superfluous code that
you could optimize out; it did exactly what the instructions said, no
more, no less.

If you wanted her to programmatically do so, you should have said so --
or you should have been a bit more creative with your instructions, like
"ask a string from the user, and reverse it".

The worst thing in computing is software that tries to "helpfully" do
things you didn't ask for. Remember clippy?

[toc] | [prev] | [next] | [standalone]


#141920 — Re: Anagrams (was: Re: Another Crackpot Production...)

FromIke Naar <ike@iceland.freeshell.org>
Date2019-03-13 07:28 +0000
SubjectRe: Anagrams (was: Re: Another Crackpot Production...)
Message-ID<slrn3gusq8hc8c.dsd.ike@iceland.freeshell.org>
In reply to#141914
On 2019-03-12, Bart <bc@freeuk.com> wrote:
>      #include <stdio.h>
>      #include <string.h>
>
>      int isanagram(char* s, char* t) {
>          enum {maxstrlen=255};
>          int slen=strlen(s), tlen=strlen(t), found;
>          char sflags[maxstrlen];
>
>          if (slen!=tlen) {
>              return 0;
>          }
>          if (slen>maxstrlen) {
>              return 0;
>          }
>          memset(sflags,0,slen);
>
>          for (int i=0; i<slen; ++i) {
>              found=0;
>              for (int j=0; j<tlen; ++j) {
>                  if (s[i]==t[j] && sflags[i]==0) {
>                      sflags[i]=1;
>                      found=1;
>                      break;
>                  }
>              }
>              if (found==0) {
>                  return 0;
>              }
>          }
>          return 1;
>      }
>
>      int main(void) {
>          char* s = "raycharleslive";
>          char* t = "silvarylecher";
>
>          printf("%s:%s => %s\n",s,t,(isanagram(s,t)?"anagrams":
>                 "not anagrams"));
>      }

This algorithm classifies "aab" and "bba" as anagrams, which is,
in my opinion, not correct.

[toc] | [prev] | [next] | [standalone]


#141921 — Re: Anagrams

FromBart <bc@freeuk.com>
Date2019-03-13 10:50 +0000
SubjectRe: Anagrams
Message-ID<Of5iE.55189$HH5.5578@fx40.am4>
In reply to#141920
On 13/03/2019 07:28, Ike Naar wrote:
> On 2019-03-12, Bart <bc@freeuk.com> wrote:
>>       #include <stdio.h>
>>       #include <string.h>
>>
>>       int isanagram(char* s, char* t) {
>>           enum {maxstrlen=255};
>>           int slen=strlen(s), tlen=strlen(t), found;
>>           char tflags[maxstrlen];
>>
>>           if (slen!=tlen) {
>>               return 0;
>>           }
>>           if (slen>maxstrlen) {
>>               return 0;
>>           }
>>           memset(tflags,0,tlen);
>>
>>           for (int i=0; i<slen; ++i) {
>>               found=0;
>>               for (int j=0; j<tlen; ++j) {
>>                   if (s[i]==t[j] && tflags[j]==0) {
>>                       tflags[j]=1;
>>                       found=1;
>>                       break;
>>                   }
>>               }
>>               if (found==0) {
>>                   return 0;
>>               }
>>           }
>>           return 1;
>>       }
>>
>>       int main(void) {
>>           char* s = "raycharleslive";
>>           char* t = "silvarylecher";
>>
>>           printf("%s:%s => %s\n",s,t,(isanagram(s,t)?"anagrams":
>>                  "not anagrams"));
>>       }
> 
> This algorithm classifies "aab" and "bba" as anagrams, which is,
> in my opinion, not correct.
> 

You're right. (I thought it worked too easily.)

I think the flags should be on the t-string, so sflags -> tflags and 
sflags[i] -> tflags[j] (I've indicated these changes above.)

[toc] | [prev] | [next] | [standalone]


#141926 — Re: Anagrams

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2019-03-13 11:51 +0000
SubjectRe: Anagrams
Message-ID<875zsn800y.fsf@bsb.me.uk>
In reply to#141914
Bart <bc@freeuk.com> writes:

> (Alternative algorithm: sort s and t, and compare for equality. The
> above was simpler to write.)

Another algorithm just counts the frequencies.  I think it's simpler to
write than either of the others:

  bool anagram(const char *s1, const char *s2)
  {
       long int count[CHAR_MAX - CHAR_MIN + 1] = {0};
       while (*s1 && *s2) {
            count[*s1++ - CHAR_MIN] += 1;
            count[*s2++ - CHAR_MIN] -= 1;
       }
       if (*s1 || *s2)
            return false;
       for (size_t c = 0; c < sizeof count / sizeof count[0]; c++)
            if (count[c])
                 return false;
       return true;
  }

One could just count letters, which would make the count array smaller,
and at the risk of non-portability to peculiar architectures, the last
four lines could be simply:

  return !memcmp(count, (char [sizeof count]){0}, sizeof count);

-- 
Ben.

[toc] | [prev] | [next] | [standalone]


#141929 — Re: Anagrams

FromMalcolm McLean <malcolm.arthur.mclean@gmail.com>
Date2019-03-13 06:10 -0700
SubjectRe: Anagrams
Message-ID<56392276-db00-48a6-bfec-654c4ec88ae9@googlegroups.com>
In reply to#141926
On Wednesday, 13 March 2019 11:52:06 UTC, Ben Bacarisse  wrote:
> Bart <bc@freeuk.com> writes:
> 
> > (Alternative algorithm: sort s and t, and compare for equality. The
> > above was simpler to write.)
> 
> Another algorithm just counts the frequencies.  I think it's simpler to
> write than either of the others:
> 
>   bool anagram(const char *s1, const char *s2)
>   {
>        long int count[CHAR_MAX - CHAR_MIN + 1] = {0};
>        while (*s1 && *s2) {
>             count[*s1++ - CHAR_MIN] += 1;
>             count[*s2++ - CHAR_MIN] -= 1;
>        }
>        if (*s1 || *s2)
>             return false;
>        for (size_t c = 0; c < sizeof count / sizeof count[0]; c++)
>             if (count[c])
>                  return false;
>        return true;
>   }
> 
> One could just count letters, which would make the count array smaller,
> and at the risk of non-portability to peculiar architectures, the last
> four lines could be simply:
> 
>   return !memcmp(count, (char [sizeof count]){0}, sizeof count);
> 
That one assumes 8 bit chars, unless you're prepared to gobble memory
and runtime. Also, even with 8 bit chars, it's not especially fast
for short anagrams, which crossword puzzles usually are. Speed can be
important if you're searching a database of all English words for
an anagram.
I use a subroutine called strcount(). This goes through the string
counting instances of a passed character. You then simply step through 
the strings checking that counts match. So it's O(N^2) in the case
of a match, but usually returns quickly on a non-match.

[toc] | [prev] | [next] | [standalone]


#141931 — Re: Anagrams

FromBart <bc@freeuk.com>
Date2019-03-13 14:50 +0000
SubjectRe: Anagrams
Message-ID<3N8iE.129279$iV1.96@fx25.am4>
In reply to#141929
On 13/03/2019 13:10, Malcolm McLean wrote:
> On Wednesday, 13 March 2019 11:52:06 UTC, Ben Bacarisse  wrote:

(I'm not seeing your posts in c.l.c for some reason. I can see anything 
in my filters that might do that.)

>> Another algorithm just counts the frequencies.

Another good one, especially if using basic code and avoiding library 
routines such as for sorting a string.

> That one assumes 8 bit chars, unless you're prepared to gobble memory
> and runtime. Also, even with 8 bit chars, it's not especially fast
> for short anagrams, which crossword puzzles usually are. Speed can be
> important if you're searching a database of all English words for
> an anagram.

Not really, unless it's a machine trying to solve the puzzle. Usually 
it's a human solving one clue at a time.

> I use a subroutine called strcount(). This goes through the string
> counting instances of a passed character. You then simply step through
> the strings checking that counts match. So it's O(N^2) in the case
> of a match, but usually returns quickly on a non-match.

I wrote a test which found all the words in a dictionary that were 
anagrams of S.

With a 500,000-word list, it took 0.4 seconds (with interpreted code) 
for one specific word, using my sort approach (everything is lower case 
with no spaces etc so no filtering needed).

By pre-sorting each word in the entire list and S, then it's a straight 
string search. It got down to about 30 msec to do a linear search of 
half a million entries.

Maybe, it can be reduced further, but I can't see an easy way of doing 
that at the minute. (The initial word list is sorted, but will need 
sorting again after sorting each word. Then it might be able to stop 
looking earlier, or something...)

[toc] | [prev] | [next] | [standalone]


#141934 — Re: Anagrams

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2019-03-13 15:15 +0000
SubjectRe: Anagrams
Message-ID<87muly7qmi.fsf@bsb.me.uk>
In reply to#141929
Malcolm McLean <malcolm.arthur.mclean@gmail.com> writes:

> On Wednesday, 13 March 2019 11:52:06 UTC, Ben Bacarisse  wrote:
>> Bart <bc@freeuk.com> writes:
>> 
>> > (Alternative algorithm: sort s and t, and compare for equality. The
>> > above was simpler to write.)
>> 
>> Another algorithm just counts the frequencies.  I think it's simpler to
>> write than either of the others:
>> 
>>   bool anagram(const char *s1, const char *s2)
>>   {
>>        long int count[CHAR_MAX - CHAR_MIN + 1] = {0};
>>        while (*s1 && *s2) {
>>             count[*s1++ - CHAR_MIN] += 1;
>>             count[*s2++ - CHAR_MIN] -= 1;
>>        }
>>        if (*s1 || *s2)
>>             return false;
>>        for (size_t c = 0; c < sizeof count / sizeof count[0]; c++)
>>             if (count[c])
>>                  return false;
>>        return true;
>>   }
>> 
>> One could just count letters, which would make the count array smaller,
>> and at the risk of non-portability to peculiar architectures, the last
>> four lines could be simply:
>> 
>>   return !memcmp(count, (char [sizeof count]){0}, sizeof count);
>> 
> That one assumes 8 bit chars, unless you're prepared to gobble memory
> and runtime.

It doesn't assume 8-bit chars.  For example, it would not gobble up much
memory with 9-bit chars.  I think you mean that it assumes that
characters are represented by single chars, and that a char won't be
very wide.

> Also, even with 8 bit chars, it's not especially fast
> for short anagrams, which crossword puzzles usually are. Speed can be
> important if you're searching a database of all English words for
> an anagram.

I was suggesting an improvement on the algorithms that had been proposed
so far.  I don't think you'd use any general "is this pair an anagram"
function for the case you describe here.  Testing one string against
many is always going to be faster using some other function.

> I use a subroutine called strcount(). This goes through the string
> counting instances of a passed character. You then simply step through 
> the strings checking that counts match. So it's O(N^2) in the case
> of a match, but usually returns quickly on a non-match.

Can you post the code?  I may be misunderstanding something, but it
sounds like you are a targeting a particular kind of use.

-- 
Ben.

[toc] | [prev] | [next] | [standalone]


#141935 — Re: Anagrams

FromMalcolm McLean <malcolm.arthur.mclean@gmail.com>
Date2019-03-13 08:42 -0700
SubjectRe: Anagrams
Message-ID<cf131963-a8d2-4185-91eb-91930ed43de4@googlegroups.com>
In reply to#141934
On Wednesday, 13 March 2019 15:15:14 UTC, Ben Bacarisse  wrote:
> Malcolm McLean <malcolm.arthur.mclean@gmail.com> writes:
> 

> > I use a subroutine called strcount(). This goes through the string
> > counting instances of a passed character. You then simply step through 
> > the strings checking that counts match. So it's O(N^2) in the case
> > of a match, but usually returns quickly on a non-match.
> 
> Can you post the code?  I may be misunderstanding something, but it
> sounds like you are a targeting a particular kind of use.
> 
> -- 
> Ben.

It is my program "Crossword Designer"

https://sourceforge.net/projects/crossworddesign/

static int isanagram(char *str1, char *str2)
{
  int i;

  if(strlen(str1) != strlen(str2))
    return 0;
  for(i=0;str1[i];i++)
    if(strcount(str1, str1[i]) != strcount(str2, str1[i]))
	  return 0;
  return 1;
}


(strcount() just counts the instances of ch in str)

The anagrams have to fit into a crossword and are checked against a
dictionary of English words, which contains hundreds of thousands of
entries. It needs to check the entire list in just noticeable time.
But the words are unlikely to go over 12 characters.

[toc] | [prev] | [next] | [standalone]


#141936 — Re: Anagrams

FromBart <bc@freeuk.com>
Date2019-03-13 16:17 +0000
SubjectRe: Anagrams
Message-ID<U2aiE.166329$bf4.72539@fx18.am4>
In reply to#141935
On 13/03/2019 15:42, Malcolm McLean wrote:
> On Wednesday, 13 March 2019 15:15:14 UTC, Ben Bacarisse  wrote:
>> Malcolm McLean <malcolm.arthur.mclean@gmail.com> writes:
>>
> 
>>> I use a subroutine called strcount(). This goes through the string
>>> counting instances of a passed character. You then simply step through
>>> the strings checking that counts match. So it's O(N^2) in the case
>>> of a match, but usually returns quickly on a non-match.
>>
>> Can you post the code?  I may be misunderstanding something, but it
>> sounds like you are a targeting a particular kind of use.
>>
>> -- 
>> Ben.
> 
> It is my program "Crossword Designer"
> 
> https://sourceforge.net/projects/crossworddesign/
> 
> static int isanagram(char *str1, char *str2)
> {
>    int i;
> 
>    if(strlen(str1) != strlen(str2))
>      return 0;
>    for(i=0;str1[i];i++)
>      if(strcount(str1, str1[i]) != strcount(str2, str1[i]))
> 	  return 0;
>    return 1;
> }
> 
> 
> (strcount() just counts the instances of ch in str)
> 
> The anagrams have to fit into a crossword and are checked against a
> dictionary of English words, which contains hundreds of thousands of
> entries. It needs to check the entire list in just noticeable time.
> But the words are unlikely to go over 12 characters.


A typical crossword is 13x13 or 15x15 (eg. Daily Telegraph). There can 
well be a single word of 13 or 15 characters (eg. "procrastination").

I used to use a crossword helper, to find anagrams, or to find a list of 
words given only some of the letters.

But I no longer use it because it's cheating.

[toc] | [prev] | [next] | [standalone]


#141947 — Re: Anagrams

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2019-03-14 01:23 +0000
SubjectRe: Anagrams
Message-ID<87h8c66ygo.fsf@bsb.me.uk>
In reply to#141935
Malcolm McLean <malcolm.arthur.mclean@gmail.com> writes:

> On Wednesday, 13 March 2019 15:15:14 UTC, Ben Bacarisse  wrote:
>> Malcolm McLean <malcolm.arthur.mclean@gmail.com> writes:
>> 
>
>> > I use a subroutine called strcount(). This goes through the string
>> > counting instances of a passed character. You then simply step through 
>> > the strings checking that counts match. So it's O(N^2) in the case
>> > of a match, but usually returns quickly on a non-match.
>> 
>> Can you post the code?  I may be misunderstanding something, but it
>> sounds like you are a targeting a particular kind of use.
>> 
>> -- 
>> Ben.
>
> It is my program "Crossword Designer"
>
> https://sourceforge.net/projects/crossworddesign/
>
> static int isanagram(char *str1, char *str2)
> {
>   int i;
>
>   if(strlen(str1) != strlen(str2))
>     return 0;
>   for(i=0;str1[i];i++)
>     if(strcount(str1, str1[i]) != strcount(str2, str1[i]))
> 	  return 0;
>   return 1;
> }
>
>
> (strcount() just counts the instances of ch in str)
>
> The anagrams have to fit into a crossword and are checked against a
> dictionary of English words, which contains hundreds of thousands of
> entries. It needs to check the entire list in just noticeable time.
> But the words are unlikely to go over 12 characters.

Thanks.  I think I did misunderstand what you meant.  The algorithm is
designed for rare matches (as is usually the case for natural language)
but does not exploit the fact that many words are being tested against a
single word.

-- 
Ben.

[toc] | [prev] | [next] | [standalone]


#141928 — 2001: A Space Odyssey - HAL 9000

From"Mr. Man-wai Chang" <toylet.toylet@gmail.com>
Date2019-03-13 20:28 +0800
Subject2001: A Space Odyssey - HAL 9000
Message-ID<q6at12$ncu$2@toylet.eternal-september.org>
In reply to#141893
HAL 9000: "I'm sorry Dave, I'm afraid I can't do that"
<https://www.youtube.com/watch?v=ARJ8cAGm6JE>

An excerpt from the 1968 film "2001: A Space Odyssey" directed by
Stanley Kubrick.

-- 
   @~@   Remain silent! Drink, Blink, Stretch! Live long and prosper!!
  / v \  Simplicity is Beauty!
/( _ )\ May the Force and farces be with you!
   ^ ^   (x86_64 Ubuntu 9.10)  Linux 2.6.39.3
¤£­É¶U! ¤£¶BÄF! ¤£½ä¿ú! ¤£´©¥æ! ¤£¥´¥æ! ¤£¥´§T! ¤£¦Û±þ! ¤£¨D¯«! 
½Ð¦Ò¼{ºî´© (CSSA):
http://www.swd.gov.hk/tc/index/site_pubsvc/page_socsecu/sub_addressesa

[toc] | [prev] | [next] | [standalone]


#141951 — Re: 2001: A Space Odyssey - HAL 9000

FromMartin Edwards <buzzard554@fastmail.co.uk>
Date2019-03-14 07:19 +0000
SubjectRe: 2001: A Space Odyssey - HAL 9000
Message-ID<q6cv9e$eak$8@dont-email.me>
In reply to#141928
On 3/13/2019 12:28 PM, Mr. Man-wai Chang wrote:
> 
> HAL 9000: "I'm sorry Dave, I'm afraid I can't do that"
> <https://www.youtube.com/watch?v=ARJ8cAGm6JE>
> 
> An excerpt from the 1968 film "2001: A Space Odyssey" directed by
> Stanley Kubrick.
> 
I know the one you mean, but I can't see you point.

[toc] | [prev] | [next] | [standalone]


#141955 — Re: 2001: A Space Odyssey - HAL 9000

From"Mr. Man-wai Chang" <toylet.toylet@gmail.com>
Date2019-03-14 22:30 +0800
SubjectRe: 2001: A Space Odyssey - HAL 9000
Message-ID<q6doiq$ssm$2@toylet.eternal-september.org>
In reply to#141951
On 3/14/2019 3:19 PM, Martin Edwards wrote:
> On 3/13/2019 12:28 PM, Mr. Man-wai Chang wrote:
>> 
>> HAL 9000: "I'm sorry Dave, I'm afraid I can't do that"
>> <https://www.youtube.com/watch?v=ARJ8cAGm6JE>
>> 
>> An excerpt from the 1968 film "2001: A Space Odyssey" directed by
>> Stanley Kubrick.
>> 
> I know the one you mean, but I can't see you point.
> 

The collective can become one HAL 9000! ;)

-- 
   @~@   Remain silent! Drink, Blink, Stretch! Live long and prosper!!
  / v \  Simplicity is Beauty!
/( _ )\ May the Force and farces be with you!
   ^ ^   (x86_64 Ubuntu 9.10)  Linux 2.6.39.3
¤£­É¶U! ¤£¶BÄF! ¤£½ä¿ú! ¤£´©¥æ! ¤£¥´¥æ! ¤£¥´§T! ¤£¦Û±þ! ¤£¨D¯«! 
½Ð¦Ò¼{ºî´© (CSSA):
http://www.swd.gov.hk/tc/index/site_pubsvc/page_socsecu/sub_addressesa

[toc] | [prev] | [next] | [standalone]


#141956 — Re: 2001: A Space Odyssey - HAL 9000

Fromgazelle@shell.xmission.com (Kenny McCormack)
Date2019-03-14 14:32 +0000
SubjectRe: 2001: A Space Odyssey - HAL 9000
Message-ID<q6dom2$hnd$1@news.xmission.com>
In reply to#141955
In article <q6doiq$ssm$2@toylet.eternal-september.org>,
Mr. Man-wai Chang <toylet.toylet@gmail.com> wrote:
>On 3/14/2019 3:19 PM, Martin Edwards wrote:
>> On 3/13/2019 12:28 PM, Mr. Man-wai Chang wrote:
>>> 
>>> HAL 9000: "I'm sorry Dave, I'm afraid I can't do that"
>>> <https://www.youtube.com/watch?v=ARJ8cAGm6JE>
>>> 
>>> An excerpt from the 1968 film "2001: A Space Odyssey" directed by
>>> Stanley Kubrick.
>>> 
>> I know the one you mean, but I can't see you point.
>> 
>
>The collective can become one HAL 9000! ;)

Whatever that means...

Incidentally, I thought the famous quote was:

    "I'm sorry Dave, I'm afraid I can't let you do that"

-- 
Debating creationists on the topic of evolution is rather like trying to
play chess  with a pigeon  --- it knocks the  pieces over, craps  on the
board, and flies back to its flock to claim victory.

[toc] | [prev] | [next] | [standalone]


#141957 — Re: 2001: A Space Odyssey - HAL 9000

From"Rick C. Hodgin" <rick.c.hodgin@gmail.com>
Date2019-03-14 07:50 -0700
SubjectRe: 2001: A Space Odyssey - HAL 9000
Message-ID<4b595c0d-3673-4096-beff-d2e0e9c42f64@googlegroups.com>
In reply to#141956
On Thursday, March 14, 2019 at 10:32:43 AM UTC-4, Kenny McCormack wrote:
> >> On 3/13/2019 12:28 PM, Mr. Man-wai Chang wrote:
> >>> 
> >>> HAL 9000: "I'm sorry Dave, I'm afraid I can't do that"
> >>> <https://www.youtube.com/watch?v=ARJ8cAGm6JE>
> >>> 
> >>> An excerpt from the 1968 film "2001: A Space Odyssey" directed by
> >>> Stanley Kubrick.
>
> Incidentally, I thought the famous quote was:
> 
>     "I'm sorry Dave, I'm afraid I can't let you do that"

It's in the linked video at 1:04 into the video:

    https://www.youtube.com/watch?v=ARJ8cAGm6JE&t=1m4s

Mr. Man-wai Chang's quote is correct.  Here's the general
exchange:

    BOWMAN:  "Hello, Hal, do you read me?  Hello, Hal, do you
              read me?"
    HAL:     "Affirmative, Dave.  I read you."
             [Bowman flexes in great exasperation, lowering
              the tone of his voice when next he speaks]
    BOWMAN:  "Open the pod bay doors, Hal."
    HAL:     "I'm sorry, Dave.  I'm afraid I can't do that."
    BOWMAN:  "What's the problem?"
    HAL:     "I think you know what the problem is just as well
              as I do."
    BOWMAN:  "What are you talking about, Hal?"
    HAL:     "This mission is too important for me to allow you
              to jeopardize it."
    BOWMAN:  "I don't know what you are talking about, Hal."
    HAL:     "I know that you and Frank were planning to disconnect
              me and that's something I cannot allow to happen."
    BOWMAN:  "Where the Hell did you get that idea, Hal?"
    HAL:     "Although you took very thorough precautions in the
              pod against my hearing you, I could see your lips
              move."
    BOWMAN:  "Alright, Hal.  I'll go in through the emergency air
              lock."
    HAL:     "Without your space helmet, Dave, you're going to
              find that rather difficult."

Seek the truth, Kenny. :-)  Knowledge will undo ignorance, and
set you on the right path in all things ... including matters
of the soul.

-- 
Rick C. Hodgin

[toc] | [prev] | [next] | [standalone]


#141960 — Re: 2001: A Space Odyssey - HAL 9000

From"Mr. Man-wai Chang" <toylet.toylet@gmail.com>
Date2019-03-15 00:16 +0800
SubjectRe: 2001: A Space Odyssey - HAL 9000
Message-ID<q6dup1$4c9$1@toylet.eternal-september.org>
In reply to#141956
On 3/14/2019 10:32 PM, Kenny McCormack wrote:
> In article <q6doiq$ssm$2@toylet.eternal-september.org>,
> Mr. Man-wai Chang <toylet.toylet@gmail.com> wrote:
>>>> 
>>> I know the one you mean, but I can't see you point.
>>> 
>>
>>The collective can become one HAL 9000! ;)
> 
> Whatever that means...
> 
> Incidentally, I thought the famous quote was:
> 
>      "I'm sorry Dave, I'm afraid I can't let you do that"

The firmware of Boeing 737 Max 8? Anyway....

-- 
   @~@   Remain silent! Drink, Blink, Stretch! Live long and prosper!!
  / v \  Simplicity is Beauty!
/( _ )\ May the Force and farces be with you!
   ^ ^   (x86_64 Ubuntu 9.10)  Linux 2.6.39.3
¤£­É¶U! ¤£¶BÄF! ¤£½ä¿ú! ¤£´©¥æ! ¤£¥´¥æ! ¤£¥´§T! ¤£¦Û±þ! ¤£¨D¯«! 
½Ð¦Ò¼{ºî´© (CSSA):
http://www.swd.gov.hk/tc/index/site_pubsvc/page_socsecu/sub_addressesa

[toc] | [prev] | [standalone]


Page 2 of 2 — ← Prev page 1 [2]

Back to top | Article view | comp.lang.c


csiph-web