[Linuxtrent] Re: Anagrammi in Python

  • From: Lele Gaifax <lele@xxxxxxxxxxxxxxxxxxx>
  • To: linuxtrent@xxxxxxxxxxxxx
  • Date: 09 Aug 2004 15:16:13 +0200

La sfida della notte scorsa ha prodotto un interessante risultato, che
ha stupito perfino l'autore di quel gazzabuglio perl :)

<baka> your pythonic anagram thingie is interesting.
<baka> i got it down to 104 chars, and by a factor of 4-5 faster. ;)
<baka> it lost the "function returns anagram list" property and is a
       pure-printer now though. ;)

    def a(w,R="",c=""):
            if not w:print R
            while w:d,w=w[0],w[1:];a(w+c,R+d);c+=d
    import sys;a(sys.argv[1])

<baka> the scary part is, its 25% smaller _AND_ faster than the 130
       char perl version that way. :(
<baka> outperformed by a frelling snake.

... quando si esce soddisfatti dal essere battuti! Hehehe!

ciao, lele.
-- 
nickname: Lele Gaifax   | Quando vivrò di quello che ho pensato ieri
real: Emanuele Gaifas   | comincerò ad aver paura di chi mi copia.
email: lele@xxxxxxxxxx  |               -- Fortunato Depero, 1929.

--
Per iscriversi  (o disiscriversi), basta spedire un  messaggio con OGGETTO
"subscribe" (o "unsubscribe") a mailto:linuxtrent-request@xxxxxxxxxxxxx


Other related posts: