Write a function that receives two strings and returns n, where n is equal to the number of characters we should shift the first string forward to match the second.

For instance, take the strings "fatigue" and "tiguefa". In this case, the first string has been rotated 5 characters forward to produce the second string, so 5 would be returned.
If the second string isn't a valid rotation of the first string, the method returns -1. 

Examples:
```
"coffee", "eecoff" => 2
"eecoff", "coffee" => 4
"moose", "Moose" => -1
"isn't", "'tisn" => 2
"Esham", "Esham" => 0
"dog", "god" => -1
```

For Swift, your function should return an Int?. So rather than returning -1 when the second string isn't a valid rotation of the first, return nil.

Source: codewars | Difficulty: EASY
Tags: String algorithms

Data structures

Starter code: def shifted_diff(first, second):
	

Solutions:
def shifted_diff(first, second):
	return (second + second).find(first) if len(first) == len(second) else -1


def shifted_diff(first, second):
	for i in range(len(first)):
		if first == second[i:] + second[:i]:
			return i
	return -1


def shifted_diff(f, s):
	try:
		ix = s.index(f[0])
		return ix if f == s[ix:] + s[:ix] else -1
	except:
		return -1


def xx(s):
	return s[1:] + s[0]

def shifted_diff(a, b):
	if a == b:
		return 0
	elif sorted(a) == sorted(b):
		n = 0
		for i in range(len(b)):
			n += 1
			b = xx(b)
			if b == a:
				return n
	return -1


def shifted_diff(first, second):
	if len(first) != len(second):
		return -1
	return (second * 2).find(first)


from collections import deque

def shifted_diff(f, s):
	(d1, d2) = (deque(f), deque(s))
	l = [d2.rotate(-1) or d1 == d2 for i in range(len(f))]
	return (l.index(True) + 1) % len(l) if True in l else -1