Ad

Use a Functional Programming approach. Though this may look somewhat awkward (map instead of a generator expression), this is easier to parse and optimize. In the long run, it becomes easier to read, too.

Code
Diff
  • def getIDS(s):
        return sum(map(ord, s)) - 48 * len(s)
    • def getIDS(s):
    • return sum(ord(x) for x in s) - 48 * len(s)
    • return sum(map(ord, s)) - 48 * len(s)