Cody

Problem 42323. With apologies to William Blake

Solution 2126231

Submitted on 12 Feb 2020 by Malcolm Wildgoose
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(isequal(symmetry(27),3))

ans = 3

2   Pass
assert(isequal(symmetry(801),0))

3   Pass
assert(isequal(symmetry(900),100))

ans = 100

4   Pass
assert(isequal(symmetry(88887),1))

ans = 1

5   Pass
assert(isequal(symmetry(1234567),65433))

ans = 65433

6   Pass
assert(isequal(symmetry(34567890),3432110))

ans = 1000000 ans = 2000000 ans = 3000000 ans = 3432110

7   Pass
format long g x=ceil(1e9*rand); j=389e9+x assert(isequal(8e11-symmetry(j),j))

j = 389569047405 ans = 100000000000 ans = 200000000000 ans = 300000000000 ans = 400000000000 ans = 410000000000 ans = 410430952595

8   Pass
format long g x=ceil(1e10*rand); j=889e10+x v=symmetry(j); assert(isequal(1e13-v,j))

j = 8894875192398 ans = 1000000000000 ans = 1100000000000 ans = 1105124807602

9   Pass
x=2^40-1; assert(isequal(symmetry(symmetry(symmetry(symmetry(x)))),7775))

ans = 488372225 ans = 100000000 ans = 200000000 ans = 300000000 ans = 311627775 ans = 100000 ans = 172225 ans = 7775

Suggested Problems

More from this Author80

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!