Cody

# Problem 1084. Square Digits Number Chain Terminal Value (Inspired by Project Euler Problem 92)

Solution 468434

Submitted on 9 Jul 2014 by goc3
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
%% assert(digits_squared_chain(649) == 1)

arr = 6 4 9 x = 133 arr = 1 3 3 x = 19 arr = 1 9 x = 82 arr = 8 2 x = 68 arr = 6 8 x = 100 arr = 1 0 0 x = 1

2   Pass
%% assert(digits_squared_chain(79) == 1)

arr = 7 9 x = 130 arr = 1 3 0 x = 10 arr = 1 0 x = 1

3   Pass
%% assert(digits_squared_chain(608) == 1)

arr = 6 0 8 x = 100 arr = 1 0 0 x = 1

4   Pass
%% assert(digits_squared_chain(487) == 1)

arr = 4 8 7 x = 129 arr = 1 2 9 x = 86 arr = 8 6 x = 100 arr = 1 0 0 x = 1

5   Pass
%% assert(digits_squared_chain(739) == 1)

arr = 7 3 9 x = 139 arr = 1 3 9 x = 91 arr = 9 1 x = 82 arr = 8 2 x = 68 arr = 6 8 x = 100 arr = 1 0 0 x = 1

6   Pass
%% assert(digits_squared_chain(565) == 1)

arr = 5 6 5 x = 86 arr = 8 6 x = 100 arr = 1 0 0 x = 1

7   Pass
%% assert(digits_squared_chain(68) == 1)

arr = 6 8 x = 100 arr = 1 0 0 x = 1

8   Pass
%% assert(digits_squared_chain(383) == 1)

arr = 3 8 3 x = 82 arr = 8 2 x = 68 arr = 6 8 x = 100 arr = 1 0 0 x = 1

9   Pass
%% assert(digits_squared_chain(379) == 1)

arr = 3 7 9 x = 139 arr = 1 3 9 x = 91 arr = 9 1 x = 82 arr = 8 2 x = 68 arr = 6 8 x = 100 arr = 1 0 0 x = 1

10   Pass
%% assert(digits_squared_chain(203) == 1)

arr = 2 0 3 x = 13 arr = 1 3 x = 10 arr = 1 0 x = 1

11   Pass
%% assert(digits_squared_chain(632) == 1)

arr = 6 3 2 x = 49 arr = 4 9 x = 97 arr = 9 7 x = 130 arr = 1 3 0 x = 10 arr = 1 0 x = 1

12   Pass
%% assert(digits_squared_chain(391) == 1)

arr = 3 9 1 x = 91 arr = 9 1 x = 82 arr = 8 2 x = 68 arr = 6 8 x = 100 arr = 1 0 0 x = 1

13   Pass
%% assert(digits_squared_chain(863) == 1)

arr = 8 6 3 x = 109 arr = 1 0 9 x = 82 arr = 8 2 x = 68 arr = 6 8 x = 100 arr = 1 0 0 x = 1

14   Pass
%% assert(digits_squared_chain(13) == 1)

arr = 1 3 x = 10 arr = 1 0 x = 1

15   Pass
%% assert(digits_squared_chain(100) == 1)

arr = 1 0 0 x = 1

16   Pass
%% assert(digits_squared_chain(236) == 1)

arr = 2 3 6 x = 49 arr = 4 9 x = 97 arr = 9 7 x = 130 arr = 1 3 0 x = 10 arr = 1 0 x = 1

17   Pass
%% assert(digits_squared_chain(293) == 1)

arr = 2 9 3 x = 94 arr = 9 4 x = 97 arr = 9 7 x = 130 arr = 1 3 0 x = 10 arr = 1 0 x = 1

18   Pass
%% assert(digits_squared_chain(230) == 1)

arr = 2 3 0 x = 13 arr = 1 3 x = 10 arr = 1 0 x = 1

19   Pass
%% assert(digits_squared_chain(31) == 1)

arr = 3 1 x = 10 arr = 1 0 x = 1

20   Pass
%% assert(digits_squared_chain(806) == 1)

