Cody

Solution 1293114

Submitted on 17 Oct 2017 by Reggie Wilcox
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))

xlast = NaN count = 0 count = 1 y = -3 xlast = 1 count = 2 y = -2 xlast = 1 count = 3 y = -1 xlast = 1 count = 4 y = 0 xlast = 1 count = 5 y = 1 xlast = 1

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

count = 0 count = 1 y = -5 xlast = -1 count = 2 y = -4 xlast = -1 count = 3 y = -3 xlast = -1 count = 4 y = -2 xlast = -1 count = 5 y = -1 xlast = -1

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

count = 0 count = 1 y = 38 xlast = 42 count = 2 y = 39 xlast = 42 count = 3 y = 40 xlast = 42 count = 4 y = 41 xlast = 42 count = 5 y = 42 xlast = 42

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

count = 0 count = 1 y = -4.0000 + 1.0000i xlast = 0.0000 + 1.0000i count = 2 y = -3.0000 + 1.0000i xlast = 0.0000 + 1.0000i count = 3 y = -2.0000 + 1.0000i xlast = 0.0000 + 1.0000i count = 4 y = -1.0000 + 1.0000i xlast = 0.0000 + 1.0000i count = 5 y = 0.0000 + 1.0000i xlast = 0.0000 + 1.0000i

Suggested Problems

More from this Author139