-7

Can we solve anagram test puzzle by getting ascii value of each character in the string and then find sum of all characters , then calculate the same for other string and then compare two values(sum)?

Is it feasible?

timrau
  • 22,578
  • 4
  • 51
  • 64
Neo
  • 5
  • 3
  • 1
    No, different words could sum to the same value, for instance "ben" and "fan". – Crowman Apr 27 '14 at 02:05
  • Welcome to SO. Please read [How to Ask](http://stackoverflow.com/questions/how-to-ask) and [help center](http://stackoverflow.com/help) on how to ask a question. – Deduplicator Apr 27 '14 at 02:09
  • 1
    It's simple to check if two strings are anagrams: Sort both and compare. `qsort` `strcmp`. – Deduplicator Apr 27 '14 at 02:11
  • possible duplicate of [A possible algorithm for determining whether two strings are anagrams of one another?](http://stackoverflow.com/questions/14739186/a-possible-algorithm-for-determining-whether-two-strings-are-anagrams-of-one-ano) – jerry May 17 '14 at 03:00
  • You can guarantee uniqueness by using a slightly similar approach of multiplying prime factors - http://stackoverflow.com/questions/18781106/generate-same-unique-hash-code-for-all-anagrams/ – Leeor May 17 '14 at 04:02

1 Answers1

6

Of course not. Counterexample: ac vs bb.

timrau
  • 22,578
  • 4
  • 51
  • 64