Counting all permutations of a substring

Michele Simionato michele.simionato at gmail.com
Thu Apr 6 11:23:36 EDT 2006


Azolex wrote:
> Python 2.5a1 (r25a1:43589, Apr  5 2006, 10:36:43) [MSC v.1310 32 bit
> (Intel)] on win32
> ...
> >>> cnt_ss = lambda s,ss,p=-1,n=-1 : n if n>p else cnt_ss(s,ss,s.find(ss,p+1),n+1)

<sarcastic-mode>
Ah, the pleasure of having a ternary operator in the language!
</sarcastic-mode>

      Michele Simionato




More information about the Python-list mailing list