arr = 8 0 6 x = 100 arr = 1 0 0 x = 1

21   Pass
%% assert(digits_squared_chain(623) == 1)

arr = 6 2 3 x = 49 arr = 4 9 x = 97 arr = 9 7 x = 130 arr = 1 3 0 x = 10 arr = 1 0 x = 1

22   Pass
%% assert(digits_squared_chain(7) == 1)

arr = 7 x = 49 arr = 4 9 x = 97 arr = 9 7 x = 130 arr = 1 3 0 x = 10 arr = 1 0 x = 1

23   Pass
%% assert(digits_squared_chain(13) == 1)

arr = 1 3 x = 10 arr = 1 0 x = 1

24   Pass
%% assert(digits_squared_chain(836) == 1)

arr = 8 3 6 x = 109 arr = 1 0 9 x = 82 arr = 8 2 x = 68 arr = 6 8 x = 100 arr = 1 0 0 x = 1

25   Pass
%% assert(digits_squared_chain(954) == 89)

arr = 9 5 4 x = 122 arr = 1 2 2 x = 9 arr = 9 x = 81 arr = 8 1 x = 65 arr = 6 5 x = 61 arr = 6 1 x = 37 arr = 3 7 x = 58 arr = 5 8 x = 89

26   Pass
%% assert(digits_squared_chain(567) == 89)

arr = 5 6 7 x = 110 arr = 1 1 0 x = 2 arr = 2 x = 4 arr = 4 x = 16 arr = 1 6 x = 37 arr = 3 7 x = 58 arr = 5 8 x = 89

27   Pass
%% assert(digits_squared_chain(388) == 89)

arr = 3 8 8 x = 137 arr = 1 3 7 x = 59 arr = 5 9 x = 106 arr = 1 0 6 x = 37 arr = 3 7 x = 58 arr = 5 8 x = 89

28   Pass
%% assert(digits_squared_chain(789) == 89)

arr = 7 8 9 x = 194 arr = 1 9 4 x = 98 arr = 9 8 x = 145 arr = 1 4 5 x = 42 arr = 4 2 x = 20 arr = 2 0 x = 4 arr = 4 x = 16 arr = 1 6 x = 37 arr = 3 7 x = 58 arr = 5 8 x = 89

29   Pass
%% assert(digits_squared_chain(246) == 89)

arr = 2 4 6 x = 56 arr = 5 6 x = 61 arr = 6 1 x = 37 arr = 3 7 x = 58 arr = 5 8 x = 89

30   Pass
%% assert(digits_squared_chain(787) == 89)

arr = 7 8 7 x = 162 arr = 1 6 2 x = 41 arr = 4 1 x = 17 arr = 1 7 x = 50 arr = 5 0 x = 25 arr = 2 5 x = 29 arr = 2 9 x = 85 arr = 8 5 x = 89

31   Pass
%% assert(digits_squared_chain(311) == 89)

arr = 3 1 1 x = 11 arr = 1 1 x = 2 arr = 2 x = 4 arr = 4 x = 16 arr = 1 6 x = 37 arr = 3 7 x = 58 arr = 5 8 x = 89

32   Pass
%% assert(digits_squared_chain(856) == 89)

arr = 8 5 6 x = 125 arr = 1 2 5 x = 30 arr = 3 0 x = 9 arr = 9 x = 81 arr = 8 1 x = 65 arr = 6 5 x = 61 arr = 6 1 x = 37 arr = 3 7 x = 58 arr = 5 8 x = 89

33   Pass
%% assert(digits_squared_chain(143) == 89)

arr = 1 4 3 x = 26 arr = 2 6 x = 40 arr = 4 0 x = 16 arr = 1 6 x = 37 arr = 3 7 x = 58 arr = 5 8 x = 89

34   Pass
%% assert(digits_squared_chain(873) == 89)

arr = 8 7 3 x = 122 arr = 1 2 2 x = 9 arr = 9 x = 81 arr = 8 1 x = 65 arr = 6 5 x = 61 arr = 6 1 x = 37 arr = 3 7 x = 58 arr = 5 8 x = 89

