Given a string, turn each letter into its ASCII character code and join them together to create a number - let's call this number `total1`:

```
'ABC' --> 'A' = 65, 'B' = 66, 'C' = 67 --> 656667
```

Then replace any incidence of the number `7` with the number `1`, and call this number 'total2':
```
total1 = 656667
              ^
total2 = 656661
              ^
```

Then return the difference between the sum of the digits in `total1` and `total2`:

```
  (6 + 5 + 6 + 6 + 6 + 7)
- (6 + 5 + 6 + 6 + 6 + 1)
-------------------------
                       6
```

Source: codewars | Difficulty: EASY
Tags: String algorithms

Fundamentals

Data structures

Mathematics

Starter code: def calc(x):
	

Solutions:
def calc(s):
	total1 = ''.join(map(lambda c: str(ord(c)), s))
	total2 = total1.replace('7', '1')
	return sum(map(int, total1)) - sum(map(int, total2))


def calc(x):
	return ''.join((str(ord(ch)) for ch in x)).count('7') * 6


def calc(x):
	return ''.join([str(ord(x[i])) for i in range(len(x))]).count('7') * 6


def calc(x):
	total1 = ''.join((str(ord(char)) for char in x))
	total2 = total1.replace('7', '1')
	return sum((int(x) for x in total1)) - sum((int(x) for x in total2))


def calc(x):
	return sum((sum((6 for i in str(ord(i)) if i == '7')) for i in x))


def calc(string):
	return ''.join((str(ord(char)) for char in string)).count('7') * 6


def calc(s):
	return sum((2 if c == 'M' else c in '%/9CFGHIJKLNOWaku' for c in s)) * 6


def calc(x):
	return sum((6 for c in ''.join(map(str, map(ord, x))) if c == '7'))


def calc(x):
	n = ''.join(map(lambda y: str(ord(y)), x))
	return n.count('7') * 6


def calc(x):
	n1 = ''.join([str(ord(c)) for c in x])
	n2 = n1.replace('7', '1')
	return sum(map(int, n1)) - sum(map(int, n2))