# Task
 let F(N) be the sum square of digits of N. So:
 
 `F(1) = 1, F(3) = 9, F(123) = 14`

 Choose a number A, the sequence {A0, A1, ...} is defined as followed:
  ```
  A0 = A
  A1 = F(A0)
  A2 = F(A1) ...
  ```
  
  if A = 123, we have:
  ```
  123 → 14(1 x 1 + 2 x 2 + 3 x 3)
      → 17(1 x 1 + 4 x 4)
      → 50(1 x 1 + 7 x 7)
      → 25(5 x 5 + 0 x 0)
      → 29(2 x 2 + 5 x 5)
      → 85(2 x 2 + 9 x 9)
      → 89(8 x 8 + 5 x 5)             ---
      → 145(8 x 8 + 9 x 9)             |r
      → 42(1 x 1 + 4 x 4 + 5 x 5)      |e
      → 20(4 x 4 + 2 x 2)              |p
      → 4(2 x 2 + 0 x 0)               |e
      → 16(4 x 4)                      |a
      → 37(1 x 1 + 6 x 6)              |t
      → 58(3 x 3 + 7 x 7)              |
      → 89(5 x 5 + 8 x 8)             --- 
      → ......
  ```

 As you can see, the sequence repeats itself. Interestingly, whatever A is, there's an index such that from it, the sequence repeats again and again.

 Let `G(A)` be the minimum length of the repeat sequence with A0 = A. 

 So `G(85) = 8` (8 number : `89,145,42, 20,4,16,37,58`)

 Your task is to find G(A) and return it.

# Input/Output


 - `[input]` integer `a0`

  the A0 number


 - `[output]` an integer

  the length of the repeat sequence

Difficulty: EASY
Starter code: def repeat_sequence_len(n):
	

Solutions:
from itertools import count

def repeat_sequence_len(n):
	memo = {}
	for i in count():
		if n in memo:
			return i - memo[n]
		memo[n] = i
		n = sum((d * d for d in map(int, str(n))))


def F(n):
	return sum((int(d) ** 2 for d in str(n)))

def repeat_sequence_len(n):
	seq = [n]
	c = F(n)
	while c not in seq:
		seq.append(c)
		c = F(c)
	return len(seq) - seq.index(c)


digits = lambda n: map(int, str(n))

def repeat_sequence_len(n):
	seen = []
	while n not in seen:
		seen.append(n)
		n = sum((x * x for x in digits(n)))
	return len(seen) - seen.index(n)


def repeat_sequence_len(n):
	s = []
	while True:
		n = sum((int(i) ** 2 for i in str(n)))
		if n not in s:
			s.append(n)
		else:
			return len(s[s.index(n):])


def f(n):
	return sum((int(x) ** 2 for x in str(n)))

def repeat_sequence_len(n):
	(d, i) = ({}, 0)
	while n not in d:
		d[n] = i
		i += 1
		n = f(n)
	return i - d[n]


def repeat_sequence_len(n):
	f = lambda n: sum((int(c) ** 2 for c in str(n)))
	tortoise = n
	rabbit = f(n)
	while tortoise != rabbit:
		tortoise = f(tortoise)
		rabbit = f(f(rabbit))
	rabbit = f(rabbit)
	result = 1
	while tortoise != rabbit:
		rabbit = f(rabbit)
		result += 1
	return result


tr = lambda n: sum((int(i) ** 2 for i in str(n)))

def repeat_sequence_len(n):
	if n < 10:
		return n
	tmp = []
	n = tr(n)
	while n not in tmp:
		tmp.append(n)
		n = tr(n)
	return len(tmp) - tmp.index(n)


def repeat_sequence_len(n):
	a = [n]
	while a.count(a[-1]) == 1:
		a.append(sum((int(c) ** 2 for c in str(a[-1]))))
	return len(a) - a.index(a[-1]) - 1


f = lambda n: sum((int(d) ** 2 for d in str(n)))

def repeat_sequence_len(n):
	S = []
	while n not in S:
		S.append(n)
		n = f(n)
	return len(S) - S.index(n)


def repeat_sequence_len(n):
	(seen, i) = ({}, 0)
	n = sum([int(x) ** 2 for x in str(n)])
	while n not in seen:
		seen[n] = i
		n = sum([int(x) ** 2 for x in str(n)])
		i += 1
	return i - seen[n]