Cody

# Problem 44359. 5th Time's a Charm

Solution 1881483

Submitted on 23 Jul 2019
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   Fail
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))

y = 5 y = 4 y = 3 y = 2 y = 1

Assertion failed.

2   Fail
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))

y = -5 y = -4 y = -3 y = -2 y = -1

Assertion failed.

3   Fail
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))

y = 210 y = 168 y = 126 y = 84 y = 42

Assertion failed.

4   Fail
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))

y = 0.0000 + 5.0000i y = 0.0000 + 4.0000i y = 0.0000 + 3.0000i y = 0.0000 + 2.0000i y = 0.0000 + 1.0000i

Assertion failed.