Problem 44359. 5th Time's a Charm
Write a function that will return the input value. However, your function must fail the first four times, only functioning properly every fifth time. Furthermore, the first four times the function is called, successively closer, but not correct, values must be supplied by the function.
For example, if x = 10, you may return any number not equal to 10 the first function call. Here, we will return 27. Then, the second function call must return a value between 27 and 10, but not equal to either, and so on, until 10 is returned the fifth time.
Solution Stats
Problem Comments
-
5 Comments
Strange - the test suites are not independent. I thought they normally were.
Yes Andrew, they are not. I also had to struggle with the same, when only the first input data passed and rest failed.
I can't get a way to solve this problem. Some hint?
Can't solve this either. Not even a clue on how to do it.
Hint see documentation for presistent variables
PS : last test case is evil
Solution Comments
Show commentsProblem Recent Solvers182
Suggested Problems
-
Reverse the Words (not letters) of a String
427 Solvers
-
Make an awesome ramp for a tiny motorcycle stuntman
605 Solvers
-
Construct an index vector from two input vectors in vectorized fashion
367 Solvers
-
Get the elements of diagonal and antidiagonal for any m-by-n matrix
462 Solvers
-
Predicting life and death of a memory-less light bulb
320 Solvers
More from this Author139
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!