http://www.perlmonks.org?node_id=496733


in reply to Determining uniqueness in a string.

Hi, Unfortunately at this moment i can't test the speed of my little idea about your problem. Well, i think that a simple solution is to add all digits and test if the result is 45, infact the sum of all digits in a ten character string is 45 only where every digit from the set 0-9 occurs exactly once, according to the Gauss' formula (N*(N*1)/2). I hope that, in spite of my ugly english, this little idea can help someone.

Replies are listed 'Best First'.
Re^2: Determining uniqueness in a string
by Yzzyx (Beadle) on Oct 02, 2005 at 13:17 UTC
    9 + 8 + 7 + 6 + 5 + 4 + 1 + 1 + 2 + 2 = 45
      errare humanum est... your reply is an incitation for me to being more careful and above all testing my little ideas.