35   Pass
%% assert(digits_squared_chain(215) == 89)

arr = 2 1 5 x = 30 arr = 3 0 x = 9 arr = 9 x = 81 arr = 8 1 x = 65 arr = 6 5 x = 61 arr = 6 1 x = 37 arr = 3 7 x = 58 arr = 5 8 x = 89

36   Pass
%% assert(digits_squared_chain(995) == 89)

arr = 9 9 5 x = 187 arr = 1 8 7 x = 114 arr = 1 1 4 x = 18 arr = 1 8 x = 65 arr = 6 5 x = 61 arr = 6 1 x = 37 arr = 3 7 x = 58 arr = 5 8 x = 89

37   Pass
%% assert(digits_squared_chain(455) == 89)

arr = 4 5 5 x = 66 arr = 6 6 x = 72 arr = 7 2 x = 53 arr = 5 3 x = 34 arr = 3 4 x = 25 arr = 2 5 x = 29 arr = 2 9 x = 85 arr = 8 5 x = 89

38   Pass
%% assert(digits_squared_chain(948) == 89)

arr = 9 4 8 x = 161 arr = 1 6 1 x = 38 arr = 3 8 x = 73 arr = 7 3 x = 58 arr = 5 8 x = 89

39   Pass
%% assert(digits_squared_chain(875) == 89)

arr = 8 7 5 x = 138 arr = 1 3 8 x = 74 arr = 7 4 x = 65 arr = 6 5 x = 61 arr = 6 1 x = 37 arr = 3 7 x = 58 arr = 5 8 x = 89

40   Pass
%% assert(digits_squared_chain(788) == 89)

arr = 7 8 8 x = 177 arr = 1 7 7 x = 99 arr = 9 9 x = 162 arr = 1 6 2 x = 41 arr = 4 1 x = 17 arr = 1 7 x = 50 arr = 5 0 x = 25 arr = 2 5 x = 29 arr = 2 9 x = 85 arr = 8 5 x = 89

41   Pass
%% assert(digits_squared_chain(722) == 89)

arr = 7 2 2 x = 57 arr = 5 7 x = 74 arr = 7 4 x = 65 arr = 6 5 x = 61 arr = 6 1 x = 37 arr = 3 7 x = 58 arr = 5 8 x = 89

42   Pass
%% assert(digits_squared_chain(250) == 89)

arr = 2 5 0 x = 29 arr = 2 9 x = 85 arr = 8 5 x = 89

43   Pass
%% assert(digits_squared_chain(227) == 89)

arr = 2 2 7 x = 57 arr = 5 7 x = 74 arr = 7 4 x = 65 arr = 6 5 x = 61 arr = 6 1 x = 37 arr = 3 7 x = 58 arr = 5 8 x = 89

44   Pass
%% assert(digits_squared_chain(640) == 89)

arr = 6 4 0 x = 52 arr = 5 2 x = 29 arr = 2 9 x = 85 arr = 8 5 x = 89

45   Pass
%% assert(digits_squared_chain(835) == 89)

arr = 8 3 5 x = 98 arr = 9 8 x = 145 arr = 1 4 5 x = 42 arr = 4 2 x = 20 arr = 2 0 x = 4 arr = 4 x = 16 arr = 1 6 x = 37 arr = 3 7 x = 58 arr = 5 8 x = 89

46   Pass
%% assert(digits_squared_chain(965) == 89)

arr = 9 6 5 x = 142 arr = 1 4 2 x = 21 arr = 2 1 x = 5 arr = 5 x = 25 arr = 2 5 x = 29 arr = 2 9 x = 85 arr = 8 5 x = 89

47   Pass
%% assert(digits_squared_chain(726) == 89)

arr = 7 2 6 x = 89

48   Pass
%% assert(digits_squared_chain(689) == 89)

arr = 6 8 9 x = 181 arr = 1 8 1 x = 66 arr = 6 6 x = 72 arr = 7 2 x = 53 arr = 5 3 x = 34 arr = 3 4 x = 25 arr = 2 5 x = 29 arr = 2 9 x = 85 arr = 8 5 x = 89