Cody

# Problem 44359. 5th Time's a Charm

Solution 1349657

Submitted on 19 Nov 2017 by Nabor Reyna Jr.
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
x = 1; y1 = fifth_times_a_charm(x); assert(~isequal(y1,x)) y2 = fifth_times_a_charm(x); assert(~isequal(y2,x)) assert(abs(x-y2)<abs(x-y1)) y3 = fifth_times_a_charm(x); assert(~isequal(y3,x)) assert(abs(x-y3)<abs(x-y2)) y4 = fifth_times_a_charm(x); assert(~isequal(y4,x)) assert(abs(x-y4)<abs(x-y3)) y5 = fifth_times_a_charm(x); assert(isequal(y5,x))

r = 1 r = 1.8000 x = 1.8000 delta = 0.8000 r = 1.4000 x = 1.4000 delta = 0.4000 r = 1.2000 x = 1.2000 delta = 0.2000 r = 1.1000 x = 1.1000 delta = 0.1000 s = 'one / ten'

2   Pass
x = -1; y1 = fifth_times_a_charm(x); assert(~isequal(y1,x)) y2 = fifth_times_a_charm(x); assert(~isequal(y2,x)) assert(abs(x-y2)<abs(x-y1)) y3 = fifth_times_a_charm(x); assert(~isequal(y3,x)) assert(abs(x-y3)<abs(x-y2)) y4 = fifth_times_a_charm(x); assert(~isequal(y4,x)) assert(abs(x-y4)<abs(x-y3)) y5 = fifth_times_a_charm(x); assert(isequal(y5,x))

r = -1 r = -0.2000 x = -0.2000 delta = 0.8000 r = -0.6000 x = -0.6000 delta = 0.4000 r = -0.8000 x = -0.8000 delta = 0.2000 r = -0.9000 x = -0.9000 delta = 0.1000 s = 'one / ten'

3   Pass
x = 42; y1 = fifth_times_a_charm(x); assert(~isequal(y1,x)) y2 = fifth_times_a_charm(x); assert(~isequal(y2,x)) assert(abs(x-y2)<abs(x-y1)) y3 = fifth_times_a_charm(x); assert(~isequal(y3,x)) assert(abs(x-y3)<abs(x-y2)) y4 = fifth_times_a_charm(x); assert(~isequal(y4,x)) assert(abs(x-y4)<abs(x-y3)) y5 = fifth_times_a_charm(x); assert(isequal(y5,x))

r = 42 r = 42.8000 x = 42.8000 delta = 0.8000 r = 42.4000 x = 42.4000 delta = 0.4000 r = 42.2000 x = 42.2000 delta = 0.2000 r = 42.1000 x = 42.1000 delta = 0.1000 s = 'one / ten'

4   Pass
x = i; y1 = fifth_times_a_charm(x); assert(~isequal(y1,x)) y2 = fifth_times_a_charm(x); assert(~isequal(y2,x)) assert(abs(x-y2)<abs(x-y1)) y3 = fifth_times_a_charm(x); assert(~isequal(y3,x)) assert(abs(x-y3)<abs(x-y2)) y4 = fifth_times_a_charm(x); assert(~isequal(y4,x)) assert(abs(x-y4)<abs(x-y3)) y5 = fifth_times_a_charm(x); assert(isequal(y5,x))

r = 0.0000 + 1.0000i r = 0.8000 + 1.0000i x = 0.8000 + 1.0000i delta = 0.8000 r = 0.4000 + 1.0000i x = 0.4000 + 1.0000i delta = 0.4000 r = 0.2000 + 1.0000i x = 0.2000 + 1.0000i delta = 0.2000 r = 0.1000 + 1.0000i x = 0.1000 + 1.0000i delta = 0.1000 s = 'one / ten'