Mostra notizie nelle discussioni
  • Avatar
    Scritto da
    Non Autenticato
    il 2008-08-02 20:05:00.0 alle 2008-08-02 20:05:00.0
    Questa è arte in c
    typedef unsigned char B;B*x[]={
    #include "dict.h"
    0};typedef struct L{B*s;struct L*n;}L;
    L*h[128],*l[128],*s[128],Z[sizeof x/sizeof*x],*F=Z;int c[256],m,a=1;
    int k(B*q){int g=0;B*p=q;while(*p)g|=!c[*p++]--;return g-1&p-q;}
    void u(B*p){while(*p)c[*p++]++;}
    void S(int N,int r,int t,L*W){L*w;int i,n;
     for(n=r<N?r:N;n>0;n--)for(w=n==N?W:h[n];s[t]=w;u(w->s),w=w->n)if(k(w->s))
      if(n==r){if(t==m-1)for(i=a=0;i<=t;i++)printf("%s%c",s[i]->s,i<t?' ':'\n');}
      else if(t<m-1)S(n,r-n,t+1,s[t]=w);}
    int main(int C,B**A){int i=0,g,n=0;B*p;while(--C)for(p=*++A;n<127&&*p;)c[*p++]++,n++;
     for(;p=x[i++];u(p))if(g=k(p))(l[g]=*(l[g]?&l[g]->n:&h[g])=F++)->s=p;
     while(++m<128)S(127,n,0,h[127]);
     return a;}
    



    Abuse of the rules Winner 2004

    Peter Klausler
    Cray Inc.

    To build

      #!/bin/sh
      dict=""
      for f in mydict /usr/share/dict/words /usr/dict/words /usr/lib/dict/words
      do if [ -r $f ]; then dict="$dict $f"; fi; done
      if [ ".$dict" = . ]; then echo no dictionary found; exit 1; fi
      cat $dict |
         tr -cd 'A-Za-z\n' |
         tr A-Z a-z | 
         egrep -v '^[^ais]$' |
         sort |
         uniq |
         sed 's/^/"/;s/$/",/' >dict.h
      cc -o klausler klausler.c



    To run

    klausler peter klausler | head


    Author's comments

    A useful tool to help one appear extra smart and witty when IRCing, or even just highly annoying.

    Finds best anagrams for word or phrase given as program arguments. Use only lower-case letters in these arguments. Output is sorted firstly in ascending order of word count (fewer words are better) and secondly in descending order of word length. Pipe the output into more(1)/less(1)/head(1) and you're likely to find the most amusing possibilities in the first few screenfuls of output. For example, "ana fawlty towers | more" quickly prints "waterfowl sty". The fewer obscure short words in your system's dictionary, the better the quality of the output; indeed, all one-letter words apart from "a", "i", and "s" (for plurals) are ignored when the dictionary is constructed by build.sh.
    • Avatar
      Scritto da
      Non Autenticato
      il 2008-08-02 20:18:00.0 alle 2008-08-02 20:18:00.0
      Re: Questa è arte in c
      #include <stdio.h>
      int l;int main(int o,char **O,
      int I){char c,*D=O[1];if(o>0){
      for(l=0;D[l              ];D[l
      ++]-=10){D   [l++]-=120;D[l]-=
      110;while   (!main(0,O,l))D[l]
      +=   20;   putchar((D[l]+1032)
      /20   )   ;}putchar(10);}else{
      c=o+     (D[I]+82)%10-(I>l/2)*
      (D[I-l+I]+72)/10-9;D[I]+=I<0?0
      :!(o=main(c/10,O,I-1))*((c+999
      )%10-(D[I]+92)%10);}return o;}
      
      • Avatar
        Scritto da
        Non Autenticato
        il 2008-08-02 20:22:00.0 alle 2008-08-02 20:22:00.0
        Re: Questa è arte in c

        - Scritto da:
        >
        > #include <stdio.h>
        > int l;int main(int o,char **O,
        > int I){char c,*D=O[1];if(o>0){
        > for(l=0;D[l              ];D[l
        > ++]-=10){D   [l++]-=120;D[l]-=
        > 110;while   (!main(0,O,l))D[l]
        > +=   20;   putchar((D[l]+1032)
        > /20   )   ;}putchar(10);}else{
        > c=o+     (D[I]+82)%10-(I>l/2)*
        > (D[I-l+I]+72)/10-9;D[I]+=I<0?0
        > :!(o=main(c/10,O,I-1))*((c+999
        > )%10-(D[I]+92)%10);}return o;}
        > 



        questà è sempre stata la mia preferita Geek
<softv>

Pagina generata in 19 millisecondi

Utenti attivi: 29 nell'ultimo minuto, 84 negli ultimi cinque minuti, 146 negli ultimi 15 minuti