Question: I only need to show the span if the user input value is greater than 1 and the input field doesn't contains the values defined in the regular expression.

Code:

```
<!doctype html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <title>Example - example-ng-form-production</title>

  <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js"></script>
  <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular-animate.js"></script>

  <script type="text/javascript">
    angular.element(document.getElementsByTagName('head')).append(angular.element('<base href="' + window.location.pathname + '" />'));
  </script>
</head>

<body ng-app="formExample">
  <script>
    angular.module('formExample', [])
      .controller('FormController', ['$scope', function($scope) {
        $scope.userType = '';
        $scope.regex = "#%<;'=";
      }]);
  </script>
  <form name="myForm" ng-controller="FormController" class="my-form">
    userType:
    <input name="input" ng-model="userType" ng-pattern="regex && userType">
    <span ng-show="userType && myForm.input.$valid">show me!</span>
    <br>
  </form>
</body>

</html>

```

[Plunker Demo](https://plnkr.co/edit/xs2beXGoSnHUiIRG4DKw?p=preview)

Answer: 
Instead of comparing all pairs of strings, you can just create a dictionary (or [`collections.defaultdict`](https://docs.python.org/3/library/collections.html#collections.defaultdict)) mapping each of the letter-counts to the words having those counts. For getting the letter-counts, you can use [`collections.Counter`](https://docs.python.org/3/library/collections.html#collections.Counter). Afterwards, you just have to get the values from that dict. If you want all words that are anagrams of any other words, just merge the lists that have more than one entry.

```
strings = ["cat", "act", "rat", "hut", "tar", "tact"]
anagrams = defaultdict(list)

for s in strings:
    anagrams[frozenset(Counter(s).items())].append(s)

print([v for v in anagrams.values()])
# [['hut'], ['rat', 'tar'], ['cat', 'act'], ['tact']]
print([x for v in anagrams.values() if len(v) > 1 for x in v])
# ['cat', 'act', 'rat', 'tar']

```

Of course, if you prefer not to use builtin functionality you can with just a few more lines just as well use a regular `dict` instead of `defaultdict` and write your own `Counter`, similar to what you have in your `isanagram` method, just without the comparison part.
The same can be done with a single line of code if you are using Linq in C#

string[] = strs; // Input string array

var result = strs.GroupBy(x => new string(x.ToCharArray().OrderBy(z => z).ToArray())).Select(g => g.ToList()).ToList();