Results 1 to 2 of 2

Thread: It Isn't Etaoin Shrdlu; It's Etaoni Rshdlc

  1. #1
    Member caveman's Avatar
    Join Date
    Jul 2009
    Location
    Strasbourg, France
    Posts
    190
    Thanks
    8
    Thanked 62 Times in 33 Posts

    It Isn't Etaoin Shrdlu; It's Etaoni Rshdlc

    I just came across this:
    http://jmq.sagepub.com/content/43/4/761.extract
    and did not bother to confirm this 1966 paper...

  2. #2
    Expert
    Matt Mahoney's Avatar
    Join Date
    May 2008
    Location
    Melbourne, Florida, USA
    Posts
    3,255
    Thanks
    306
    Thanked 778 Times in 485 Posts
    ETAONI HSRDLU WMCGFYBPVKXJQZ in calgary/book1
    ETAONI HSRDLU MWCFGYPBVKXJQZ in silesia/dickens
    EANITO RSLCDU MPHGFBYVWKXJZQ in maxcomp/world95.txt
    ETHAON ISRDLU FMWYGCBPVKJZXQ in cantrbry_large/bible.txt
    ETAION RSLHCD MUPGFBYWVKQXJZ in enwik8
    ETAION RSLHDC MUPGFBYWVKQXJZ in enwik9
    ETASIN ORLDCP UHMGFBWYKVXJQZ in Reuters 21578 corpus

    Code:
    // Print alphabet by decreasing frequency from file name args
    // Public domain.
    
    #include <stdio.h>
    int main(int argc, char** argv) {
      int t[26]={0}, c, n=0;
      char buf[4096];
      for (int i=1; i<argc; ++i) {
        FILE* in=fopen(argv[i], "rb");
        while (in && (n=fread(buf, 1, 4096, in))>0) {
          for (int j=0; j<n; ++j) {
            c=buf[j];
            if (c>='a' && c<='z') ++t[c-'a'];
            if (c>='A' && c<='Z') ++t[c-'A'];
          }
        }
        if (in) fclose(in);
      }
      n=0;
      for (int i=0; i<26; ++i) {
        int b=0;
        for (int j=1; j<26; ++j)
          if (t[j]>t[b]) b=j;
        printf("%c", b+'A');
        if (i==5 || i==11) printf(" ");
        n+=t[b];
        t[b]=-1;
      }
      printf(" n=%d\n", n);
      return 0;
    }

  3. The Following 2 Users Say Thank You to Matt Mahoney For This Useful Post:

    biject.bwts (5th January 2014),caveman (25th January 2014)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •